cd04836359
Since _GLOBAL_OFFSET_TABLE_ may be referenced implicitly on x86, checking ref_regular_nonweak leaves the unused _GLOBAL_OFFSET_TABLE_ in output. This patch checks explicit GOT references instead. ld-i386/discarded1.s and ld-x86-64/discarded1.s are updated to avoid linker optimization which removes GOT references. bfd/ PR ld/22782 * elf32-i386.c (elf_i386_check_relocs): Set got_referenced if _GLOBAL_OFFSET_TABLE_ is referenced or GOT is needed to resolve undefined weak symbol to 0. * elf64-x86-64.c (elf_x86_64_check_relocs): Set got_referenced if _GLOBAL_OFFSET_TABLE_ is referenced. * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Check got_referenced instead of ref_regular_nonweak. Remove the unused _GLOBAL_OFFSET_TABLE_ from symbol table. * elfxx-x86.h (elf_x86_link_hash_table): Add got_referenced. ld/ PR ld/22782 * testsuite/ld-i386/discarded1.s: Replace mov with div. * testsuite/ld-x86-64/discarded1.s: Likewise. * testsuite/ld-i386/i386.exp: Run pr22782. * testsuite/ld-i386/load1-nacl.d: Updated for removing _GLOBAL_OFFSET_TABLE_ from output. * testsuite/ld-i386/load1.d: Likewise. * testsuite/ld-x86-64/load1a-nacl.d: Likewise. * testsuite/ld-x86-64/load1a.d: Likewise. * testsuite/ld-x86-64/load1b-nacl.d: Likewise. * testsuite/ld-x86-64/load1b.d: Likewise. * testsuite/ld-i386/pr22782.d: New file. * testsuite/ld-i386/pr22782.s: Likewise. * testsuite/ld-x86-64/pr22782.s: Likewise. * testsuite/ld-x86-64/pr22782a.d: Likewise. * testsuite/ld-x86-64/pr22782b.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr22782a and pr22782b.
56 lines
2.5 KiB
Makefile
56 lines
2.5 KiB
Makefile
#source: load1.s
|
|
#as: --64
|
|
#ld: -melf_x86_64
|
|
#objdump: -dw --sym
|
|
#target: x86_64-*-nacl*
|
|
|
|
.*: +file format .*
|
|
|
|
SYMBOL TABLE:
|
|
#...
|
|
0+100300b0 l O .data 0+1 bar
|
|
#...
|
|
0+100300b1 g O .data 0+1 foo
|
|
#...
|
|
|
|
Disassembly of section .text:
|
|
|
|
0+20000 <_start>:
|
|
[ ]*[a-f0-9]+: 81 d0 b0 00 03 10 adc \$0x100300b0,%eax
|
|
[ ]*[a-f0-9]+: 81 c3 b0 00 03 10 add \$0x100300b0,%ebx
|
|
[ ]*[a-f0-9]+: 81 e1 b0 00 03 10 and \$0x100300b0,%ecx
|
|
[ ]*[a-f0-9]+: 81 fa b0 00 03 10 cmp \$0x100300b0,%edx
|
|
[ ]*[a-f0-9]+: 81 ce b0 00 03 10 or \$0x100300b0,%esi
|
|
[ ]*[a-f0-9]+: 81 df b0 00 03 10 sbb \$0x100300b0,%edi
|
|
[ ]*[a-f0-9]+: 81 ed b0 00 03 10 sub \$0x100300b0,%ebp
|
|
[ ]*[a-f0-9]+: 41 81 f0 b0 00 03 10 xor \$0x100300b0,%r8d
|
|
[ ]*[a-f0-9]+: 41 f7 c7 b0 00 03 10 test \$0x100300b0,%r15d
|
|
[ ]*[a-f0-9]+: 48 81 d0 b0 00 03 10 adc \$0x100300b0,%rax
|
|
[ ]*[a-f0-9]+: 48 81 c3 b0 00 03 10 add \$0x100300b0,%rbx
|
|
[ ]*[a-f0-9]+: 48 81 e1 b0 00 03 10 and \$0x100300b0,%rcx
|
|
[ ]*[a-f0-9]+: 48 81 fa b0 00 03 10 cmp \$0x100300b0,%rdx
|
|
[ ]*[a-f0-9]+: 48 81 cf b0 00 03 10 or \$0x100300b0,%rdi
|
|
[ ]*[a-f0-9]+: 48 81 de b0 00 03 10 sbb \$0x100300b0,%rsi
|
|
[ ]*[a-f0-9]+: 48 81 ed b0 00 03 10 sub \$0x100300b0,%rbp
|
|
[ ]*[a-f0-9]+: 49 81 f0 b0 00 03 10 xor \$0x100300b0,%r8
|
|
[ ]*[a-f0-9]+: 49 f7 c7 b0 00 03 10 test \$0x100300b0,%r15
|
|
[ ]*[a-f0-9]+: 81 d0 b1 00 03 10 adc \$0x100300b1,%eax
|
|
[ ]*[a-f0-9]+: 81 c3 b1 00 03 10 add \$0x100300b1,%ebx
|
|
[ ]*[a-f0-9]+: 81 e1 b1 00 03 10 and \$0x100300b1,%ecx
|
|
[ ]*[a-f0-9]+: 81 fa b1 00 03 10 cmp \$0x100300b1,%edx
|
|
[ ]*[a-f0-9]+: 81 ce b1 00 03 10 or \$0x100300b1,%esi
|
|
[ ]*[a-f0-9]+: 81 df b1 00 03 10 sbb \$0x100300b1,%edi
|
|
[ ]*[a-f0-9]+: 81 ed b1 00 03 10 sub \$0x100300b1,%ebp
|
|
[ ]*[a-f0-9]+: 41 81 f0 b1 00 03 10 xor \$0x100300b1,%r8d
|
|
[ ]*[a-f0-9]+: 41 f7 c7 b1 00 03 10 test \$0x100300b1,%r15d
|
|
[ ]*[a-f0-9]+: 48 81 d0 b1 00 03 10 adc \$0x100300b1,%rax
|
|
[ ]*[a-f0-9]+: 48 81 c3 b1 00 03 10 add \$0x100300b1,%rbx
|
|
[ ]*[a-f0-9]+: 48 81 e1 b1 00 03 10 and \$0x100300b1,%rcx
|
|
[ ]*[a-f0-9]+: 48 81 fa b1 00 03 10 cmp \$0x100300b1,%rdx
|
|
[ ]*[a-f0-9]+: 48 81 cf b1 00 03 10 or \$0x100300b1,%rdi
|
|
[ ]*[a-f0-9]+: 48 81 de b1 00 03 10 sbb \$0x100300b1,%rsi
|
|
[ ]*[a-f0-9]+: 48 81 ed b1 00 03 10 sub \$0x100300b1,%rbp
|
|
[ ]*[a-f0-9]+: 49 81 f0 b1 00 03 10 xor \$0x100300b1,%r8
|
|
[ ]*[a-f0-9]+: 49 f7 c7 b1 00 03 10 test \$0x100300b1,%r15
|
|
#pass
|