Implement VK_GOTNTPOFF and switch RelocNeedsGOT to use VariantKind.

llvm-svn: 117543
This commit is contained in:
Rafael Espindola 2010-10-28 14:22:44 +00:00
parent 440ea32773
commit b3b49bbc39
4 changed files with 28 additions and 15 deletions

View File

@ -134,6 +134,7 @@ public:
VK_GOTTPOFF,
VK_INDNTPOFF,
VK_NTPOFF,
VK_GOTNTPOFF,
VK_PLT,
VK_TLSGD,
VK_TPOFF,

View File

@ -78,21 +78,19 @@ static bool isFixupKindX86PCRel(unsigned Kind) {
}
}
static bool RelocNeedsGOT(unsigned Type) {
// FIXME: Can we use the VariantKind?
switch (Type) {
static bool RelocNeedsGOT(MCSymbolRefExpr::VariantKind Variant) {
switch (Variant) {
default:
return false;
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:
case ELF::R_386_TLS_GD:
case ELF::R_386_TLS_LE_32:
case ELF::R_386_TLS_IE:
case ELF::R_386_TLS_LE:
case MCSymbolRefExpr::VK_GOT:
case MCSymbolRefExpr::VK_PLT:
case MCSymbolRefExpr::VK_GOTPCREL:
case MCSymbolRefExpr::VK_TPOFF:
case MCSymbolRefExpr::VK_TLSGD:
case MCSymbolRefExpr::VK_GOTTPOFF:
case MCSymbolRefExpr::VK_INDNTPOFF:
case MCSymbolRefExpr::VK_NTPOFF:
case MCSymbolRefExpr::VK_GOTNTPOFF:
return true;
}
}
@ -692,7 +690,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case MCSymbolRefExpr::VK_PLT:
Type = ELF::R_X86_64_PLT32;
break;
case llvm::MCSymbolRefExpr::VK_GOTPCREL:
case MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
case MCSymbolRefExpr::VK_GOTTPOFF:
@ -783,6 +781,9 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case MCSymbolRefExpr::VK_NTPOFF:
Type = ELF::R_386_TLS_LE;
break;
case MCSymbolRefExpr::VK_GOTNTPOFF:
Type = ELF::R_386_TLS_GOTIE;
break;
}
break;
case FK_Data_2: Type = ELF::R_386_16; break;
@ -792,7 +793,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
}
}
if (RelocNeedsGOT(Type))
if (RelocNeedsGOT(Modifier))
NeedsGOT = true;
ELFRelocationEntry ERE;

View File

@ -175,6 +175,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
case VK_GOTTPOFF: return "GOTTPOFF";
case VK_INDNTPOFF: return "INDNTPOFF";
case VK_NTPOFF: return "NTPOFF";
case VK_GOTNTPOFF: return "GOTNTPOFF";
case VK_PLT: return "PLT";
case VK_TLSGD: return "TLSGD";
case VK_TPOFF: return "TPOFF";
@ -194,6 +195,7 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
.Case("GOTTPOFF", VK_GOTTPOFF)
.Case("INDNTPOFF", VK_INDNTPOFF)
.Case("NTPOFF", VK_NTPOFF)
.Case("GOTNTPOFF", VK_GOTNTPOFF)
.Case("PLT", VK_PLT)
.Case("TLSGD", VK_TLSGD)
.Case("TPOFF", VK_TPOFF)

View File

@ -76,6 +76,14 @@
// CHECK-NEXT: (('r_offset', 0x00000031)
// CHECK-NEXT: ('r_sym', 0x0000000b)
// CHECK-NEXT: ('r_type', 0x00000011)
// CHECK-NEXT: ),
// Relocation 9 (foo@GOTNTPOFF) is of type R_386_TLS_GOTIE
// CHECK-NEXT: # Relocation 0x00000009
// CHECK-NEXT: (('r_offset', 0x00000037)
// CHECK-NEXT: ('r_sym', 0x0000000b)
// CHECK-NEXT: ('r_type', 0x00000010)
// CHECK-NEXT: ),
.text
bar:
@ -97,6 +105,7 @@ bar2:
movl $foo@TPOFF, %edx
movl foo@INDNTPOFF, %ecx
addl foo@NTPOFF(%eax), %eax
addl foo@GOTNTPOFF(%ebx), %ecx
.section .rodata.str1.16,"aMS",@progbits,1
.Lfoo: