aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-addr.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-05-07 02:29:54 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-07-01 23:48:52 +0100
commitb6084a958f20b795e5e0a0644d72b6e162334cdf (patch)
tree2fd599d397fae9cfc1df09155556b568123d63bf /elf/dl-addr.c
parent2cbec365663cd0e2fe21f77b1f5e20ae3ab5f538 (diff)
downloadglibc-b6084a958f20b795e5e0a0644d72b6e162334cdf.tar
glibc-b6084a958f20b795e5e0a0644d72b6e162334cdf.tar.gz
glibc-b6084a958f20b795e5e0a0644d72b6e162334cdf.tar.bz2
glibc-b6084a958f20b795e5e0a0644d72b6e162334cdf.zip
Treat STV_HIDDEN and STV_INTERNAL symbols as STB_LOCAL
In a reference to PR ld/19908 make ld.so respect symbol export classes aka visibility and treat STV_HIDDEN and STV_INTERNAL symbols as local, preventing such symbols from preempting exported symbols. According to the ELF gABI[1] neither STV_HIDDEN nor STV_INTERNAL symbols are supposed to be present in linked binaries: "A hidden symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." "An internal symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." however some GNU binutils versions produce such symbols in some cases. PR ld/19908 is one and we also have this note in scripts/abilist.awk: so clearly there is linked code out there which contains such symbols which is prone to symbol table misinterpretation, and it'll be more productive if we handle this gracefully, under the Robustness Principle: "be liberal in what you accept, and conservative in what you produce", especially as this is a simple (STV_HIDDEN|STV_INTERNAL) => STB_LOCAL mapping. References: [1] "System V Application Binary Interface - DRAFT - 24 April 2001", The Santa Cruz Operation, Inc., "Symbol Table", <http://www.sco.com/developers/gabi/2001-04-24/ch4.symtab.html> * sysdeps/generic/ldsodefs.h (dl_symbol_visibility_binds_local_p): New inline function. * elf/dl-addr.c (determine_info): Treat hidden and internal symbols as local. * elf/dl-lookup.c (do_lookup_x): Likewise. * elf/dl-reloc.c (RESOLVE_MAP): Likewise.
Diffstat (limited to 'elf/dl-addr.c')
-rw-r--r--elf/dl-addr.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index 291ff55816..1b16a58ced 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -88,6 +88,7 @@ determine_info (const ElfW(Addr) addr, struct link_map *match, Dl_info *info,
for (; (void *) symtab < (void *) symtabend; ++symtab)
if ((ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL
|| ELFW(ST_BIND) (symtab->st_info) == STB_WEAK)
+ && __glibc_likely (!dl_symbol_visibility_binds_local_p (symtab))
&& ELFW(ST_TYPE) (symtab->st_info) != STT_TLS
&& (symtab->st_shndx != SHN_UNDEF
|| symtab->st_value != 0)