FixedValue = Value;
// determine the type of the relocation
+
+ MCSymbolRefExpr::VariantKind Modifier = Target.getSymA()->getKind();
unsigned Type;
if (Is64Bit) {
if (IsPCRel) {
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;
--- /dev/null
+// 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@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: ])