PowerPC64 dot-symbol compatibility bugfixes
authorAlan Modra <amodra@gmail.com>
Sat, 3 Dec 2016 10:30:01 +0000 (21:00 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 3 Dec 2016 10:30:01 +0000 (21:00 +1030)
commit8c5b4e5228ec94923fbdfb0008926b0b2a3f51c2
tree609d1d4f5f5f0db079c91b00c8806f818e419076
parent4e95fbcd79b84308417fc25ce12cacdb2a61c0d0
PowerPC64 dot-symbol compatibility bugfixes

Lots of fixes for the compatibility code that handles linking of
-mcall-aixdesc code (or that generated by 12 year old gcc) with
current ELFv1 ABI code.

1) A reference to a dot-symbol in an object file wasn't satisfied by a
   function descriptor in later object files.
2) The as-needed code had bit-rotted;  Shared libs now need a strong
   reference to be counted as needed.
3) --gc-sections involving dot-symbols was broken, needing
   func_desc_adjust to be run early and lots of other fixes.

bfd/
* elf64-ppc.c (struct ppc_link_hash_entry): Delete "was_undefined".
(struct ppc_link_hash_table): Delete "twiddled_syms".  Add
"need_func_desc_adj".
(lookup_fdh): Link direct fdh sym via oh field and set flags.
(make_fdh): Make strong and weak undefined function descriptor
symbols.
(ppc64_elf_merge_symbol): New function.
(elf_backend_merge_symbol): Define.
(ppc64_elf_archive_symbol_lookup): Don't test undefweak for fake
function descriptors.
(add_symbol_adjust): Don't twiddle symbols to undefweak.
Propagate more ref flags to function descriptor symbol.  Make
some function descriptor symbols dynamic.
(ppc64_elf_before_check_relocs): Only run add_symbol_adjust for
ELFv1.  Set need_func_desc_adj.  Don't fix undefs list.
(ppc64_elf_check_relocs): Set non_ir_ref for descriptors.
Don't call lookup_fdh here.
(ppc64_elf_gc_sections): New function.
(bfd_elf64_bfd_gc_sections): Define.
(ppc64_elf_gc_mark_hook): Mark descriptor.
(func_desc_adjust): Don't make fake function descriptor syms strong
here.  Exit earlier on non-dotsyms.  Take note of elf.dynamic
flag when deciding whether a dynamic function descriptor might
be needed.  Transfer elf.dynamic and set elf.needs_plt.  Move
plt regardless of visibility.  Make descriptor dynamic if
entry sym is dynamic, not for other cases.
(ppc64_elf_func_desc_adjust): Don't run func_desc_adjust if
already done.
(ppc64_elf_edit_opd): Use oh field rather than lookup_fdh.
(ppc64_elf_size_stubs): Likewise.
(ppc_build_one_stub): Don't clear was_undefined.  Only set sym
undefweak if stub symbol is defined.
(undo_symbol_twiddle, ppc64_elf_restore_symbols): Delete.
* elf64-ppc.h (ppc64_elf_restore_symbols): Don't declare.
ld/
* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Don't call
ppc64_elf_restore_symbols.
* testsuite/ld-powerpc/dotsym1.d: New.
* testsuite/ld-powerpc/dotsym2.d: New.
* testsuite/ld-powerpc/dotsym3.d: New.
* testsuite/ld-powerpc/dotsym4.d: New.
* testsuite/ld-powerpc/dotsymref.s: New.
* testsuite/ld-powerpc/nodotsym.s: New.
* testsuite/ld-powerpc/powerpc.exp: Run new tests.
12 files changed:
bfd/ChangeLog
bfd/elf64-ppc.c
bfd/elf64-ppc.h
ld/ChangeLog
ld/emultempl/ppc64elf.em
ld/testsuite/ld-powerpc/dotsym1.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/dotsym2.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/dotsym3.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/dotsym4.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/dotsymref.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/nodotsym.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/powerpc.exp