diff --git a/libs/libc/modlib/Kconfig b/libs/libc/modlib/Kconfig index f225bb3544b9d..f1667180ad17b 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 865df005a1fd1..152f477100e68 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 */