Produce a R_X86_64_GOT32 when needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115537 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-10-04 18:44:25 +00:00
parent 265bc8932a
commit 28f9ac8101
2 changed files with 26 additions and 1 deletions

View File

@ -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,7 +589,16 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
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;

14
test/MC/ELF/got.s Normal file
View File

@ -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: ])