[llvm-commits] [llvm] r115537 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/got.s
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 4 11:44:25 PDT 2010
Author: rafael
Date: Mon Oct 4 13:44:25 2010
New Revision: 115537
URL: http://llvm.org/viewvc/llvm-project?rev=115537&view=rev
Log:
Produce a R_X86_64_GOT32 when needed.
Added:
llvm/trunk/test/MC/ELF/got.s
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=115537&r1=115536&r2=115537&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Oct 4 13:44:25 2010
@@ -576,6 +576,8 @@
FixedValue = Value;
// determine the type of the relocation
+
+ MCSymbolRefExpr::VariantKind Modifier = Target.getSymA()->getKind();
unsigned Type;
if (Is64Bit) {
if (IsPCRel) {
@@ -587,7 +589,16 @@
case X86::reloc_signed_4byte:
case X86::reloc_pcrel_4byte:
assert(isInt<32>(Target.getConstant()));
- Type = ELF::R_X86_64_32S;
+ switch (Modifier) {
+ case MCSymbolRefExpr::VK_None:
+ Type = ELF::R_X86_64_32S;
+ break;
+ case MCSymbolRefExpr::VK_GOT:
+ Type = ELF::R_X86_64_GOT32;
+ break;
+ default:
+ llvm_unreachable("Unimplemented");
+ }
break;
case FK_Data_4:
Type = ELF::R_X86_64_32;
Added: llvm/trunk/test/MC/ELF/got.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/got.s?rev=115537&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/got.s (added)
+++ llvm/trunk/test/MC/ELF/got.s Mon Oct 4 13:44:25 2010
@@ -0,0 +1,14 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
+
+// Test that this produces a R_X86_64_GOT32.
+
+ movl foo at GOT, %eax
+
+// CHECK: ('_relocations', [
+// CHECK-NEXT: # Relocation 0
+// CHECK-NEXT: (('r_offset',
+// CHECK-NEXT: ('r_sym',
+// CHECK-NEXT: ('r_type', 3)
+// CHECK-NEXT: ('r_addend',
+// CHECK-NEXT: ),
+// CHECK-NEXT: ])
More information about the llvm-commits
mailing list