mirror of
https://github.com/apache/nuttx.git
synced 2025-12-07 18:12:33 +08:00
symtabs: improve handling of symbol lookups
When CONFIG_SYMTAB_ORDEREDBYNAME is selected most code will use the ordered search function. When it is not selected no code will use the ordered search function. This change merges the two functions and varies its behaviour based on the config setting, such that all callers can simply call the one search function and get the best behaviour. An additional configuration option allows leading underscores to be stripped from symbols being relocated in loaded objects. This allows toolchains which prefix C symbol with underscores to make loadable ELF objects.
This commit is contained in:
committed by
Xiang Xiao
parent
c80cdf06c2
commit
c9db653c8d
@@ -66,12 +66,3 @@ config BINFMT_CONSTRUCTORS
|
||||
---help---
|
||||
Built-in support for C++ constructors in loaded modules. Currently
|
||||
only support for ELF binary formats.
|
||||
|
||||
config SYMTAB_ORDEREDBYNAME
|
||||
bool "Symbol Tables Ordered by Name"
|
||||
default n
|
||||
---help---
|
||||
Select if the symbol table is ordered by symbol name. In this case,
|
||||
the logic can perform faster lookups using a binary search.
|
||||
Otherwise, the symbol table is assumed to be un-ordered and only
|
||||
slow, linear searches are supported.
|
||||
|
||||
@@ -290,14 +290,8 @@ int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf_Sym *sym,
|
||||
|
||||
/* Check if the base code exports a symbol of this name */
|
||||
|
||||
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
|
||||
symbol = symtab_findorderedbyname(exports,
|
||||
(FAR char *)loadinfo->iobuffer,
|
||||
nexports);
|
||||
#else
|
||||
symbol = symtab_findbyname(exports, (FAR char *)loadinfo->iobuffer,
|
||||
nexports);
|
||||
#endif
|
||||
if (!symbol)
|
||||
{
|
||||
berr("SHN_UNDEF: Exported symbol \"%s\" not found\n",
|
||||
|
||||
@@ -461,11 +461,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||
|
||||
/* Find the exported symbol value for this symbol name. */
|
||||
|
||||
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
|
||||
symbol = symtab_findorderedbyname(exports, symname, nexports);
|
||||
#else
|
||||
symbol = symtab_findbyname(exports, symname, nexports);
|
||||
#endif
|
||||
if (!symbol)
|
||||
{
|
||||
berr("Exported symbol \"%s\" not found\n", symname);
|
||||
|
||||
Reference in New Issue
Block a user