caa65211bb
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.
56 lines
2.4 KiB
Makefile
56 lines
2.4 KiB
Makefile
#source: load1.s
|
|
#as: --x32
|
|
#ld: -melf32_x86_64
|
|
#objdump: -dw --sym
|
|
#notarget: x86_64-*-nacl*
|
|
|
|
.*: +file format .*
|
|
|
|
SYMBOL TABLE:
|
|
#...
|
|
0+60017c l O .data 0+1 bar
|
|
#...
|
|
0+60017d g O .data 0+1 foo
|
|
#...
|
|
|
|
|
|
Disassembly of section .text:
|
|
|
|
0+400074 <_start>:
|
|
[ ]*[a-f0-9]+: 81 d0 7c 01 60 00 adc \$0x60017c,%eax
|
|
[ ]*[a-f0-9]+: 81 c3 7c 01 60 00 add \$0x60017c,%ebx
|
|
[ ]*[a-f0-9]+: 81 e1 7c 01 60 00 and \$0x60017c,%ecx
|
|
[ ]*[a-f0-9]+: 81 fa 7c 01 60 00 cmp \$0x60017c,%edx
|
|
[ ]*[a-f0-9]+: 81 ce 7c 01 60 00 or \$0x60017c,%esi
|
|
[ ]*[a-f0-9]+: 81 df 7c 01 60 00 sbb \$0x60017c,%edi
|
|
[ ]*[a-f0-9]+: 81 ed 7c 01 60 00 sub \$0x60017c,%ebp
|
|
[ ]*[a-f0-9]+: 41 81 f0 7c 01 60 00 xor \$0x60017c,%r8d
|
|
[ ]*[a-f0-9]+: 41 f7 c7 7c 01 60 00 test \$0x60017c,%r15d
|
|
[ ]*[a-f0-9]+: 48 81 d0 7c 01 60 00 adc \$0x60017c,%rax
|
|
[ ]*[a-f0-9]+: 48 81 c3 7c 01 60 00 add \$0x60017c,%rbx
|
|
[ ]*[a-f0-9]+: 48 81 e1 7c 01 60 00 and \$0x60017c,%rcx
|
|
[ ]*[a-f0-9]+: 48 81 fa 7c 01 60 00 cmp \$0x60017c,%rdx
|
|
[ ]*[a-f0-9]+: 48 81 cf 7c 01 60 00 or \$0x60017c,%rdi
|
|
[ ]*[a-f0-9]+: 48 81 de 7c 01 60 00 sbb \$0x60017c,%rsi
|
|
[ ]*[a-f0-9]+: 48 81 ed 7c 01 60 00 sub \$0x60017c,%rbp
|
|
[ ]*[a-f0-9]+: 49 81 f0 7c 01 60 00 xor \$0x60017c,%r8
|
|
[ ]*[a-f0-9]+: 49 f7 c7 7c 01 60 00 test \$0x60017c,%r15
|
|
[ ]*[a-f0-9]+: 81 d0 7d 01 60 00 adc \$0x60017d,%eax
|
|
[ ]*[a-f0-9]+: 81 c3 7d 01 60 00 add \$0x60017d,%ebx
|
|
[ ]*[a-f0-9]+: 81 e1 7d 01 60 00 and \$0x60017d,%ecx
|
|
[ ]*[a-f0-9]+: 81 fa 7d 01 60 00 cmp \$0x60017d,%edx
|
|
[ ]*[a-f0-9]+: 81 ce 7d 01 60 00 or \$0x60017d,%esi
|
|
[ ]*[a-f0-9]+: 81 df 7d 01 60 00 sbb \$0x60017d,%edi
|
|
[ ]*[a-f0-9]+: 81 ed 7d 01 60 00 sub \$0x60017d,%ebp
|
|
[ ]*[a-f0-9]+: 41 81 f0 7d 01 60 00 xor \$0x60017d,%r8d
|
|
[ ]*[a-f0-9]+: 41 f7 c7 7d 01 60 00 test \$0x60017d,%r15d
|
|
[ ]*[a-f0-9]+: 48 81 d0 7d 01 60 00 adc \$0x60017d,%rax
|
|
[ ]*[a-f0-9]+: 48 81 c3 7d 01 60 00 add \$0x60017d,%rbx
|
|
[ ]*[a-f0-9]+: 48 81 e1 7d 01 60 00 and \$0x60017d,%rcx
|
|
[ ]*[a-f0-9]+: 48 81 fa 7d 01 60 00 cmp \$0x60017d,%rdx
|
|
[ ]*[a-f0-9]+: 48 81 cf 7d 01 60 00 or \$0x60017d,%rdi
|
|
[ ]*[a-f0-9]+: 48 81 de 7d 01 60 00 sbb \$0x60017d,%rsi
|
|
[ ]*[a-f0-9]+: 48 81 ed 7d 01 60 00 sub \$0x60017d,%rbp
|
|
[ ]*[a-f0-9]+: 49 81 f0 7d 01 60 00 xor \$0x60017d,%r8
|
|
[ ]*[a-f0-9]+: 49 f7 c7 7d 01 60 00 test \$0x60017d,%r15
|
|
#pass
|