Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -233,7 +233,7 @@ } // Local-Dynamic relocs can be relaxed to Local-Exec. - if (Target->isTlsLocalDynamicRel(Type) && !Config->Shared) { + if (isRelExprOneOf(Expr) && !Config->Shared) { C.Relocations.push_back( {R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body}); return 1; @@ -282,7 +282,8 @@ // Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally // defined. - if (Target->isTlsInitialExecRel(Type) && !Config->Shared && !IsPreemptible) { + if (isRelExprOneOf(Expr) && + !Config->Shared && !IsPreemptible) { C.Relocations.push_back( {R_RELAX_TLS_IE_TO_LE, Type, Offset, Addend, &Body}); return 1; Index: ELF/Target.h =================================================================== --- ELF/Target.h +++ ELF/Target.h @@ -23,8 +23,6 @@ class TargetInfo { public: - virtual bool isTlsInitialExecRel(uint32_t Type) const; - virtual bool isTlsLocalDynamicRel(uint32_t Type) const; virtual bool isPicRel(uint32_t Type) const { return true; } virtual uint32_t getDynRel(uint32_t Type) const { return Type; } virtual void writeGotPltHeader(uint8_t *Buf) const {} Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -124,8 +124,6 @@ int64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override; void writeGotPltHeader(uint8_t *Buf) const override; uint32_t getDynRel(uint32_t Type) const override; - bool isTlsLocalDynamicRel(uint32_t Type) const override; - bool isTlsInitialExecRel(uint32_t Type) const override; void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override; void writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const override; void writePltHeader(uint8_t *Buf) const override; @@ -147,8 +145,6 @@ RelExpr getRelExpr(uint32_t Type, const SymbolBody &S, const uint8_t *Loc) const override; bool isPicRel(uint32_t Type) const override; - bool isTlsLocalDynamicRel(uint32_t Type) const override; - bool isTlsInitialExecRel(uint32_t Type) const override; void writeGotPltHeader(uint8_t *Buf) const override; void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override; void writePltHeader(uint8_t *Buf) const override; @@ -193,7 +189,6 @@ RelExpr getRelExpr(uint32_t Type, const SymbolBody &S, const uint8_t *Loc) const override; bool isPicRel(uint32_t Type) const override; - bool isTlsInitialExecRel(uint32_t Type) const override; void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override; void writePltHeader(uint8_t *Buf) const override; void writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, uint64_t PltEntryAddr, @@ -303,10 +298,6 @@ return false; } -bool TargetInfo::isTlsInitialExecRel(uint32_t Type) const { return false; } - -bool TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { return false; } - void TargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const { writeGotPlt(Buf, S); } @@ -451,14 +442,6 @@ return Type; } -bool X86TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { - return Type == R_386_TLS_LDO_32 || Type == R_386_TLS_LDM; -} - -bool X86TargetInfo::isTlsInitialExecRel(uint32_t Type) const { - return Type == R_386_TLS_IE || Type == R_386_TLS_GOTIE; -} - void X86TargetInfo::writePltHeader(uint8_t *Buf) const { if (Config->Pic) { const uint8_t V[] = { @@ -772,17 +755,6 @@ } template -bool X86_64TargetInfo::isTlsInitialExecRel(uint32_t Type) const { - return Type == R_X86_64_GOTTPOFF; -} - -template -bool X86_64TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { - return Type == R_X86_64_DTPOFF32 || Type == R_X86_64_DTPOFF64 || - Type == R_X86_64_TLSLD; -} - -template void X86_64TargetInfo::relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const { // Convert @@ -1383,11 +1355,6 @@ } } -bool AArch64TargetInfo::isTlsInitialExecRel(uint32_t Type) const { - return Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 || - Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC; -} - bool AArch64TargetInfo::isPicRel(uint32_t Type) const { return Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64; }