modlib:move Exception section logic to modlib

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-07-09 15:17:11 +08:00 committed by Xiang Xiao
parent dfc5e4dd55
commit 91c7e8e44b
2 changed files with 24 additions and 0 deletions

View file

@ -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

View file

@ -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 */