summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-06 17:24:33 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-09 03:09:22 -0600
commit85a1ab9747d84e8caf4f229fdaed31c5e8d49f7a (patch)
tree68855ada6bde1d6400776b43e5a2965dfed324f8
parente232ee375afdf8da50757b3c423dc69fef07de5d (diff)
stack.c.gen: ADD-MISSING: Resolve several missing functions
-rwxr-xr-xbuild-aux/stack.c.gen50
1 files changed, 41 insertions, 9 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen
index 5bdb23c..a8a971e 100755
--- a/build-aux/stack.c.gen
+++ b/build-aux/stack.c.gen
@@ -580,9 +580,11 @@ class LibObjPlugin:
class LibHWPlugin:
pico_platform: str
+ libobj: LibObjPlugin
- def __init__(self, arg_pico_platform: str) -> None:
+ def __init__(self, arg_pico_platform: str, libobj: LibObjPlugin) -> None:
self.pico_platform = arg_pico_platform
+ self.libobj = libobj
def is_intrhandler(self, name: QName) -> bool:
return str(name.base()) in [
@@ -607,6 +609,20 @@ class LibHWPlugin:
) -> tuple[typing.Collection[QName], bool] | None:
if "/3rd-party/" in loc:
return None
+ for fn in (
+ "io_readv",
+ "io_writev",
+ "io_close",
+ "io_close_read",
+ "io_close_write",
+ "io_readwritev",
+ ):
+ if f"{fn}(" in line:
+ return self.libobj.indirect_callees(loc, f"LO_CALL(x, {fn[3:]})")
+ if "io_read(" in line:
+ return self.libobj.indirect_callees(loc, "LO_CALL(x, readv)")
+ if "io_writev(" in line:
+ return self.libobj.indirect_callees(loc, "LO_CALL(x, writev)")
if "trigger->cb(trigger->cb_arg)" in line:
ret = [
QName("alarmclock_sleep_intrhandler"),
@@ -621,7 +637,7 @@ class LibHWPlugin:
return [
QName("w5500_intrhandler"),
], False
- if "/rp2040_dmairq.c:" in loc and "handler->fn" in line:
+ if "/rp2040_dma.c:" in loc and "handler->fn" in line:
return [
QName("rp2040_hwspi_intrhandler"),
], False
@@ -1033,7 +1049,7 @@ class PicoSDKPlugin:
synthetic_node("isr_svcall", 0, {"__unhandled_user_irq"}),
synthetic_node("isr_pendsv", 0, {"__unhandled_user_irq"}),
synthetic_node("isr_systick", 0, {"__unhandled_user_irq"}),
- synthetic_node(f"__unhandled_user_irq", 0),
+ synthetic_node("__unhandled_user_irq", 0),
synthetic_node("_entry_point", 0, {"_reset_handler"}),
synthetic_node("_reset_handler", 0, {"runtime_init", "main", "exit"}),
]
@@ -1255,7 +1271,10 @@ class NewlibPlugin:
return [QName("register_fini")]
def extra_includes(self) -> typing.Collection[str]:
- return []
+ return [
+ # register_fini() calls atexit(__libc_fini_array)
+ "__libc_fini_array",
+ ]
def extra_nodes(self) -> typing.Collection[Node]:
# This is accurate to
@@ -1290,6 +1309,16 @@ class NewlibPlugin:
synthetic_node("_getpid_r", 8, {"_getpid"}),
synthetic_node("random", 8),
synthetic_node("register_fini", 8, {"atexit"}),
+ synthetic_node("atexit", 8, {"__register_exitproc"}),
+ synthetic_node(
+ "__register_exitproc",
+ 32,
+ {
+ "__retarget_lock_acquire_recursive",
+ "__retarget_lock_release_recursive",
+ },
+ ),
+ synthetic_node("__libc_fini_array", 16, {"_fini"}),
]
def indirect_callees(
@@ -1312,13 +1341,14 @@ class LibGCCPlugin:
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
- # as of Parabola's arm-none-eabi-gcc 14.2.0-1.
+ # This is accurate to Parabola's arm-none-eabi-gcc 14.2.0-1.
return [
+ # /usr/lib/gcc/arm-none-eabi/14.2.0/thumb/v6-m/nofp/libgcc.a
synthetic_node("__aeabi_idiv0", 0),
synthetic_node("__aeabi_ldiv0", 0),
synthetic_node("__aeabi_llsr", 0),
+ # /usr/lib/gcc/arm-none-eabi/14.2.0/thumb/v6-m/nofp/crti.o
+ synthetic_node("_fini", 24),
]
def indirect_callees(
@@ -1357,10 +1387,12 @@ def main(
return 1
return 0
+ libobj_plugin = LibObjPlugin(arg_c_fnames)
+
plugins += [
CmdPlugin(),
- LibObjPlugin(arg_c_fnames),
- LibHWPlugin(arg_pico_platform),
+ libobj_plugin,
+ LibHWPlugin(arg_pico_platform, libobj_plugin),
LibCRPlugin(),
LibCRIPCPlugin(),
lib9p_plugin,