diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-04-20 14:41:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-04-20 14:41:55 +0000 |
commit | cc36a63f0bbdf0c43a3f93a479453467514a3180 (patch) | |
tree | f124f505f189db45d03587b9286cb6f3fe697642 | |
parent | b35cc691ea93d9408f76736170359fd7ce604b53 (diff) | |
download | bcm5719-llvm-cc36a63f0bbdf0c43a3f93a479453467514a3180.tar.gz bcm5719-llvm-cc36a63f0bbdf0c43a3f93a479453467514a3180.zip |
Move canRelaxTls to Writer.cpp. NFC.
llvm-svn: 266878
-rw-r--r-- | lld/ELF/Target.cpp | 23 | ||||
-rw-r--r-- | lld/ELF/Target.h | 1 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 32 |
3 files changed, 27 insertions, 29 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 98c7a255a4c..c32a6ddea32 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -228,29 +228,6 @@ uint64_t TargetInfo::getImplicitAddend(const uint8_t *Buf, return 0; } -bool TargetInfo::canRelaxTls(uint32_t Type, const SymbolBody *S) const { - if (Config->Shared || (S && !S->isTls())) - return false; - - // We know we are producing an executable. - - // Global-Dynamic relocs can be relaxed to Initial-Exec or Local-Exec - // depending on the symbol being locally defined or not. - if (isTlsGlobalDynamicRel(Type)) - return true; - - // Local-Dynamic relocs can be relaxed to Local-Exec. - if (isTlsLocalDynamicRel(Type)) - return true; - - // Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally - // defined. - if (isTlsInitialExecRel(Type)) - return !S->isPreemptible(); - - return false; -} - uint64_t TargetInfo::getVAStart() const { return Config->Pic ? 0 : VAStart; } bool TargetInfo::needsCopyRelImpl(uint32_t Type) const { return false; } diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index b8e6ea32ba7..ac7319f391f 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -67,7 +67,6 @@ public: virtual RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const = 0; virtual void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const = 0; - bool canRelaxTls(uint32_t Type, const SymbolBody *S) const; template <class ELFT> bool needsCopyRel(uint32_t Type, const SymbolBody &S) const; virtual ~TargetInfo(); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 9cbe4ff12e2..c7c714a5168 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -273,6 +273,29 @@ template <bool Is64Bits> struct DenseMapInfo<SectionKey<Is64Bits>> { }; } +static bool canRelaxTls(uint32_t Type, const SymbolBody *S) { + if (Config->Shared || (S && !S->isTls())) + return false; + + // We know we are producing an executable. + + // Global-Dynamic relocs can be relaxed to Initial-Exec or Local-Exec + // depending on the symbol being locally defined or not. + if (Target->isTlsGlobalDynamicRel(Type)) + return true; + + // Local-Dynamic relocs can be relaxed to Local-Exec. + if (Target->isTlsLocalDynamicRel(Type)) + return true; + + // Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally + // defined. + if (Target->isTlsInitialExecRel(Type)) + return !S->isPreemptible(); + + return false; +} + // Returns the number of relocations processed. template <class ELFT> static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, @@ -284,7 +307,7 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, typedef typename ELFT::uint uintX_t; if (Expr == R_TLSLD_PC || Expr == R_TLSLD) { - if (Target->canRelaxTls(Type, nullptr)) { + if (canRelaxTls(Type, nullptr)) { C.Relocations.push_back( {R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body}); return 2; @@ -300,15 +323,14 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, if (!Body.isTls()) return 0; - if (Target->isTlsLocalDynamicRel(Type) && - Target->canRelaxTls(Type, nullptr)) { + if (Target->isTlsLocalDynamicRel(Type) && canRelaxTls(Type, nullptr)) { C.Relocations.push_back( {R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body}); return 1; } if (Target->isTlsGlobalDynamicRel(Type)) { - if (!Target->canRelaxTls(Type, &Body)) { + if (!canRelaxTls(Type, &Body)) { if (Out<ELFT>::Got->addDynTlsEntry(Body)) { uintX_t Off = Out<ELFT>::Got->getGlobalDynOffset(Body); Out<ELFT>::RelaDyn->addReloc( @@ -337,7 +359,7 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, {R_RELAX_TLS_GD_TO_LE, Type, Offset, Addend, &Body}); return Target->TlsGdToLeSkip; } - if (Target->isTlsInitialExecRel(Type) && Target->canRelaxTls(Type, &Body)) { + if (Target->isTlsInitialExecRel(Type) && canRelaxTls(Type, &Body)) { C.Relocations.push_back( {R_RELAX_TLS_IE_TO_LE, Type, Offset, Addend, &Body}); return 1; |