Make pushq produce signed relocations.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 16 Dec 2010 22:50:01 +0000 (22:50 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 16 Dec 2010 22:50:01 +0000 (22:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122005 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86MCCodeEmitter.cpp
test/MC/ELF/relocation.s

index 208a6805e40cc960e9fc3937e4ccbaf220b6f82d..e6dc74e65d795f815820b6d2576ce8f1f8b34d56 100644 (file)
@@ -996,7 +996,10 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
                     Fixups);
     } else {
       unsigned FixupKind;
-      if (MI.getOpcode() == X86::MOV64ri32 || MI.getOpcode() == X86::MOV64mi32)
+      // FIXME: Is there a better way to know that we need a signed relocation?
+      if (MI.getOpcode() == X86::MOV64ri32 ||
+          MI.getOpcode() == X86::MOV64mi32 ||
+          MI.getOpcode() == X86::PUSH64i32)
         FixupKind = X86::reloc_signed_4byte;
       else
         FixupKind = getImmFixupKind(TSFlags);
index 663c91e8c1a039d80e223e0b57ffeb248436cd20..a3ad5268b4076c4dec8afb5af69ffc25ab75e13d 100644 (file)
@@ -14,6 +14,8 @@ bar:
         leaq   foo@TPOFF(%rax), %rax    # R_X86_64_TPOFF32
         leaq   foo@TLSLD(%rip), %rdi    # R_X86_64_TLSLD
         leaq   foo@DTPOFF(%rax), %rcx   # R_X86_64_DTPOFF32
+        pushq    $bar
+
 
 // CHECK:  # Section 0x00000001
 // CHECK: (('sh_name', 0x00000001) # '.text'
@@ -90,3 +92,9 @@ bar:
 // CHECK-NEXT:   ('r_sym', 0x00000006)
 // CHECK-NEXT:   ('r_type', 0x00000015)
 // CHECK-NEXT:   ('r_addend', 0x00000000)
+
+// CHECK: # Relocation 0x0000000b
+// CHECK-NEXT:  (('r_offset', 0x0000004e)
+// CHECK-NEXT:   ('r_sym', 0x00000002)
+// CHECK-NEXT:   ('r_type', 0x0000000b)
+// CHECK-NEXT:   ('r_addend', 0x00000000)