binutils-gdb/ld/testsuite/ld-i386/load1-nacl.d
H.J. Lu cd04836359 x86: Remove the unused _GLOBAL_OFFSET_TABLE_
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.
2018-02-05 08:38:16 -08:00

60 lines
2.7 KiB
Makefile

#source: load1.s
#as: --32
#ld: -melf_i386
#objdump: -dw --sym
#target: i?86-*-nacl* x86_64-*-nacl*
.*: +file format .*
SYMBOL TABLE:
#...
10030074 l O .data 0+1 bar
#...
10030075 g O .data 0+1 foo
#...
Disassembly of section .text:
0+20000 <_start>:
[ ]*[a-f0-9]+: c7 c0 74 00 03 10 mov \$0x10030074,%eax
[ ]*[a-f0-9]+: 81 d0 74 00 03 10 adc \$0x10030074,%eax
[ ]*[a-f0-9]+: 81 c3 74 00 03 10 add \$0x10030074,%ebx
[ ]*[a-f0-9]+: 81 e1 74 00 03 10 and \$0x10030074,%ecx
[ ]*[a-f0-9]+: 81 fa 74 00 03 10 cmp \$0x10030074,%edx
[ ]*[a-f0-9]+: 81 cf 74 00 03 10 or \$0x10030074,%edi
[ ]*[a-f0-9]+: 81 de 74 00 03 10 sbb \$0x10030074,%esi
[ ]*[a-f0-9]+: 81 ed 74 00 03 10 sub \$0x10030074,%ebp
[ ]*[a-f0-9]+: 81 f4 74 00 03 10 xor \$0x10030074,%esp
[ ]*[a-f0-9]+: f7 c1 74 00 03 10 test \$0x10030074,%ecx
[ ]*[a-f0-9]+: c7 c0 74 00 03 10 mov \$0x10030074,%eax
[ ]*[a-f0-9]+: 81 d0 74 00 03 10 adc \$0x10030074,%eax
[ ]*[a-f0-9]+: 81 c3 74 00 03 10 add \$0x10030074,%ebx
[ ]*[a-f0-9]+: 81 e1 74 00 03 10 and \$0x10030074,%ecx
[ ]*[a-f0-9]+: 81 fa 74 00 03 10 cmp \$0x10030074,%edx
[ ]*[a-f0-9]+: 81 cf 74 00 03 10 or \$0x10030074,%edi
[ ]*[a-f0-9]+: 81 de 74 00 03 10 sbb \$0x10030074,%esi
[ ]*[a-f0-9]+: 81 ed 74 00 03 10 sub \$0x10030074,%ebp
[ ]*[a-f0-9]+: 81 f4 74 00 03 10 xor \$0x10030074,%esp
[ ]*[a-f0-9]+: f7 c1 74 00 03 10 test \$0x10030074,%ecx
[ ]*[a-f0-9]+: c7 c0 75 00 03 10 mov \$0x10030075,%eax
[ ]*[a-f0-9]+: 81 d0 75 00 03 10 adc \$0x10030075,%eax
[ ]*[a-f0-9]+: 81 c3 75 00 03 10 add \$0x10030075,%ebx
[ ]*[a-f0-9]+: 81 e1 75 00 03 10 and \$0x10030075,%ecx
[ ]*[a-f0-9]+: 81 fa 75 00 03 10 cmp \$0x10030075,%edx
[ ]*[a-f0-9]+: 81 cf 75 00 03 10 or \$0x10030075,%edi
[ ]*[a-f0-9]+: 81 de 75 00 03 10 sbb \$0x10030075,%esi
[ ]*[a-f0-9]+: 81 ed 75 00 03 10 sub \$0x10030075,%ebp
[ ]*[a-f0-9]+: 81 f4 75 00 03 10 xor \$0x10030075,%esp
[ ]*[a-f0-9]+: f7 c1 75 00 03 10 test \$0x10030075,%ecx
[ ]*[a-f0-9]+: c7 c0 75 00 03 10 mov \$0x10030075,%eax
[ ]*[a-f0-9]+: 81 d0 75 00 03 10 adc \$0x10030075,%eax
[ ]*[a-f0-9]+: 81 c3 75 00 03 10 add \$0x10030075,%ebx
[ ]*[a-f0-9]+: 81 e1 75 00 03 10 and \$0x10030075,%ecx
[ ]*[a-f0-9]+: 81 fa 75 00 03 10 cmp \$0x10030075,%edx
[ ]*[a-f0-9]+: 81 cf 75 00 03 10 or \$0x10030075,%edi
[ ]*[a-f0-9]+: 81 de 75 00 03 10 sbb \$0x10030075,%esi
[ ]*[a-f0-9]+: 81 ed 75 00 03 10 sub \$0x10030075,%ebp
[ ]*[a-f0-9]+: 81 f4 75 00 03 10 xor \$0x10030075,%esp
[ ]*[a-f0-9]+: f7 c1 75 00 03 10 test \$0x10030075,%ecx
#pass