ADD64ri32 sign extends its argument, so we need to use a R_X86_64_32S.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 19 May 2011 20:32:34 +0000 (20:32 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 19 May 2011 20:32:34 +0000 (20:32 +0000)
Fixes PR9934.

We really need to start tblgening the relocation info :-(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131669 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f195a67a30409e5ee426d1d20f27aca88f0ecd99..55aceba9f270925c5f1244ea3e5c2f8cf05ee339 100644 (file)
@@ -1015,7 +1015,8 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
     } else {
       unsigned FixupKind;
       // FIXME: Is there a better way to know that we need a signed relocation?
-      if (MI.getOpcode() == X86::MOV64ri32 ||
+      if (MI.getOpcode() == X86::ADD64ri32 ||
+          MI.getOpcode() == X86::MOV64ri32 ||
           MI.getOpcode() == X86::MOV64mi32 ||
           MI.getOpcode() == X86::PUSH64i32)
         FixupKind = X86::reloc_signed_4byte;
index 4df09e13fce0d625b186f0dcc0ab00c59eb16564..2760232a5a80fe7a2ca76e1a15f6fdde0b73823c 100644 (file)
@@ -17,6 +17,7 @@ bar:
         pushq    $bar
         movq   foo(%rip), %rdx
         leaq    foo-bar(%r14),%r14
+        addq   $bar,%rax         # R_X86_64_32S
 
 
 // CHECK:  # Section 0x00000001
@@ -106,6 +107,12 @@ bar:
 // CHECK-NEXT:  ('r_type', 0x00000002)
 // CHECK-NEXT:  ('r_addend', 0x0000005c)
 
+// CHECK: # Relocation 0x0000000e
+// CHECK-NEXT: (('r_offset', 0x00000063)
+// CHECK-NEXT:  ('r_sym', 0x00000002)
+// CHECK-NEXT:  ('r_type', 0x0000000b)
+// CHECK-NEXT:  ('r_addend', 0x00000000)
+
 // CHECK:   # Symbol 0x00000002
 // CHECK: (('st_name', 0x00000000) # ''
 // CHECK:  ('st_bind', 0x00000000)