forked from OSchip/llvm-project
parent
fe9f456291
commit
b2c4ca6433
|
@ -576,6 +576,8 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
|||
FixedValue = Value;
|
||||
|
||||
// determine the type of the relocation
|
||||
|
||||
MCSymbolRefExpr::VariantKind Modifier = Target.getSymA()->getKind();
|
||||
unsigned Type;
|
||||
if (Is64Bit) {
|
||||
if (IsPCRel) {
|
||||
|
@ -587,8 +589,17 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
|||
case X86::reloc_signed_4byte:
|
||||
case X86::reloc_pcrel_4byte:
|
||||
assert(isInt<32>(Target.getConstant()));
|
||||
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;
|
||||
break;
|
||||
|
|
|
@ -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@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: ])
|
Loading…
Reference in New Issue