[lld] r266878 - Move canRelaxTls to Writer.cpp. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 20 07:41:56 PDT 2016
Author: rafael
Date: Wed Apr 20 09:41:55 2016
New Revision: 266878
URL: http://llvm.org/viewvc/llvm-project?rev=266878&view=rev
Log:
Move canRelaxTls to Writer.cpp. NFC.
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=266878&r1=266877&r2=266878&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Wed Apr 20 09:41:55 2016
@@ -228,29 +228,6 @@ uint64_t TargetInfo::getImplicitAddend(c
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; }
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=266878&r1=266877&r2=266878&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Wed Apr 20 09:41:55 2016
@@ -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();
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=266878&r1=266877&r2=266878&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Apr 20 09:41:55 2016
@@ -273,6 +273,29 @@ template <bool Is64Bits> struct DenseMap
};
}
+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(uint
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(uint
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(uint
{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;
More information about the llvm-commits
mailing list