binutils-gdb/ld/testsuite/ld-i386/load1.d
H.J. Lu caa65211bb Add "-z call-nop=PADDING" option to ld
The ld linker can transform indirect call to a locally defined function,
foo, via its GOT slot, to either "NOP call foo" or "call foo NOP" where
NOP is a 1-byte NOP padding.  This patch adds a "-z call-nop=PADDING"
option to x86 ld to control 1-byte NOP padding for x86 call instruction.
PADDING is one of prefix-addr, prefix-nop, suffix-nop, prefix-NUMBER or
suffix-NUMBER.

bfd/

	* elf32-i386.c (elf_i386_convert_load): Use call_nop_byte and
	check call_nop_as_suffix for 1-byte NOP padding to pad call.
	* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.

include/

	* bfdlink.h (bfd_link_info): Add call_nop_as_suffix and
	call_nop_byte.

ld/

	* ld/ld.texinfo: Document "-z call-nop=PADDING" option.
	* emulparams/call_nop.sh: New file.
	* emulparams/elf_i386_be.sh: Source
	${srcdir}/emulparams/call_nop.sh.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_i386_vxworks.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
	link_info.call_nop_byte if $CALL_NOP_BYTE isn't empty.

ld/testsuite/

	* ld-i386/call3.s: New file.
	* ld-i386/call3a.d: Likewise.
	* ld-i386/call3b.d: Likewise.
	* ld-i386/call3c.d: Likewise.
	* ld-i386/call3d.d: Likewise.
	* ld-i386/call3e.d: Likewise.
	* ld-i386/call3f.d: Likewise.
	* ld-i386/call3g.d: Likewise.
	* ld-i386/call3h.d: Likewise.
	* ld-i386/load1-nacl.d: Likewise.
	* ld-x86-64/call1.s: Likewise.
	* ld-x86-64/call1a.d: Likewise.
	* ld-x86-64/call1b.d: Likewise.
	* ld-x86-64/call1c.d: Likewise.
	* ld-x86-64/call1d.d: Likewise.
	* ld-x86-64/call1e.d: Likewise.
	* ld-x86-64/call1f.d: Likewise.
	* ld-x86-64/call1g.d: Likewise.
	* ld-x86-64/call1h.d: Likewise.
	* ld-x86-64/call1i.d: Likewise.
	* ld-x86-64/load1a-nacl.d: Likewise.
	* ld-x86-64/load1b-nacl.d: Likewise.
	* ld-x86-64/load1c-nacl.d: Likewise.
	* ld-x86-64/load1d-nacl.d: Likewise.
2015-10-22 04:56:39 -07:00

59 lines
2.7 KiB
Makefile

#as: --32
#ld: -melf_i386
#objdump: -dw --sym
#notarget: i?86-*-nacl* x86_64-*-nacl*
.*: +file format .*
SYMBOL TABLE:
#...
0+8049170 l O .data 0+1 bar
#...
0+8049171 g O .data 0+1 foo
#...
Disassembly of section .text:
0+8048074 <_start>:
[ ]*[a-f0-9]+: 8d 05 70 91 04 08 lea 0x8049170,%eax
[ ]*[a-f0-9]+: 81 d0 70 91 04 08 adc \$0x8049170,%eax
[ ]*[a-f0-9]+: 81 c3 70 91 04 08 add \$0x8049170,%ebx
[ ]*[a-f0-9]+: 81 e1 70 91 04 08 and \$0x8049170,%ecx
[ ]*[a-f0-9]+: 81 fa 70 91 04 08 cmp \$0x8049170,%edx
[ ]*[a-f0-9]+: 81 cf 70 91 04 08 or \$0x8049170,%edi
[ ]*[a-f0-9]+: 81 de 70 91 04 08 sbb \$0x8049170,%esi
[ ]*[a-f0-9]+: 81 ed 70 91 04 08 sub \$0x8049170,%ebp
[ ]*[a-f0-9]+: 81 f4 70 91 04 08 xor \$0x8049170,%esp
[ ]*[a-f0-9]+: f7 c1 70 91 04 08 test \$0x8049170,%ecx
[ ]*[a-f0-9]+: 8d 05 70 91 04 08 lea 0x8049170,%eax
[ ]*[a-f0-9]+: 81 d0 70 91 04 08 adc \$0x8049170,%eax
[ ]*[a-f0-9]+: 81 c3 70 91 04 08 add \$0x8049170,%ebx
[ ]*[a-f0-9]+: 81 e1 70 91 04 08 and \$0x8049170,%ecx
[ ]*[a-f0-9]+: 81 fa 70 91 04 08 cmp \$0x8049170,%edx
[ ]*[a-f0-9]+: 81 cf 70 91 04 08 or \$0x8049170,%edi
[ ]*[a-f0-9]+: 81 de 70 91 04 08 sbb \$0x8049170,%esi
[ ]*[a-f0-9]+: 81 ed 70 91 04 08 sub \$0x8049170,%ebp
[ ]*[a-f0-9]+: 81 f4 70 91 04 08 xor \$0x8049170,%esp
[ ]*[a-f0-9]+: f7 c1 70 91 04 08 test \$0x8049170,%ecx
[ ]*[a-f0-9]+: 8d 05 71 91 04 08 lea 0x8049171,%eax
[ ]*[a-f0-9]+: 81 d0 71 91 04 08 adc \$0x8049171,%eax
[ ]*[a-f0-9]+: 81 c3 71 91 04 08 add \$0x8049171,%ebx
[ ]*[a-f0-9]+: 81 e1 71 91 04 08 and \$0x8049171,%ecx
[ ]*[a-f0-9]+: 81 fa 71 91 04 08 cmp \$0x8049171,%edx
[ ]*[a-f0-9]+: 81 cf 71 91 04 08 or \$0x8049171,%edi
[ ]*[a-f0-9]+: 81 de 71 91 04 08 sbb \$0x8049171,%esi
[ ]*[a-f0-9]+: 81 ed 71 91 04 08 sub \$0x8049171,%ebp
[ ]*[a-f0-9]+: 81 f4 71 91 04 08 xor \$0x8049171,%esp
[ ]*[a-f0-9]+: f7 c1 71 91 04 08 test \$0x8049171,%ecx
[ ]*[a-f0-9]+: 8d 05 71 91 04 08 lea 0x8049171,%eax
[ ]*[a-f0-9]+: 81 d0 71 91 04 08 adc \$0x8049171,%eax
[ ]*[a-f0-9]+: 81 c3 71 91 04 08 add \$0x8049171,%ebx
[ ]*[a-f0-9]+: 81 e1 71 91 04 08 and \$0x8049171,%ecx
[ ]*[a-f0-9]+: 81 fa 71 91 04 08 cmp \$0x8049171,%edx
[ ]*[a-f0-9]+: 81 cf 71 91 04 08 or \$0x8049171,%edi
[ ]*[a-f0-9]+: 81 de 71 91 04 08 sbb \$0x8049171,%esi
[ ]*[a-f0-9]+: 81 ed 71 91 04 08 sub \$0x8049171,%ebp
[ ]*[a-f0-9]+: 81 f4 71 91 04 08 xor \$0x8049171,%esp
[ ]*[a-f0-9]+: f7 c1 71 91 04 08 test \$0x8049171,%ecx
#pass