diff options
Diffstat (limited to 'ELF/Target.cpp')
-rw-r--r-- | ELF/Target.cpp | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/ELF/Target.cpp b/ELF/Target.cpp index 921505ae4b61..4643c1a919aa 100644 --- a/ELF/Target.cpp +++ b/ELF/Target.cpp @@ -124,8 +124,6 @@ public: 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 @@ public: 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 @@ public: 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 @@ bool TargetInfo::needsThunk(RelExpr Expr, uint32_t RelocType, 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); } @@ -360,6 +351,15 @@ X86TargetInfo::X86TargetInfo() { RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S, const uint8_t *Loc) const { + // There are 4 different TLS variable models with varying degrees of + // flexibility and performance. LocalExec and InitialExec models are fast but + // less-flexible models. They cannot be used for dlopen(). If they are in use, + // we set DF_STATIC_TLS in the ELF header so that the runtime can reject such + // DSOs. + if (Type == R_386_TLS_LE || Type == R_386_TLS_LE_32 || Type == R_386_TLS_IE || + Type == R_386_TLS_GOTIE) + Config->HasStaticTlsModel = true; + switch (Type) { case R_386_8: case R_386_16: @@ -451,14 +451,6 @@ uint32_t X86TargetInfo::getDynRel(uint32_t Type) const { 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 +764,6 @@ bool X86_64TargetInfo<ELFT>::isPicRel(uint32_t Type) const { } template <class ELFT> -bool X86_64TargetInfo<ELFT>::isTlsInitialExecRel(uint32_t Type) const { - return Type == R_X86_64_GOTTPOFF; -} - -template <class ELFT> -bool X86_64TargetInfo<ELFT>::isTlsLocalDynamicRel(uint32_t Type) const { - return Type == R_X86_64_DTPOFF32 || Type == R_X86_64_DTPOFF64 || - Type == R_X86_64_TLSLD; -} - -template <class ELFT> void X86_64TargetInfo<ELFT>::relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const { // Convert @@ -1383,11 +1364,6 @@ bool AArch64TargetInfo::usesOnlyLowPageBits(uint32_t Type) const { } } -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; } |