diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-10-22 04:49:20 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-10-22 04:49:38 -0700 |
commit | 56ceb5b5405af23eddd12e12d8ba849010120324 (patch) | |
tree | 3404c0c3ed3df6a50bcb4bcf979e0bb276d84857 /ld | |
parent | 02a866936de7e63ad4962ccba56c8cd05c231275 (diff) | |
download | fsf-binutils-gdb-56ceb5b5405af23eddd12e12d8ba849010120324.zip fsf-binutils-gdb-56ceb5b5405af23eddd12e12d8ba849010120324.tar.gz fsf-binutils-gdb-56ceb5b5405af23eddd12e12d8ba849010120324.tar.bz2 |
Add R_X86_64_[REX_]GOTPCRELX support to gas and ld
This patch adds support for the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in
https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0
to gas and ld. It updates gas to generate R_X86_64_GOTPCRELX,
R_X86_64_REX_GOTPCRELX if there is a REX prefix, relocation for memory
operand, foo@GOTPCREL(%rip). With the locally defined symbol, foo, we
convert
mov foo@GOTPCREL(%rip), %reg
to
lea foo(%rip), %reg
and convert
call/jmp *foo@GOTPCREL(%rip)
to
nop call foo/jmp foo nop
When PIC is false, convert
test %reg, foo@GOTPCREL(%rip)
to
test $foo, %reg
and convert
binop foo@GOTPCREL(%rip), %reg
to
binop $foo, %reg
where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.
bfd/
* elf64-x86-64.c: Include opcode/i386.h.
(x86_64_elf_howto_table): Add R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.
(R_X86_64_standard): Replace R_X86_64_PLT32_BND with
R_X86_64_REX_GOTPCRELX.
(x86_64_reloc_map): Add BFD_RELOC_X86_64_GOTPCRELX and
BFD_RELOC_X86_64_REX_GOTPCRELX.
(need_convert_mov_to_lea): Renamed to ...
(need_convert_load): This.
(elf_x86_64_check_relocs): Handle R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX. Replace need_convert_mov_to_lea with
need_convert_load.
(elf_x86_64_gc_sweep_hook): Handle R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.
(elf_x86_64_size_dynamic_sections): Likewise.
(elf_x86_64_relocate_section): Likewise.
(elf_x86_64_convert_mov_to_lea): Renamed to ...
(elf_x86_64_convert_load): This. Replace need_convert_mov_to_lea
with need_convert_load. Support R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX transformations.
* reloc.c (BFD_RELOC_X86_64_GOTPCRELX): New.
(BFD_RELOC_X86_64_REX_GOTPCRELX): Likewise.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.
gas/
* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_X86_64_GOTPCRELX and BFD_RELOC_X86_64_REX_GOTPCRELX.
(tc_gen_reloc): Likewise.
(i386_validate_fix): Generate BFD_RELOC_X86_64_GOTPCRELX or
BFD_RELOC_X86_64_REX_GOTPCRELX if fx_tcbit2 is set.
* config/tc-i386.h (TC_FORCE_RELOCATION_LOCAL): Also return
true for BFD_RELOC_X86_64_GOTPCRELX and
BFD_RELOC_X86_64_REX_GOTPCRELX.
gas/testsuite/
* gas/i386/i386.exp: Run x86-64-gotpcrel.
* gas/i386/x86-64-gotpcrel.d: New file.
* gas/i386/x86-64-gotpcrel.s: Likewise.
* gas/i386/ilp32/x86-64-gotpcrel.d: Likewise.
* gas/i386/x86-64-localpic.d: Replace R_X86_64_GOTPCREL with
R_X86_64_REX_GOTPCRELX.
* gas/i386/ilp32/x86-64-localpic.d: Likewise.
include/elf/
* x86-64.h (R_X86_64_GOTPCRELX): New.
(R_X86_64_REX_GOTPCRELX): Likewise.
ld/testsuite/
* ld-ifunc/ifunc-5r-local-x86-64.d: Replace R_X86_64_GOTPCREL
with R_X86_64_REX_GOTPCRELX.
* ld-x86-64/plt-main1.rd: Likewise.
* ld-x86-64/plt-main3.rd: Likewise.
* ld-x86-64/plt-main4.rd: Likewise.
* ld-x86-64/gotpcrel1.dd: New file.
* ld-x86-64/gotpcrel1.out: Likewise.
* ld-x86-64/gotpcrel1a.S: Likewise.
* ld-x86-64/gotpcrel1b.c: Likewise.
* ld-x86-64/gotpcrel1c.c: Likewise.
* ld-x86-64/gotpcrel1d.S: Likewise.
* ld-x86-64/load1.s: Likewise.
* ld-x86-64/load1a.d: Likewise.
* ld-x86-64/load1b.d: Likewise.
* ld-x86-64/load1c.d: Likewise.
* ld-x86-64/load1d.d: Likewise.
* ld-x86-64/x86-64.exp: Run load1a, load1b, load1c and load1d
tests. Run gotpcrel1 test.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ChangeLog | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/gotpcrel1.dd | 17 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/gotpcrel1.out | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/gotpcrel1a.S | 18 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/gotpcrel1b.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/gotpcrel1c.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/gotpcrel1d.S | 26 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/load1.s | 51 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/load1a.d | 54 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/load1b.d | 55 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/load1c.d | 47 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/load1d.d | 47 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main1.rd | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main3.rd | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main4.rd | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 28 |
17 files changed, 390 insertions, 4 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index becfd53..b8d04f5 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,5 +1,26 @@ 2015-10-22 H.J. Lu <hongjiu.lu@intel.com> + * ld-ifunc/ifunc-5r-local-x86-64.d: Replace R_X86_64_GOTPCREL + with R_X86_64_REX_GOTPCRELX. + * ld-x86-64/plt-main1.rd: Likewise. + * ld-x86-64/plt-main3.rd: Likewise. + * ld-x86-64/plt-main4.rd: Likewise. + * ld-x86-64/gotpcrel1.dd: New file. + * ld-x86-64/gotpcrel1.out: Likewise. + * ld-x86-64/gotpcrel1a.S: Likewise. + * ld-x86-64/gotpcrel1b.c: Likewise. + * ld-x86-64/gotpcrel1c.c: Likewise. + * ld-x86-64/gotpcrel1d.S: Likewise. + * ld-x86-64/load1.s: Likewise. + * ld-x86-64/load1a.d: Likewise. + * ld-x86-64/load1b.d: Likewise. + * ld-x86-64/load1c.d: Likewise. + * ld-x86-64/load1d.d: Likewise. + * ld-x86-64/x86-64.exp: Run load1a, load1b, load1c and load1d + tests. Run gotpcrel1 test. + +2015-10-22 H.J. Lu <hongjiu.lu@intel.com> + * ld-i386/branch1.d: New file. * ld-i386/branch1.s: Likewise. * ld-i386/call1.d: Likewise. diff --git a/ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d index e9ad214c..18021e7 100644 --- a/ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d +++ b/ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d @@ -7,4 +7,4 @@ Relocation section '.rela.text' at .* [ ]+Offset[ ]+Info[ ]+Type[ ]+.* [0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+foo\(\)[ ]+foo - 4 -[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_GOTPCREL[ ]+foo\(\)[ ]+foo - 4 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_REX_GOTPCRELX[ ]+foo\(\)[ ]+foo - 4 diff --git a/ld/testsuite/ld-x86-64/gotpcrel1.dd b/ld/testsuite/ld-x86-64/gotpcrel1.dd new file mode 100644 index 0000000..187a1a5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/gotpcrel1.dd @@ -0,0 +1,17 @@ +#... +[a-f0-9]+ <main>: +[ ]*[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +[ ]*[a-f0-9]+: [ a-f0-9]+ addr32 callq [a-f0-9]+ <foo> +[ ]*[a-f0-9]+: [ a-f0-9]+ callq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+> +[ ]*[a-f0-9]+: [ a-f0-9]+ callq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+> +[ ]*[a-f0-9]+: [ a-f0-9]+ lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo> +[ ]*[a-f0-9]+: ff d0 callq \*%rax +[ ]*[a-f0-9]+: [ a-f0-9]+ mov 0x[a-f0-9]+\(%rip\),%rcx # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+> +[ ]*[a-f0-9]+: ff d1 callq \*%rcx +[ ]*[a-f0-9]+: [ a-f0-9]+ mov 0x[a-f0-9]+\(%rip\),%rdx # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+> +[ ]*[a-f0-9]+: ff d2 callq \*%rdx +[ ]*[a-f0-9]+: 31 ff xor %edi,%edi +[ ]*[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +[ ]*[a-f0-9]+: [ a-f0-9]+ jmpq [a-f0-9]+ <myexit> +[ ]*[a-f0-9]+: 90 nop +#pass diff --git a/ld/testsuite/ld-x86-64/gotpcrel1.out b/ld/testsuite/ld-x86-64/gotpcrel1.out new file mode 100644 index 0000000..4d35632 --- /dev/null +++ b/ld/testsuite/ld-x86-64/gotpcrel1.out @@ -0,0 +1,8 @@ +foo +bar +plt +plt +foo +bar +plt +plt diff --git a/ld/testsuite/ld-x86-64/gotpcrel1a.S b/ld/testsuite/ld-x86-64/gotpcrel1a.S new file mode 100644 index 0000000..58dfbb1 --- /dev/null +++ b/ld/testsuite/ld-x86-64/gotpcrel1a.S @@ -0,0 +1,18 @@ + .text + .globl main + .type main, @function +main: + subq $8, %rsp + call *foo@GOTPCREL(%rip) + call *bar@GOTPCREL(%rip) + call *plt@GOTPCREL(%rip) + movq foo@GOTPCREL(%rip), %rax + call *%rax + movq bar@GOTPCREL(%rip), %rcx + call *%rcx + movq plt@GOTPCREL(%rip), %rdx + call *%rdx + xorl %edi, %edi + addq $8, %rsp + jmp *myexit@GOTPCREL(%rip) + .size main, .-main diff --git a/ld/testsuite/ld-x86-64/gotpcrel1b.c b/ld/testsuite/ld-x86-64/gotpcrel1b.c new file mode 100644 index 0000000..cf0c78e --- /dev/null +++ b/ld/testsuite/ld-x86-64/gotpcrel1b.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +foo (void) +{ + printf ("%s\n", __FUNCTION__); +} diff --git a/ld/testsuite/ld-x86-64/gotpcrel1c.c b/ld/testsuite/ld-x86-64/gotpcrel1c.c new file mode 100644 index 0000000..05f5fc2 --- /dev/null +++ b/ld/testsuite/ld-x86-64/gotpcrel1c.c @@ -0,0 +1,7 @@ +#include <stdlib.h> + +void +myexit (int status) +{ + exit (status); +} diff --git a/ld/testsuite/ld-x86-64/gotpcrel1d.S b/ld/testsuite/ld-x86-64/gotpcrel1d.S new file mode 100644 index 0000000..4b01499 --- /dev/null +++ b/ld/testsuite/ld-x86-64/gotpcrel1d.S @@ -0,0 +1,26 @@ + .text + .globl bar + .type bar, @function +bar: + leaq __FUNCTION__.2215(%rip), %rdi + jmp *puts@GOTPCREL(%rip) + .size bar, .-bar + .globl plt + .type plt, @function +plt: + leaq __FUNCTION__.2219(%rip), %rdi + subq $8, %rsp + call *puts@GOTPCREL(%rip) + leaq __FUNCTION__.2219(%rip), %rdi + addq $8, %rsp + jmp *puts@GOTPCREL(%rip) + .size plt, .-plt + .section .rodata + .type __FUNCTION__.2219, @object + .size __FUNCTION__.2219, 4 +__FUNCTION__.2219: + .string "plt" + .type __FUNCTION__.2215, @object + .size __FUNCTION__.2215, 4 +__FUNCTION__.2215: + .string "bar" diff --git a/ld/testsuite/ld-x86-64/load1.s b/ld/testsuite/ld-x86-64/load1.s new file mode 100644 index 0000000..f35b48f --- /dev/null +++ b/ld/testsuite/ld-x86-64/load1.s @@ -0,0 +1,51 @@ + .data + .type bar, @object +bar: + .byte 1 + .size bar, .-bar + .globl foo + .type foo, @object +foo: + .byte 1 + .size foo, .-foo + .text + .globl _start + .type _start, @function +_start: + adcl bar@GOTPCREL(%rip), %eax + addl bar@GOTPCREL(%rip), %ebx + andl bar@GOTPCREL(%rip), %ecx + cmpl bar@GOTPCREL(%rip), %edx + orl bar@GOTPCREL(%rip), %esi + sbbl bar@GOTPCREL(%rip), %edi + subl bar@GOTPCREL(%rip), %ebp + xorl bar@GOTPCREL(%rip), %r8d + testl %r15d, bar@GOTPCREL(%rip) + adcq bar@GOTPCREL(%rip), %rax + addq bar@GOTPCREL(%rip), %rbx + andq bar@GOTPCREL(%rip), %rcx + cmpq bar@GOTPCREL(%rip), %rdx + orq bar@GOTPCREL(%rip), %rdi + sbbq bar@GOTPCREL(%rip), %rsi + subq bar@GOTPCREL(%rip), %rbp + xorq bar@GOTPCREL(%rip), %r8 + testq %r15, bar@GOTPCREL(%rip) + adcl foo@GOTPCREL(%rip), %eax + addl foo@GOTPCREL(%rip), %ebx + andl foo@GOTPCREL(%rip), %ecx + cmpl foo@GOTPCREL(%rip), %edx + orl foo@GOTPCREL(%rip), %esi + sbbl foo@GOTPCREL(%rip), %edi + subl foo@GOTPCREL(%rip), %ebp + xorl foo@GOTPCREL(%rip), %r8d + testl %r15d, foo@GOTPCREL(%rip) + adcq foo@GOTPCREL(%rip), %rax + addq foo@GOTPCREL(%rip), %rbx + andq foo@GOTPCREL(%rip), %rcx + cmpq foo@GOTPCREL(%rip), %rdx + orq foo@GOTPCREL(%rip), %rdi + sbbq foo@GOTPCREL(%rip), %rsi + subq foo@GOTPCREL(%rip), %rbp + xorq foo@GOTPCREL(%rip), %r8 + testq %r15, foo@GOTPCREL(%rip) + .size _start, .-_start diff --git a/ld/testsuite/ld-x86-64/load1a.d b/ld/testsuite/ld-x86-64/load1a.d new file mode 100644 index 0000000..e03efbd --- /dev/null +++ b/ld/testsuite/ld-x86-64/load1a.d @@ -0,0 +1,54 @@ +#source: load1.s +#as: --64 +#ld: -melf_x86_64 +#objdump: -dw --sym + +.*: +file format .* + +SYMBOL TABLE: +#... +0+6001b8 l O .data 0+1 bar +#... +0+6001b9 g O .data 0+1 foo +#... + +Disassembly of section .text: + +0+4000b0 <_start>: +[ ]*[a-f0-9]+: 81 d0 b8 01 60 00 adc \$0x6001b8,%eax +[ ]*[a-f0-9]+: 81 c3 b8 01 60 00 add \$0x6001b8,%ebx +[ ]*[a-f0-9]+: 81 e1 b8 01 60 00 and \$0x6001b8,%ecx +[ ]*[a-f0-9]+: 81 fa b8 01 60 00 cmp \$0x6001b8,%edx +[ ]*[a-f0-9]+: 81 ce b8 01 60 00 or \$0x6001b8,%esi +[ ]*[a-f0-9]+: 81 df b8 01 60 00 sbb \$0x6001b8,%edi +[ ]*[a-f0-9]+: 81 ed b8 01 60 00 sub \$0x6001b8,%ebp +[ ]*[a-f0-9]+: 41 81 f0 b8 01 60 00 xor \$0x6001b8,%r8d +[ ]*[a-f0-9]+: 41 f7 c7 b8 01 60 00 test \$0x6001b8,%r15d +[ ]*[a-f0-9]+: 48 81 d0 b8 01 60 00 adc \$0x6001b8,%rax +[ ]*[a-f0-9]+: 48 81 c3 b8 01 60 00 add \$0x6001b8,%rbx +[ ]*[a-f0-9]+: 48 81 e1 b8 01 60 00 and \$0x6001b8,%rcx +[ ]*[a-f0-9]+: 48 81 fa b8 01 60 00 cmp \$0x6001b8,%rdx +[ ]*[a-f0-9]+: 48 81 cf b8 01 60 00 or \$0x6001b8,%rdi +[ ]*[a-f0-9]+: 48 81 de b8 01 60 00 sbb \$0x6001b8,%rsi +[ ]*[a-f0-9]+: 48 81 ed b8 01 60 00 sub \$0x6001b8,%rbp +[ ]*[a-f0-9]+: 49 81 f0 b8 01 60 00 xor \$0x6001b8,%r8 +[ ]*[a-f0-9]+: 49 f7 c7 b8 01 60 00 test \$0x6001b8,%r15 +[ ]*[a-f0-9]+: 81 d0 b9 01 60 00 adc \$0x6001b9,%eax +[ ]*[a-f0-9]+: 81 c3 b9 01 60 00 add \$0x6001b9,%ebx +[ ]*[a-f0-9]+: 81 e1 b9 01 60 00 and \$0x6001b9,%ecx +[ ]*[a-f0-9]+: 81 fa b9 01 60 00 cmp \$0x6001b9,%edx +[ ]*[a-f0-9]+: 81 ce b9 01 60 00 or \$0x6001b9,%esi +[ ]*[a-f0-9]+: 81 df b9 01 60 00 sbb \$0x6001b9,%edi +[ ]*[a-f0-9]+: 81 ed b9 01 60 00 sub \$0x6001b9,%ebp +[ ]*[a-f0-9]+: 41 81 f0 b9 01 60 00 xor \$0x6001b9,%r8d +[ ]*[a-f0-9]+: 41 f7 c7 b9 01 60 00 test \$0x6001b9,%r15d +[ ]*[a-f0-9]+: 48 81 d0 b9 01 60 00 adc \$0x6001b9,%rax +[ ]*[a-f0-9]+: 48 81 c3 b9 01 60 00 add \$0x6001b9,%rbx +[ ]*[a-f0-9]+: 48 81 e1 b9 01 60 00 and \$0x6001b9,%rcx +[ ]*[a-f0-9]+: 48 81 fa b9 01 60 00 cmp \$0x6001b9,%rdx +[ ]*[a-f0-9]+: 48 81 cf b9 01 60 00 or \$0x6001b9,%rdi +[ ]*[a-f0-9]+: 48 81 de b9 01 60 00 sbb \$0x6001b9,%rsi +[ ]*[a-f0-9]+: 48 81 ed b9 01 60 00 sub \$0x6001b9,%rbp +[ ]*[a-f0-9]+: 49 81 f0 b9 01 60 00 xor \$0x6001b9,%r8 +[ ]*[a-f0-9]+: 49 f7 c7 b9 01 60 00 test \$0x6001b9,%r15 +#pass diff --git a/ld/testsuite/ld-x86-64/load1b.d b/ld/testsuite/ld-x86-64/load1b.d new file mode 100644 index 0000000..5adc89d --- /dev/null +++ b/ld/testsuite/ld-x86-64/load1b.d @@ -0,0 +1,55 @@ +#source: load1.s +#as: --x32 +#ld: -melf32_x86_64 +#objdump: -dw --sym + +.*: +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 diff --git a/ld/testsuite/ld-x86-64/load1c.d b/ld/testsuite/ld-x86-64/load1c.d new file mode 100644 index 0000000..2e0eb07 --- /dev/null +++ b/ld/testsuite/ld-x86-64/load1c.d @@ -0,0 +1,47 @@ +#source: load1.s +#as: --64 +#ld: -shared -melf_x86_64 +#objdump: -dw + +.*: +file format .* + +Disassembly of section .text: + +[a-f0-9]+ <_start>: +[ ]*[a-f0-9]+: 13 05 ca 01 20 00 adc 0x2001ca\(%rip\),%eax # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 03 1d c4 01 20 00 add 0x2001c4\(%rip\),%ebx # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 23 0d be 01 20 00 and 0x2001be\(%rip\),%ecx # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 3b 15 b8 01 20 00 cmp 0x2001b8\(%rip\),%edx # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 0b 35 b2 01 20 00 or 0x2001b2\(%rip\),%esi # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 1b 3d ac 01 20 00 sbb 0x2001ac\(%rip\),%edi # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 2b 2d a6 01 20 00 sub 0x2001a6\(%rip\),%ebp # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 44 33 05 9f 01 20 00 xor 0x20019f\(%rip\),%r8d # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 44 85 3d 98 01 20 00 test %r15d,0x200198\(%rip\) # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 13 05 91 01 20 00 adc 0x200191\(%rip\),%rax # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 03 1d 8a 01 20 00 add 0x20018a\(%rip\),%rbx # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 23 0d 83 01 20 00 and 0x200183\(%rip\),%rcx # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 3b 15 7c 01 20 00 cmp 0x20017c\(%rip\),%rdx # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 0b 3d 75 01 20 00 or 0x200175\(%rip\),%rdi # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 1b 35 6e 01 20 00 sbb 0x20016e\(%rip\),%rsi # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 48 2b 2d 67 01 20 00 sub 0x200167\(%rip\),%rbp # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 4c 33 05 60 01 20 00 xor 0x200160\(%rip\),%r8 # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 4c 85 3d 59 01 20 00 test %r15,0x200159\(%rip\) # 2003e0 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: 13 05 5b 01 20 00 adc 0x20015b\(%rip\),%eax # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 03 1d 55 01 20 00 add 0x200155\(%rip\),%ebx # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 23 0d 4f 01 20 00 and 0x20014f\(%rip\),%ecx # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 3b 15 49 01 20 00 cmp 0x200149\(%rip\),%edx # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 0b 35 43 01 20 00 or 0x200143\(%rip\),%esi # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 1b 3d 3d 01 20 00 sbb 0x20013d\(%rip\),%edi # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 2b 2d 37 01 20 00 sub 0x200137\(%rip\),%ebp # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 44 33 05 30 01 20 00 xor 0x200130\(%rip\),%r8d # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 44 85 3d 29 01 20 00 test %r15d,0x200129\(%rip\) # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 13 05 22 01 20 00 adc 0x200122\(%rip\),%rax # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 03 1d 1b 01 20 00 add 0x20011b\(%rip\),%rbx # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 23 0d 14 01 20 00 and 0x200114\(%rip\),%rcx # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 3b 15 0d 01 20 00 cmp 0x20010d\(%rip\),%rdx # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 0b 3d 06 01 20 00 or 0x200106\(%rip\),%rdi # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 1b 35 ff 00 20 00 sbb 0x2000ff\(%rip\),%rsi # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 48 2b 2d f8 00 20 00 sub 0x2000f8\(%rip\),%rbp # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 4c 33 05 f1 00 20 00 xor 0x2000f1\(%rip\),%r8 # 2003e8 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: 4c 85 3d ea 00 20 00 test %r15,0x2000ea\(%rip\) # 2003e8 <_DYNAMIC\+0xe8> +#pass diff --git a/ld/testsuite/ld-x86-64/load1d.d b/ld/testsuite/ld-x86-64/load1d.d new file mode 100644 index 0000000..68292ac --- /dev/null +++ b/ld/testsuite/ld-x86-64/load1d.d @@ -0,0 +1,47 @@ +#source: load1.s +#as: --x32 +#ld: -shared -melf32_x86_64 +#objdump: -dw + +.*: +file format .* + +Disassembly of section .text: + +0+[a-f0-9]+ <_start>: +[ ]*[a-f0-9]+: 13 05 5e 01 20 00 adc 0x20015e\(%rip\),%eax # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 03 1d 58 01 20 00 add 0x200158\(%rip\),%ebx # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 23 0d 52 01 20 00 and 0x200152\(%rip\),%ecx # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 3b 15 4c 01 20 00 cmp 0x20014c\(%rip\),%edx # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 0b 35 46 01 20 00 or 0x200146\(%rip\),%esi # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 1b 3d 40 01 20 00 sbb 0x200140\(%rip\),%edi # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 2b 2d 3a 01 20 00 sub 0x20013a\(%rip\),%ebp # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 44 33 05 33 01 20 00 xor 0x200133\(%rip\),%r8d # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 44 85 3d 2c 01 20 00 test %r15d,0x20012c\(%rip\) # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 13 05 25 01 20 00 adc 0x200125\(%rip\),%rax # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 03 1d 1e 01 20 00 add 0x20011e\(%rip\),%rbx # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 23 0d 17 01 20 00 and 0x200117\(%rip\),%rcx # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 3b 15 10 01 20 00 cmp 0x200110\(%rip\),%rdx # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 0b 3d 09 01 20 00 or 0x200109\(%rip\),%rdi # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 1b 35 02 01 20 00 sbb 0x200102\(%rip\),%rsi # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 48 2b 2d fb 00 20 00 sub 0x2000fb\(%rip\),%rbp # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 4c 33 05 f4 00 20 00 xor 0x2000f4\(%rip\),%r8 # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 4c 85 3d ed 00 20 00 test %r15,0x2000ed\(%rip\) # 2002d0 <_DYNAMIC\+0x70> +[ ]*[a-f0-9]+: 13 05 ef 00 20 00 adc 0x2000ef\(%rip\),%eax # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 03 1d e9 00 20 00 add 0x2000e9\(%rip\),%ebx # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 23 0d e3 00 20 00 and 0x2000e3\(%rip\),%ecx # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 3b 15 dd 00 20 00 cmp 0x2000dd\(%rip\),%edx # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 0b 35 d7 00 20 00 or 0x2000d7\(%rip\),%esi # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 1b 3d d1 00 20 00 sbb 0x2000d1\(%rip\),%edi # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 2b 2d cb 00 20 00 sub 0x2000cb\(%rip\),%ebp # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 44 33 05 c4 00 20 00 xor 0x2000c4\(%rip\),%r8d # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 44 85 3d bd 00 20 00 test %r15d,0x2000bd\(%rip\) # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 13 05 b6 00 20 00 adc 0x2000b6\(%rip\),%rax # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 03 1d af 00 20 00 add 0x2000af\(%rip\),%rbx # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 23 0d a8 00 20 00 and 0x2000a8\(%rip\),%rcx # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 3b 15 a1 00 20 00 cmp 0x2000a1\(%rip\),%rdx # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 0b 3d 9a 00 20 00 or 0x20009a\(%rip\),%rdi # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 1b 35 93 00 20 00 sbb 0x200093\(%rip\),%rsi # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 48 2b 2d 8c 00 20 00 sub 0x20008c\(%rip\),%rbp # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 4c 33 05 85 00 20 00 xor 0x200085\(%rip\),%r8 # 2002d8 <_DYNAMIC\+0x78> +[ ]*[a-f0-9]+: 4c 85 3d 7e 00 20 00 test %r15,0x20007e\(%rip\) # 2002d8 <_DYNAMIC\+0x78> +#pass diff --git a/ld/testsuite/ld-x86-64/plt-main1.rd b/ld/testsuite/ld-x86-64/plt-main1.rd index 421d911..36fa8ef 100644 --- a/ld/testsuite/ld-x86-64/plt-main1.rd +++ b/ld/testsuite/ld-x86-64/plt-main1.rd @@ -1,3 +1,3 @@ #... -[0-9a-f ]+R_X86_64_GOTPCREL +0+ +bar - 4 +[0-9a-f ]+R_X86_64_(REX_|)GOTPCRELX +0+ +bar - 4 #pass diff --git a/ld/testsuite/ld-x86-64/plt-main3.rd b/ld/testsuite/ld-x86-64/plt-main3.rd index f3d294e..0a0d402 100644 --- a/ld/testsuite/ld-x86-64/plt-main3.rd +++ b/ld/testsuite/ld-x86-64/plt-main3.rd @@ -1,5 +1,5 @@ #... -[0-9a-f ]+R_X86_64_GOTPCREL +0+ +bar - 4 +[0-9a-f ]+R_X86_64_(REX_GOTPCRELX|GOTPCREL) +0+ +bar - 4 #... [0-9a-f ]+R_X86_64_PLT32 +0+ +bar - 4 #pass diff --git a/ld/testsuite/ld-x86-64/plt-main4.rd b/ld/testsuite/ld-x86-64/plt-main4.rd index 7f33f3a..d391fc0 100644 --- a/ld/testsuite/ld-x86-64/plt-main4.rd +++ b/ld/testsuite/ld-x86-64/plt-main4.rd @@ -1,5 +1,5 @@ #... -[0-9a-f ]+R_X86_64_GOTPCREL +0+ +foo - 4 +[0-9a-f ]+R_X86_64_(REX_|)GOTPCRELX +0+ +foo - 4 #... [0-9a-f ]+R_X86_64_PLT32 +0+ +foo - 4 #pass diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 69728c2..7b8990b 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -321,6 +321,10 @@ run_dump_test "mov1a" run_dump_test "mov1b" run_dump_test "mov1c" run_dump_test "mov1d" +run_dump_test "load1a" +run_dump_test "load1b" +run_dump_test "load1c" +run_dump_test "load1d" run_dump_test "pr17935-1" run_dump_test "pr17935-2" run_dump_test "pr18160" @@ -511,6 +515,22 @@ if { [isnative] && [which $CC] != 0 } { "" \ "pr19031.so" \ ] \ + [list \ + "Build gotpcrel1d.so" \ + "-shared" \ + "" \ + { gotpcrel1d.S } \ + "" \ + "gotpcrel1d.so" \ + ] \ + [list \ + "Build gotpcrel1" \ + "tmpdir/gotpcrel1d.so" \ + "" \ + { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \ + {{objdump {-dw} gotpcrel1.dd}} \ + "gotpcrel1" \ + ] \ ] run_ld_link_exec_tests [] [list \ @@ -573,6 +593,14 @@ if { [isnative] && [which $CC] != 0 } { "pr19031" \ "pr19031.out" \ ] \ + [list \ + "Run gotpcrel1" \ + "tmpdir/gotpcrel1d.so" \ + "" \ + { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \ + "gotpcrel1" \ + "gotpcrel1.out" \ + ] \ ] if { [istarget "x86_64-*-linux*"] \ |