X32: Add REX prefix to encode R_X86_64_GOTTPOFF
[deliverable/binutils-gdb.git] / gas / config / tc-i386.c
index 2e34ce3df6143247ea3e9227952582e6e6a6210d..cdd4ed49bb6a2c891a9b9c774ed1d745552ee6b4 100644 (file)
@@ -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)
This page took 0.024269 seconds and 4 git commands to generate.