elf: Remove fallback to the start of DT_STRTAB for dladdr

System Internals / glibc - Fangrui Song [google.com] - 2 May 2022 16:06 UTC

When neither DT_HASH nor DT_GNU_HASH is present, the code scans [DT_SYMTAB, DT_STRTAB). However, there is no guarantee that .dynstr immediately follows .dynsym (e.g. lld typically places .gnu.version after .dynsym).

In the absence of a hash table, symbol lookup will always fail (map->l_nbuckets == 0 in dl-lookup.c) as if the object has no symbol, so it seems fair for dladdr to do the same.

8e28aa3a51 elf: Remove fallback to the start of DT_STRTAB for dladdr
elf/dl-addr.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

Upstream: sourceware.org


  • Share