diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 0c859aeec43d..5f747177eb39 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -372,6 +372,8 @@ RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { switch (Type) { default: return R_ABS; + case R_386_TLS_GD: + return R_TLSGD; case R_386_TLS_LDM: return R_TLSLD; case R_386_PLT32: @@ -677,12 +679,13 @@ RelExpr X86_64TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { return R_ABS; case R_X86_64_TLSLD: return R_TLSLD_PC; + case R_X86_64_TLSGD: + return R_TLSGD_PC; case R_X86_64_SIZE32: case R_X86_64_SIZE64: return R_SIZE; case R_X86_64_PLT32: case R_X86_64_PC32: - case R_X86_64_TLSGD: return R_PC; case R_X86_64_GOT32: return R_GOT; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index d230bc351e99..1c53e91131fa 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -317,13 +317,13 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, Off + (uintX_t)sizeof(uintX_t), false, &Body, 0}); } - Expr = Expr == R_PC ? R_TLSGD_PC : R_TLSGD; C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; } if (Body.isPreemptible()) { - Expr = Expr == R_PC ? R_RELAX_TLS_GD_TO_IE_PC : R_RELAX_TLS_GD_TO_IE; + Expr = + Expr == R_TLSGD_PC ? R_RELAX_TLS_GD_TO_IE_PC : R_RELAX_TLS_GD_TO_IE; C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); if (!Body.isInGot()) { Out::Got->addEntry(Body);