[llvm-commits] [llvm] r115793 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/merge.s
Rafael Espindola
rafael.espindola at gmail.com
Wed Oct 6 09:23:36 PDT 2010
Author: rafael
Date: Wed Oct 6 11:23:36 2010
New Revision: 115793
URL: http://llvm.org/viewvc/llvm-project?rev=115793&view=rev
Log:
Correctly handle GOTPCREL relocations.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ELF/merge.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=115793&r1=115792&r2=115793&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Oct 6 11:23:36 2010
@@ -544,12 +544,12 @@
if (SD.isExternal())
return true;
- const llvm::MCSymbolRefExpr& Ref = *Target.getSymA();
+ MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind();
const MCSectionELF &Sec2 =
static_cast<const MCSectionELF&>(F.getParent()->getSection());
- if (Ref.getKind() == MCSymbolRefExpr::VK_PLT &&
- &Sec2 != &Section)
+ if (&Sec2 != &Section &&
+ (Kind == MCSymbolRefExpr::VK_PLT || Kind == MCSymbolRefExpr::VK_GOTPCREL))
return true;
return false;
@@ -648,6 +648,9 @@
case MCSymbolRefExpr::VK_GOT:
Type = ELF::R_X86_64_GOT32;
break;
+ case llvm::MCSymbolRefExpr::VK_GOTPCREL:
+ Type = ELF::R_X86_64_GOTPCREL;
+ break;
default:
llvm_unreachable("Unimplemented");
}
Modified: llvm/trunk/test/MC/ELF/merge.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/merge.s?rev=115793&r1=115792&r2=115793&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/merge.s (original)
+++ llvm/trunk/test/MC/ELF/merge.s Wed Oct 6 11:23:36 2010
@@ -11,6 +11,7 @@
movl $.Lfoo, %edi
movl $.Lfoo+2, %edi
jmp foo at PLT
+ movq foo at GOTPCREL, %rax
.section .sec1,"aM", at progbits,16
.Lfoo:
@@ -70,4 +71,12 @@
// CHECK-NEXT: ('r_type', 4
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
+
+// Relocation 4 refers to symbol 2
+// CHECK-NEXT: # Relocation 4
+// CHECK-NEXT: (('r_offset',
+// CHECK-NEXT: ('r_sym', 2)
+// CHECK-NEXT: ('r_type', 9
+// CHECK-NEXT: ('r_addend',
+// CHECK-NEXT: ),
// CHECK-NEXT: ])
More information about the llvm-commits
mailing list