This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 91c7e8e44bb614318c871a1e63a47973597f6578 Author: anjiahao <anjia...@xiaomi.com> AuthorDate: Tue Jul 9 15:17:11 2024 +0800 modlib:move Exception section logic to modlib Signed-off-by: anjiahao <anjia...@xiaomi.com> --- libs/libc/modlib/Kconfig | 10 ++++++++++ libs/libc/modlib/modlib_load.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libs/libc/modlib/Kconfig b/libs/libc/modlib/Kconfig index f225bb3544..f1667180ad 100644 --- a/libs/libc/modlib/Kconfig +++ b/libs/libc/modlib/Kconfig @@ -106,4 +106,14 @@ config MODLIB_LOADTO_LMA relocate .data section to the final address(VMA) and zero .bss section by self. +config MODLIB_EXIDX_SECTNAME + string "ELF Section Name for Exception Index" + default ".ARM.exidx" + depends on CXX_EXCEPTION && ARCH_ARM + ---help--- + Set the name string for the exception index section on the ELF modules to + be loaded by the ELF binary loader. + + This is needed to support exception handling on loadable ELF modules. + endmenu # Module library configuration diff --git a/libs/libc/modlib/modlib_load.c b/libs/libc/modlib/modlib_load.c index 865df005a1..152f477100 100644 --- a/libs/libc/modlib/modlib_load.c +++ b/libs/libc/modlib/modlib_load.c @@ -537,6 +537,20 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo) goto errout_with_buffers; } +#ifdef CONFIG_MODLIB_EXIDX_SECTNAME + ret = modlib_findsection(loadinfo, CONFIG_MODLIB_EXIDX_SECTNAME); + if (ret < 0) + { + binfo("modlib_findsection: Exception Index section not found: %d\n", + ret); + } + else + { + up_init_exidx(loadinfo->shdr[ret].sh_addr, + loadinfo->shdr[ret].sh_size); + } +#endif + return OK; /* Error exits */