diff options
author | Alan Modra <amodra@gmail.com> | 2017-08-21 13:28:06 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-08-21 23:29:29 +0930 |
commit | 487b6440dad57440939fab7afdd84a218b612796 (patch) | |
tree | d725ac9d34e642287396a7e9c0c0d9e923a8ab3c /bfd | |
parent | e3c2f928b8f9afce6fdedaa1ddedfaa1d305aa9d (diff) | |
download | gdb-487b6440dad57440939fab7afdd84a218b612796.zip gdb-487b6440dad57440939fab7afdd84a218b612796.tar.gz gdb-487b6440dad57440939fab7afdd84a218b612796.tar.bz2 |
Make __start/__stop symbols protected visibility
They can't be hidden visibility since apparently people use dlsym to
look them up.
bfd/
PR ld/21964
* elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols.
* elflink.c (bfd_elf_define_start_stop): Rewrite.
ld/
PR ld/21964
* testsuite/ld-elf/pr21562a.d: Update for changed start/stop symbols.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/sizeofa.d: Likewise.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/startofa.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.
* testsuite/ld-gc/pr20022.d: Likewise.
* testsuite/ld-gc/start.d: Likewise.
* testsuite/ld-elf/pr21964-1a.c: New file.
* testsuite/ld-elf/pr21964-1b.c: New file.
* testsuite/ld-elf/pr21964-2a.c: New file.
* testsuite/ld-elf/pr21964-2b.c: New file.
* testsuite/ld-elf/shared.exp: Run PR ld/21964 tests.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 4 | ||||
-rw-r--r-- | bfd/elflink.c | 34 |
3 files changed, 33 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6badc5d..15f1a3f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2017-08-21 Alan Modra <amodra@gmail.com> + H.J. Lu <hongjiu.lu@intel.com> + + PR ld/21964 + * elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols. + * elflink.c (bfd_elf_define_start_stop): Rewrite. + 2017-08-21 Hans-Peter Nilsson <hp@bitrange.com> PR ld/20125 diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 92a8e02..83958e4 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2802,7 +2802,9 @@ extern asection _bfd_elf_large_com_section; library, if any. A unique symbol can never be bound locally. */ #define SYMBOLIC_BIND(INFO, H) \ (!(H)->unique_global \ - && ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))) + && ((INFO)->symbolic \ + || (H)->start_stop \ + || ((INFO)->dynamic && !(H)->dynamic))) #ifdef __cplusplus } diff --git a/bfd/elflink.c b/bfd/elflink.c index f9886dc..ceacb37 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -14260,18 +14260,30 @@ struct bfd_link_hash_entry * bfd_elf_define_start_stop (struct bfd_link_info *info, const char *symbol, asection *sec) { - struct bfd_link_hash_entry *h; + struct elf_link_hash_entry *h; - h = bfd_generic_define_start_stop (info, symbol, sec); - if (h != NULL) + h = elf_link_hash_lookup (elf_hash_table (info), symbol, + FALSE, FALSE, TRUE); + if (h != NULL + && (h->root.type == bfd_link_hash_undefined + || h->root.type == bfd_link_hash_undefweak + || (h->ref_regular && !h->def_regular))) { - struct elf_link_hash_entry *eh = (struct elf_link_hash_entry *) h; - eh->start_stop = 1; - eh->u2.start_stop_section = sec; - _bfd_elf_link_hash_hide_symbol (info, eh, TRUE); - if (ELF_ST_VISIBILITY (eh->other) != STV_INTERNAL) - eh->other = ((eh->other & ~ELF_ST_VISIBILITY (-1)) - | STV_HIDDEN); + h->root.type = bfd_link_hash_defined; + h->root.u.def.section = sec; + h->root.u.def.value = 0; + h->def_regular = 1; + h->def_dynamic = 0; + h->start_stop = 1; + h->u2.start_stop_section = sec; + if (symbol[0] == '.') + { + /* .startof. and .sizeof. symbols are local. */ + _bfd_elf_link_hash_hide_symbol (info, h, TRUE); + } + else if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) + h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED; + return &h->root; } - return h; + return NULL; } |