Implement R_X86_64_GOTTPOFF, R_X86_64_TLSGD and R_X86_64_TPOFF32.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117481 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-10-27 20:28:07 +00:00
parent f31430f6ec
commit bc82d8b84f
2 changed files with 40 additions and 7 deletions

View File

@ -85,6 +85,9 @@ static bool RelocNeedsGOT(unsigned Type) {
case ELF::R_X86_64_GOT32:
case ELF::R_X86_64_PLT32:
case ELF::R_X86_64_GOTPCREL:
case ELF::R_X86_64_TPOFF32:
case ELF::R_X86_64_TLSGD:
case ELF::R_X86_64_GOTTPOFF:
return true;
}
}
@ -687,6 +690,12 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case llvm::MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
case MCSymbolRefExpr::VK_GOTTPOFF:
Type = ELF::R_X86_64_GOTTPOFF;
break;
case MCSymbolRefExpr::VK_TLSGD:
Type = ELF::R_X86_64_TLSGD;
break;
}
} else {
switch ((unsigned)Fixup.getKind()) {
@ -707,6 +716,9 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
case MCSymbolRefExpr::VK_TPOFF:
Type = ELF::R_X86_64_TPOFF32;
break;
}
break;
case FK_Data_4:

View File

@ -1,14 +1,17 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
// Test that we produce a R_X86_64_32S or R_X86_64_32.
// Test that we produce the correct relocation.
bar:
movl $bar, %edx // R_X86_64_32
movq $bar, %rdx // R_X86_64_32S
movq $bar, bar(%rip) // R_X86_64_32S
movl bar, %edx // R_X86_64_32S
movq bar, %rdx // R_X86_64_32S
.long bar // R_X86_64_32
movl $bar, %edx # R_X86_64_32
movq $bar, %rdx # R_X86_64_32S
movq $bar, bar(%rip) # R_X86_64_32S
movl bar, %edx # R_X86_64_32S
movq bar, %rdx # R_X86_64_32S
.long bar # R_X86_64_32
leaq foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF
leaq foo@TLSGD(%rip), %rax # R_X86_64_TLSGD
leaq foo@TPOFF(%rax), %rax # R_X86_64_TPOFF32
// CHECK: # Section 0x00000001
// CHECK: (('sh_name', 0x00000001) # '.text'
@ -55,3 +58,21 @@ bar:
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000a)
// CHECK-NEXT: ('r_addend',
// CHECK: # Relocation 0x00000006
// CHECK-NEXT: (('r_offset', 0x0000002d)
// CHECK-NEXT: ('r_sym', 0x00000006)
// CHECK-NEXT: ('r_type', 0x00000016)
// CHECK-NEXT: ('r_addend', 0xfffffffc)
// CHECK: # Relocation 0x00000007
// CHECK-NEXT: (('r_offset', 0x00000034)
// CHECK-NEXT: ('r_sym', 0x00000006)
// CHECK-NEXT: ('r_type', 0x00000013)
// CHECK-NEXT: ('r_addend', 0xfffffffc)
// CHECK: # Relocation 0x00000008
// CHECK-NEXT: (('r_offset', 0x0000003b)
// CHECK-NEXT: ('r_sym', 0x00000006)
// CHECK-NEXT: ('r_type', 0x00000017)
// CHECK-NEXT: ('r_addend', 0x00000000)