From 0b5bfd22e39cae54d8f2ca795fd752fa57e579ba Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 24 Oct 2023 17:49:58 +0200 Subject: [PATCH] llext: add support for global functions Loadable modules can contain global (not "static") functions, even if they aren't exported for use by other modules, e.g. when a module is built from multiple .c files. Such functions are then also included in link tables and have to be re-linked. Signed-off-by: Guennadi Liakhovetski --- subsys/llext/llext.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/llext/llext.c b/subsys/llext/llext.c index e09539c6155..42a704bebb2 100644 --- a/subsys/llext/llext.c +++ b/subsys/llext/llext.c @@ -530,7 +530,7 @@ static void llext_link_plt(struct llext_loader *ldr, struct llext *ext, uint32_t stt = ELF_ST_TYPE(sym_tbl.st_info); uint32_t stb = ELF_ST_BIND(sym_tbl.st_info); - if (stt != STT_NOTYPE || sym_tbl.st_shndx != SHN_UNDEF) { + if (stt != STT_FUNC && (stt != STT_NOTYPE || sym_tbl.st_shndx != SHN_UNDEF)) { continue; } @@ -547,6 +547,8 @@ static void llext_link_plt(struct llext_loader *ldr, struct llext *ext, switch (stb) { case STB_GLOBAL: link_addr = llext_find_sym(NULL, name); + if (!link_addr) + link_addr = llext_find_sym(&ext->sym_tab, name); if (!link_addr) { LOG_WRN("PLT: cannot find idx %u name %s", j, name);