case R_X86_64_GOTTPOFF:
/* Check transition from IE access model:
- movq foo@gottpoff(%rip), %reg
- addq foo@gottpoff(%rip), %reg
+ mov foo@gottpoff(%rip), %reg
+ add foo@gottpoff(%rip), %reg
*/
- if (offset < 3 || (offset + 4) > sec->size)
- return FALSE;
-
- val = bfd_get_8 (abfd, contents + offset - 3);
- if (val != 0x48 && val != 0x4c)
- return FALSE;
+ /* Check REX prefix first. */
+ if (offset >= 3 && (offset + 4) <= sec->size)
+ {
+ val = bfd_get_8 (abfd, contents + offset - 3);
+ if (val != 0x48 && val != 0x4c)
+ {
+ /* X32 may have 0x44 REX prefix or no REX prefix. */
+ if (ABI_64_P (abfd))
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* X32 may not have any REX prefix. */
+ if (ABI_64_P (abfd))
+ return FALSE;
+ if (offset < 2 || (offset + 3) > sec->size)
+ return FALSE;
+ }
val = bfd_get_8 (abfd, contents + offset - 2);
if (val != 0x8b && val != 0x03)
if (val == 0x4c)
bfd_put_8 (output_bfd, 0x49,
contents + roff - 3);
+ else if (!ABI_64_P (output_bfd) && val == 0x44)
+ bfd_put_8 (output_bfd, 0x41,
+ contents + roff - 3);
bfd_put_8 (output_bfd, 0xc7,
contents + roff - 2);
bfd_put_8 (output_bfd, 0xc0 | reg,
if (val == 0x4c)
bfd_put_8 (output_bfd, 0x49,
contents + roff - 3);
+ else if (!ABI_64_P (output_bfd) && val == 0x44)
+ bfd_put_8 (output_bfd, 0x41,
+ contents + roff - 3);
bfd_put_8 (output_bfd, 0x81,
contents + roff - 2);
bfd_put_8 (output_bfd, 0xc0 | reg,
if (val == 0x4c)
bfd_put_8 (output_bfd, 0x4d,
contents + roff - 3);
+ else if (!ABI_64_P (output_bfd) && val == 0x44)
+ bfd_put_8 (output_bfd, 0x45,
+ contents + roff - 3);
bfd_put_8 (output_bfd, 0x8d,
contents + roff - 2);
bfd_put_8 (output_bfd, 0x80 | reg | (reg << 3),
--- /dev/null
+#source: tlsie4.s
+#as: --x32
+#ld: -melf32_x86_64 tmpdir/tlsie4
+#objdump: -drw
+#target: x86_64-*-linux*
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+[a-f0-9]+ <_start>:
+[ ]*[a-f0-9]+: c7 c0 fc ff ff ff mov \$0xfffffffc,%eax
+[ ]*[a-f0-9]+: 8d 80 fc ff ff ff lea -0x4\(%rax\),%eax
+[ ]*[a-f0-9]+: 41 c7 c0 fc ff ff ff mov \$0xfffffffc,%r8d
+[ ]*[a-f0-9]+: 45 8d 80 fc ff ff ff lea -0x4\(%r8\),%r8d
+[ ]*[a-f0-9]+: 41 c7 c4 fc ff ff ff mov \$0xfffffffc,%r12d
+[ ]*[a-f0-9]+: 41 81 c4 fc ff ff ff add \$0xfffffffc,%r12d
+#pass
--- /dev/null
+ .text
+ .globl _start
+_start:
+ mov foo@GOTTPOFF(%rip), %eax
+ add foo@GOTTPOFF(%rip), %eax
+ mov foo@GOTTPOFF(%rip), %r8d
+ add foo@GOTTPOFF(%rip), %r8d
+ mov foo@GOTTPOFF(%rip), %r12d
+ add foo@GOTTPOFF(%rip), %r12d
+ .globl foo
+ .section .tdata,"awT",@progbits
+ .align 4
+ .type foo, @object
+ .size foo, 4
+foo:
+ .long 100