diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h index e1f27f156cb..272c7c0e07b 100644 --- a/include/llvm/MC/MCExpr.h +++ b/include/llvm/MC/MCExpr.h @@ -139,6 +139,7 @@ public: VK_TLSGD, VK_TLSLDM, VK_TPOFF, + VK_DTPOFF, VK_ARM_HI16, // The R_ARM_MOVT_ABS relocation (:upper16: in the asm file) VK_ARM_LO16, // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the asm file) VK_ARM_PLT, // ARM-style PLT symbol references. i.e., (PLT) instead of @PLT diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 22005022851..5cffef03d3a 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -92,6 +92,7 @@ static bool RelocNeedsGOT(MCSymbolRefExpr::VariantKind Variant) { case MCSymbolRefExpr::VK_NTPOFF: case MCSymbolRefExpr::VK_GOTNTPOFF: case MCSymbolRefExpr::VK_TLSLDM: + case MCSymbolRefExpr::VK_DTPOFF: return true; } } @@ -788,6 +789,9 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm, case MCSymbolRefExpr::VK_TLSLDM: Type = ELF::R_386_TLS_LDM; break; + case MCSymbolRefExpr::VK_DTPOFF: + Type = ELF::R_386_TLS_LDO_32; + break; } break; case FK_Data_2: Type = ELF::R_386_16; break; diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 6ee2520e69a..5780ba9411c 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -180,6 +180,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) { case VK_TLSGD: return "TLSGD"; case VK_TLSLDM: return "TLSLDM"; case VK_TPOFF: return "TPOFF"; + case VK_DTPOFF: return "DTPOFF"; case VK_ARM_HI16: return ":upper16:"; case VK_ARM_LO16: return ":lower16:"; case VK_ARM_PLT: return "(PLT)"; @@ -201,6 +202,7 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) { .Case("TLSGD", VK_TLSGD) .Case("TLSLDM", VK_TLSLDM) .Case("TPOFF", VK_TPOFF) + .Case("DTPOFF", VK_DTPOFF) .Case("TLVP", VK_TLVP) .Default(VK_Invalid); } diff --git a/test/MC/ELF/relocation-386.s b/test/MC/ELF/relocation-386.s index 9fb0befb03f..c3903236187 100644 --- a/test/MC/ELF/relocation-386.s +++ b/test/MC/ELF/relocation-386.s @@ -91,6 +91,14 @@ // CHECK-NEXT: ('r_sym', 0x0000000b) // CHECK-NEXT: ('r_type', 0x00000013) // CHECK-NEXT: ), + +// Relocation 11 (foo@DTPOFF) is of type R_386_TLS_LDO_32 +// CHECK-NEXT: # Relocation 0x0000000b +// CHECK-NEXT: (('r_offset', 0x00000043) +// CHECK-NEXT: ('r_sym', 0x0000000b) +// CHECK-NEXT: ('r_type', 0x00000020) +// CHECK-NEXT: ), + .text bar: leal .Lfoo@GOTOFF(%ebx), %eax @@ -113,6 +121,7 @@ bar2: addl foo@NTPOFF(%eax), %eax addl foo@GOTNTPOFF(%ebx), %ecx leal foo@TLSLDM(%ebx), %eax + leal foo@DTPOFF(%eax), %edx .section .rodata.str1.16,"aMS",@progbits,1 .Lfoo: