summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-09 01:29:48 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-09 03:09:22 -0600
commit86d4320a0a8c2987f3f5ec39079c293fb086d9da (patch)
tree93a7c24ef08109db27ed0800ae777c324c35745f /build-aux
parentb8f3fe4923002f3978b0f8d1710b678da629e2c5 (diff)
lint-bin, stack.c.gen: INFRA: Add a way to include unused functions
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/stack.c.gen55
1 files changed, 55 insertions, 0 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen
index 2b7feef..576e446 100755
--- a/build-aux/stack.c.gen
+++ b/build-aux/stack.c.gen
@@ -418,6 +418,12 @@ class Plugin(typing.Protocol):
# `__attribute__((constructor))`.
def init_array(self) -> typing.Collection[QName]: ...
+ # extra_includes returns a list of functions that are never
+ # called, but are included in the binary anyway. This may because
+ # it is an unused method in a used vtable. This may be because it
+ # is an atexit() callback (we never exit).
+ def extra_includes(self) -> typing.Collection[str]: ...
+
def extra_nodes(self) -> typing.Collection[Node]: ...
def indirect_callees(
self, loc: str, line: str
@@ -474,6 +480,9 @@ class CmdPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -544,6 +553,9 @@ class LibObjPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -584,6 +596,9 @@ class LibHWPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -623,6 +638,9 @@ class LibCRPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -642,6 +660,9 @@ class LibCRIPCPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -747,6 +768,9 @@ class Lib9PPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -797,6 +821,9 @@ class LibMiscPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -839,6 +866,9 @@ class PicoFmtPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -932,6 +962,9 @@ class PicoSDKPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def indirect_callees(
self, loc: str, line: str
) -> tuple[typing.Collection[QName], bool] | None:
@@ -1181,6 +1214,9 @@ class TinyUSBDevicePlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
return []
@@ -1217,6 +1253,9 @@ class NewlibPlugin:
def init_array(self) -> typing.Collection[QName]:
return [QName("register_fini")]
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
# This is accurate to
# /usr/arm-none-eabi/lib/thumb/v6-m/nofp/libg.a as of
@@ -1268,6 +1307,9 @@ class LibGCCPlugin:
def init_array(self) -> typing.Collection[QName]:
return []
+ def extra_includes(self) -> typing.Collection[str]:
+ return []
+
def extra_nodes(self) -> typing.Collection[Node]:
# This is accurate to
# /usr/lib/gcc/arm-none-eabi/14.2.0/thumb/v6-m/nofp/libgcc.a
@@ -1360,6 +1402,16 @@ def main(
return 1, False
return 0, False
+ extra_includes: list[str] = []
+ for plugin in plugins:
+ extra_includes.extend(plugin.extra_includes())
+
+ def extra_filter(name: QName) -> tuple[int, bool]:
+ nonlocal extra_includes
+ if str(name.base()) in extra_includes:
+ return 1, True
+ return 0, False
+
def location_xform(loc: str) -> str:
if not loc.startswith("/"):
return loc
@@ -1373,6 +1425,7 @@ def main(
"Threads": thread_filter,
"Interrupt handlers": intrhandler_filter,
"Misc": misc_filter,
+ "Extra": extra_filter,
},
app=PluginApplication(location_xform, plugins),
cfg_max_call_depth=100,
@@ -1444,6 +1497,8 @@ def main(
print("*/")
print("")
print("/*")
+ if result.groups["Extra"].rows:
+ print_group("Extra")
for funcname in sorted(result.included_funcs):
print(f"included: {funcname}")
print("*/")