mirror of
https://github.com/apache/nuttx.git
synced 2026-10-07 22:35:22 +00:00
libs/libc/elf: Find the symbols of a stripped shared object.
libelf_findsymtab() accepted only a SHT_SYMTAB section. A shared object that strip has processed has no SHT_SYMTAB: only its SHT_DYNSYM remains. With CONFIG_DEBUG_SYMBOLS the application build strips each module in bin/, so every FDPIC module that it builds fails to load with "No symbols in ELF file". Use the dynamic symbol table of a shared object when it has no other symbol table. It holds every symbol that the object imports or exports, which is what the loader looks up. An object with SHT_SYMTAB still uses it. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
602affafe8
commit
ba1ae7947a
1 changed files with 11 additions and 1 deletions
|
|
@ -254,7 +254,10 @@ int libelf_findsymtab(FAR struct mod_loadinfo_s *loadinfo)
|
|||
{
|
||||
int i;
|
||||
|
||||
/* Find the symbol table section header and its associated string table */
|
||||
/* Find the symbol table section header and its associated string table.
|
||||
* A stripped shared object keeps only its dynamic symbol table, which
|
||||
* holds every symbol that it imports or exports.
|
||||
*/
|
||||
|
||||
for (i = 1; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
|
|
@ -264,6 +267,13 @@ int libelf_findsymtab(FAR struct mod_loadinfo_s *loadinfo)
|
|||
loadinfo->strtabidx = loadinfo->shdr[i].sh_link;
|
||||
break;
|
||||
}
|
||||
|
||||
if (loadinfo->shdr[i].sh_type == SHT_DYNSYM &&
|
||||
loadinfo->ehdr.e_type == ET_DYN)
|
||||
{
|
||||
loadinfo->symtabidx = i;
|
||||
loadinfo->strtabidx = loadinfo->shdr[i].sh_link;
|
||||
}
|
||||
}
|
||||
|
||||
/* Verify that there is a symbol and string table */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue