summaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-11-07 12:22:53 -0800
committerH.J. Lu <hjl.tools@gmail.com>2014-11-07 12:31:01 -0800
commitcf115d606eea814d659588953cbaa5b0b16e234c (patch)
tree54d26310722578b4ef723553d795c1ec502b8fec /gas
parent35cd712bccbb56c7705eb9cd7372b725da6152b4 (diff)
downloadbinutils-cf115d606eea814d659588953cbaa5b0b16e234c.tar.gz
binutils-cf115d606eea814d659588953cbaa5b0b16e234c.tar.bz2
binutils-cf115d606eea814d659588953cbaa5b0b16e234c.zip
X32: Add REX prefix to encode R_X86_64_GOTTPOFF
Structions with R_X86_64_GOTTPOFF relocation must be encoded with REX prefix even if it isn't required by destination register. Otherwise linker can't safely perform IE -> LE optimization. bfd/ PR ld/17482 * elf64-x86-64.c (elf_x86_64_relocate_section): Update comments for IE->LE transition. gas/ PR ld/17482 * config/tc-i386.c (output_insn): Add a dummy REX_OPCODE prefix for structions with R_X86_64_GOTTPOFF relocation for x32 if needed. gas/testsuite/ PR ld/17482 * gas/i386/ilp32/x32-tls.d: New file. * gas/i386/ilp32/x32-tls.s: Likewise. ld/testsuite/ PR ld/17482 * ld-x86-64/tlsie4.dd: Updated.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog9
-rw-r--r--gas/config/tc-i386.c9
-rw-r--r--gas/testsuite/ChangeLog9
-rw-r--r--gas/testsuite/gas/i386/ilp32/x32-tls.d13
-rw-r--r--gas/testsuite/gas/i386/ilp32/x32-tls.s13
5 files changed, 53 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index fde4a5251e7..cb1829d45d7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2014-11-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ Apply trunk patch:
+ 2014-11-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/17482
+ * config/tc-i386.c (output_insn): Add a dummy REX_OPCODE prefix
+ for structions with R_X86_64_GOTTPOFF relocation for x32 if needed.
+
2014-11-03 Nick Clifton <nickc@redhat.com>
Apply trunk patch:
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 2e34ce3df61..cdd4ed49bb6 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -6997,6 +6997,15 @@ check_prefix:
abort ();
}
+ /* For x32, add a dummy REX_OPCODE prefix for mov/add with
+ R_X86_64_GOTTPOFF relocation so that linker can safely
+ perform IE->LE optimization. */
+ if (x86_elf_abi == X86_64_X32_ABI
+ && i.operands == 2
+ && i.reloc[0] == BFD_RELOC_X86_64_GOTTPOFF
+ && i.prefix[REX_PREFIX] == 0)
+ add_prefix (REX_OPCODE);
+
/* The prefix bytes. */
for (j = ARRAY_SIZE (i.prefix), q = i.prefix; j > 0; j--, q++)
if (*q)
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 90c9d57b911..e39be365f75 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2014-11-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ Apply trunk patch:
+ 2014-11-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/17482
+ * gas/i386/ilp32/x32-tls.d: New file.
+ * gas/i386/ilp32/x32-tls.s: Likewise.
+
2014-10-28 Matthew Fortune <matthew.fortune@imgtec.com>
Apply trunk patches
diff --git a/gas/testsuite/gas/i386/ilp32/x32-tls.d b/gas/testsuite/gas/i386/ilp32/x32-tls.d
new file mode 100644
index 00000000000..1255829f8b7
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x32-tls.d
@@ -0,0 +1,13 @@
+#objdump: -dw
+#name: x86-64 (ILP32) TLS
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <_start>:
+[ ]*[a-f0-9]+: 48 8b 05 00 00 00 00 mov 0x0\(%rip\),%rax # 7 <_start\+0x7>
+[ ]*[a-f0-9]+: 4c 8b 25 00 00 00 00 mov 0x0\(%rip\),%r12 # e <_start\+0xe>
+[ ]*[a-f0-9]+: 40 03 05 00 00 00 00 rex add 0x0\(%rip\),%eax # 15 <_start\+0x15>
+[ ]*[a-f0-9]+: 44 03 25 00 00 00 00 add 0x0\(%rip\),%r12d # 1c <_start\+0x1c>
+#pass
diff --git a/gas/testsuite/gas/i386/ilp32/x32-tls.s b/gas/testsuite/gas/i386/ilp32/x32-tls.s
new file mode 100644
index 00000000000..f9626cdfdd3
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x32-tls.s
@@ -0,0 +1,13 @@
+ .text
+_start:
+ mov foo@gottpoff(%rip), %rax
+ mov foo@gottpoff(%rip), %r12
+ add foo@gottpoff(%rip), %eax
+ add foo@gottpoff(%rip), %r12d
+ .globl foo
+ .section .tdata,"awT",@progbits
+ .align 4
+ .type foo, @object
+ .size foo, 4
+foo:
+ .long 100