diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-01-18 16:21:46 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-01-18 16:22:13 -0800 |
commit | c5bdb022609634970dd981517d478e6cc332629c (patch) | |
tree | 02fa73ce55df5b1450b4e10e47bfe450576437d7 /ld | |
parent | 85ed4f7ecea48a92b33f4c6b3f8d9e0e858ed617 (diff) | |
download | gdb-c5bdb022609634970dd981517d478e6cc332629c.zip gdb-c5bdb022609634970dd981517d478e6cc332629c.tar.gz gdb-c5bdb022609634970dd981517d478e6cc332629c.tar.bz2 |
solaris2.em: Fold after_allocation into before_allocation
Since all ELF linkers call check_relocs after opening all inputs, we
can fold after_allocation into before_allocation so that local dynamic
symbols will be placed before global dynamic symbols in .dynsym section.
This fixed:
FAIL: Common symbol override test (auxiliary shared object build)
FAIL: ld-elf/pr19617a
FAIL: ld-elf/pr19698
for i386-solaris2.12 and x86_64-solaris2.12 targets.
PR ld/22728
* emultempl/solaris2.em (elf_solaris2_after_allocation): Fold
into ...
(elf_solaris2_before_allocation): This.
(LDEMUL_AFTER_ALLOCATION): Removed.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 8 | ||||
-rw-r--r-- | ld/emultempl/solaris2.em | 68 |
2 files changed, 35 insertions, 41 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 3801705..6b6886e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2018-01-18 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/22728 + * emultempl/solaris2.em (elf_solaris2_after_allocation): Fold + into ... + (elf_solaris2_before_allocation): This. + (LDEMUL_AFTER_ALLOCATION): Removed. + 2018-01-18 Alan Modra <amodra@gmail.com> * emultempl/ppc32elf.em: Support optional --plt-align arg. diff --git a/ld/emultempl/solaris2.em b/ld/emultempl/solaris2.em index 7c3fafb..cc009e0 100644 --- a/ld/emultempl/solaris2.em +++ b/ld/emultempl/solaris2.em @@ -35,8 +35,12 @@ fragment <<EOF .dynsym table of executables and shared objects. If generating a versioned shared object, they must always be bound to the base version. + The Solaris 2 ABI also requires two local symbols to be emitted for + every executable and shared object. + Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output File, p.63. */ + static void elf_solaris2_before_allocation (void) { @@ -50,6 +54,13 @@ elf_solaris2_before_allocation (void) "_etext", NULL }; + /* Local symbols required by the Solaris 2 ABI. Already emitted by + emulparams/solaris2.sh. */ + static const char *local_syms[] = { + "_START_", + "_END_", + NULL + }; const char **sym; /* Do this for both executables and shared objects. */ @@ -72,6 +83,22 @@ elf_solaris2_before_allocation (void) /* Emit it into the .dynamic section, too. */ bfd_elf_link_record_dynamic_symbol (&link_info, h); } + + for (sym = local_syms; *sym != NULL; sym++) + { + struct elf_link_hash_entry *h; + + /* Lookup symbol. */ + h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym, + FALSE, FALSE, FALSE); + if (h == NULL) + continue; + + /* Turn it local. */ + h->forced_local = 1; + /* Type should be STT_OBJECT, not STT_NOTYPE. */ + h->type = STT_OBJECT; + } } /* Only do this if emitting a shared object and versioning is in place. */ @@ -110,47 +137,6 @@ elf_solaris2_before_allocation (void) gld${EMULATION_NAME}_before_allocation (); } -/* The Solaris 2 ABI requires two local symbols to be emitted for every - executable and shared object. - - Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output - File, p.63. */ -static void -elf_solaris2_after_allocation (void) -{ - /* Local symbols required by the Solaris 2 ABI. Already emitted by - emulparams/solaris2.sh. */ - static const char *local_syms[] = { - "_START_", - "_END_", - NULL - }; - const char **sym; - - /* Do this for both executables and shared objects. */ - if (!bfd_link_relocatable (&link_info)) - { - for (sym = local_syms; *sym != NULL; sym++) - { - struct elf_link_hash_entry *h; - - /* Lookup symbol. */ - h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym, - FALSE, FALSE, FALSE); - if (h == NULL) - continue; - - /* Turn it local. */ - h->forced_local = 1; - /* Type should be STT_OBJECT, not STT_NOTYPE. */ - h->type = STT_OBJECT; - } - } - - gld${EMULATION_NAME}_after_allocation (); -} - EOF LDEMUL_BEFORE_ALLOCATION=elf_solaris2_before_allocation -LDEMUL_AFTER_ALLOCATION=elf_solaris2_after_allocation |