Handle weak alias for PIE with copy reloc
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 14 Dec 2014 07:37:22 +0000 (23:37 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 14 Dec 2014 07:44:39 +0000 (23:44 -0800)
commit3e5d8b05745a9fa1d9ad120459143e6e36cfbde0
tree6c270d1f1a21daaff04f1d3a7d2bba0db7ddb01f
parent27cef631a78b56f8ad030ba6231432e04cc1838e
Handle weak alias for PIE with copy reloc

When there is a weak symbol with a real definition, the processor
independent code will have arranged for us to see the real definition
first.  We need to copy the needs_copy bit from the real definition and
check it when allowing copy reloc in PIE.

bfd/

PR ld/17689
* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add needs_copy.
Change has_bnd_reloc to bit field.
(elf_x86_64_link_hash_newfunc): Initialize needs_copy and
has_bnd_reloc to 0.
(elf_x86_64_check_relocs): Set has_bnd_reloc to 1 instead
of TRUE.
(elf_x86_64_adjust_dynamic_symbol): Copy needs_copy from the
real definition to a weak symbol.
(elf_x86_64_allocate_dynrelocs): Also check needs_copy of a
weak symbol for PIE when discarding space for relocs against
symbols which turn out to need copy relocs.
(elf_x86_64_relocate_section): Also check needs_copy of a
weak symbol for PIE with copy reloc.

ld/testsuite/

PR ld/17689
* ld-x86-64/pr17689.out: New file.
* ld-x86-64/pr17689.rd: Likewise.
* ld-x86-64/pr17689a.c: Likewise.
* ld-x86-64/pr17689b.S: Likewise.

* ld-x86-64/x86-64.exp: Run PR ld/17689 tests.
bfd/ChangeLog
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-x86-64/pr17689.out [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr17689.rd [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr17689a.c [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr17689b.S [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp