aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-i386
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-10-22 04:53:04 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-10-22 04:56:39 -0700
commitcaa65211bbbfd53c40c9ce1b79b97ccf2c679a52 (patch)
treefb1a002a3550e25bdfa5c224a52d4a5fd7fab63b /ld/testsuite/ld-i386
parent56ceb5b5405af23eddd12e12d8ba849010120324 (diff)
downloadgdb-caa65211bbbfd53c40c9ce1b79b97ccf2c679a52.zip
gdb-caa65211bbbfd53c40c9ce1b79b97ccf2c679a52.tar.gz
gdb-caa65211bbbfd53c40c9ce1b79b97ccf2c679a52.tar.bz2
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.
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r--ld/testsuite/ld-i386/call3.s9
-rw-r--r--ld/testsuite/ld-i386/call3a.d13
-rw-r--r--ld/testsuite/ld-i386/call3b.d13
-rw-r--r--ld/testsuite/ld-i386/call3c.d14
-rw-r--r--ld/testsuite/ld-i386/call3d.d14
-rw-r--r--ld/testsuite/ld-i386/call3e.d13
-rw-r--r--ld/testsuite/ld-i386/call3f.d14
-rw-r--r--ld/testsuite/ld-i386/call3g.d14
-rw-r--r--ld/testsuite/ld-i386/call3h.d14
-rw-r--r--ld/testsuite/ld-i386/i386.exp9
-rw-r--r--ld/testsuite/ld-i386/load1-nacl.d59
-rw-r--r--ld/testsuite/ld-i386/load1.d1
12 files changed, 187 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/call3.s b/ld/testsuite/ld-i386/call3.s
new file mode 100644
index 0000000..ce003c8
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3.s
@@ -0,0 +1,9 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .globl _start
+ .type _start, @function
+_start:
+ call *foo@GOT
diff --git a/ld/testsuite/ld-i386/call3a.d b/ld/testsuite/ld-i386/call3a.d
new file mode 100644
index 0000000..a8ff27f
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3a.d
@@ -0,0 +1,13 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4} * addr16 call +[a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-i386/call3b.d b/ld/testsuite/ld-i386/call3b.d
new file mode 100644
index 0000000..06af6f5
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3b.d
@@ -0,0 +1,13 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=prefix-addr
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4} * addr16 call +[a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-i386/call3c.d b/ld/testsuite/ld-i386/call3c.d
new file mode 100644
index 0000000..64e8372
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3c.d
@@ -0,0 +1,14 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=prefix-nop
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 90 nop
+[ ]*[a-f0-9]+: e8 ([0-9a-f]{2} ){4} * call +[a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-i386/call3d.d b/ld/testsuite/ld-i386/call3d.d
new file mode 100644
index 0000000..a9274c8
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3d.d
@@ -0,0 +1,14 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=suffix-nop
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: e8 ([0-9a-f]{2} ){4} * call +[a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 90 nop
+#pass
diff --git a/ld/testsuite/ld-i386/call3e.d b/ld/testsuite/ld-i386/call3e.d
new file mode 100644
index 0000000..2876b49
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3e.d
@@ -0,0 +1,13 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=prefix-0x67
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4} * addr16 call +[a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-i386/call3f.d b/ld/testsuite/ld-i386/call3f.d
new file mode 100644
index 0000000..5ab0cf1
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3f.d
@@ -0,0 +1,14 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=prefix-0x90
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 90 nop
+[ ]*[a-f0-9]+: e8 ([0-9a-f]{2} ){4} * call +[a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-i386/call3g.d b/ld/testsuite/ld-i386/call3g.d
new file mode 100644
index 0000000..8287770
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3g.d
@@ -0,0 +1,14 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=suffix-0x90
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: e8 ([0-9a-f]{2} ){4} * call +[a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 90 nop
+#pass
diff --git a/ld/testsuite/ld-i386/call3h.d b/ld/testsuite/ld-i386/call3h.d
new file mode 100644
index 0000000..83f371a
--- /dev/null
+++ b/ld/testsuite/ld-i386/call3h.d
@@ -0,0 +1,14 @@
+#source: call3.s
+#as: --32
+#ld: -melf_i386 -z call-nop=suffix-144
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: e8 ([0-9a-f]{2} ){4} * call +[a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 90 nop
+#pass
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 3d28dcc..9bf08da 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -296,9 +296,18 @@ run_dump_test "mov1b"
run_dump_test "branch1"
run_dump_test "call1"
run_dump_test "call2"
+run_dump_test "call3a"
+run_dump_test "call3b"
+run_dump_test "call3c"
+run_dump_test "call3d"
+run_dump_test "call3e"
+run_dump_test "call3f"
+run_dump_test "call3g"
+run_dump_test "call3h"
run_dump_test "jmp1"
run_dump_test "jmp2"
run_dump_test "load1"
+run_dump_test "load1-nacl"
run_dump_test "load2"
run_dump_test "load3"
run_dump_test "load4a"
diff --git a/ld/testsuite/ld-i386/load1-nacl.d b/ld/testsuite/ld-i386/load1-nacl.d
new file mode 100644
index 0000000..1245639
--- /dev/null
+++ b/ld/testsuite/ld-i386/load1-nacl.d
@@ -0,0 +1,59 @@
+#source: load1.s
+#as: --32
+#ld: -melf_i386
+#objdump: -dw --sym
+#target: i?86-*-nacl* x86_64-*-nacl*
+
+.*: +file format .*
+
+SYMBOL TABLE:
+#...
+10030080 l O .data 0+1 bar
+#...
+10030081 g O .data 0+1 foo
+#...
+
+Disassembly of section .text:
+
+0+20000 <_start>:
+[ ]*[a-f0-9]+: 8d 05 80 00 03 10 lea 0x10030080,%eax
+[ ]*[a-f0-9]+: 81 d0 80 00 03 10 adc \$0x10030080,%eax
+[ ]*[a-f0-9]+: 81 c3 80 00 03 10 add \$0x10030080,%ebx
+[ ]*[a-f0-9]+: 81 e1 80 00 03 10 and \$0x10030080,%ecx
+[ ]*[a-f0-9]+: 81 fa 80 00 03 10 cmp \$0x10030080,%edx
+[ ]*[a-f0-9]+: 81 cf 80 00 03 10 or \$0x10030080,%edi
+[ ]*[a-f0-9]+: 81 de 80 00 03 10 sbb \$0x10030080,%esi
+[ ]*[a-f0-9]+: 81 ed 80 00 03 10 sub \$0x10030080,%ebp
+[ ]*[a-f0-9]+: 81 f4 80 00 03 10 xor \$0x10030080,%esp
+[ ]*[a-f0-9]+: f7 c1 80 00 03 10 test \$0x10030080,%ecx
+[ ]*[a-f0-9]+: 8d 05 80 00 03 10 lea 0x10030080,%eax
+[ ]*[a-f0-9]+: 81 d0 80 00 03 10 adc \$0x10030080,%eax
+[ ]*[a-f0-9]+: 81 c3 80 00 03 10 add \$0x10030080,%ebx
+[ ]*[a-f0-9]+: 81 e1 80 00 03 10 and \$0x10030080,%ecx
+[ ]*[a-f0-9]+: 81 fa 80 00 03 10 cmp \$0x10030080,%edx
+[ ]*[a-f0-9]+: 81 cf 80 00 03 10 or \$0x10030080,%edi
+[ ]*[a-f0-9]+: 81 de 80 00 03 10 sbb \$0x10030080,%esi
+[ ]*[a-f0-9]+: 81 ed 80 00 03 10 sub \$0x10030080,%ebp
+[ ]*[a-f0-9]+: 81 f4 80 00 03 10 xor \$0x10030080,%esp
+[ ]*[a-f0-9]+: f7 c1 80 00 03 10 test \$0x10030080,%ecx
+[ ]*[a-f0-9]+: 8d 05 81 00 03 10 lea 0x10030081,%eax
+[ ]*[a-f0-9]+: 81 d0 81 00 03 10 adc \$0x10030081,%eax
+[ ]*[a-f0-9]+: 81 c3 81 00 03 10 add \$0x10030081,%ebx
+[ ]*[a-f0-9]+: 81 e1 81 00 03 10 and \$0x10030081,%ecx
+[ ]*[a-f0-9]+: 81 fa 81 00 03 10 cmp \$0x10030081,%edx
+[ ]*[a-f0-9]+: 81 cf 81 00 03 10 or \$0x10030081,%edi
+[ ]*[a-f0-9]+: 81 de 81 00 03 10 sbb \$0x10030081,%esi
+[ ]*[a-f0-9]+: 81 ed 81 00 03 10 sub \$0x10030081,%ebp
+[ ]*[a-f0-9]+: 81 f4 81 00 03 10 xor \$0x10030081,%esp
+[ ]*[a-f0-9]+: f7 c1 81 00 03 10 test \$0x10030081,%ecx
+[ ]*[a-f0-9]+: 8d 05 81 00 03 10 lea 0x10030081,%eax
+[ ]*[a-f0-9]+: 81 d0 81 00 03 10 adc \$0x10030081,%eax
+[ ]*[a-f0-9]+: 81 c3 81 00 03 10 add \$0x10030081,%ebx
+[ ]*[a-f0-9]+: 81 e1 81 00 03 10 and \$0x10030081,%ecx
+[ ]*[a-f0-9]+: 81 fa 81 00 03 10 cmp \$0x10030081,%edx
+[ ]*[a-f0-9]+: 81 cf 81 00 03 10 or \$0x10030081,%edi
+[ ]*[a-f0-9]+: 81 de 81 00 03 10 sbb \$0x10030081,%esi
+[ ]*[a-f0-9]+: 81 ed 81 00 03 10 sub \$0x10030081,%ebp
+[ ]*[a-f0-9]+: 81 f4 81 00 03 10 xor \$0x10030081,%esp
+[ ]*[a-f0-9]+: f7 c1 81 00 03 10 test \$0x10030081,%ecx
+#pass
diff --git a/ld/testsuite/ld-i386/load1.d b/ld/testsuite/ld-i386/load1.d
index e93531e..062ea18 100644
--- a/ld/testsuite/ld-i386/load1.d
+++ b/ld/testsuite/ld-i386/load1.d
@@ -1,6 +1,7 @@
#as: --32
#ld: -melf_i386
#objdump: -dw --sym
+#notarget: i?86-*-nacl* x86_64-*-nacl*
.*: +file format .*