summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-04-20 14:52:18 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-04-20 14:52:18 +0000
commitf54413c18e7dc3933d3aa2d16e82a835ae2b96ad (patch)
treec93733a17ca3fd4401966ec522e1828dccaa47eb
parentcc36a63f0bbdf0c43a3f93a479453467514a3180 (diff)
downloadbcm5719-llvm-f54413c18e7dc3933d3aa2d16e82a835ae2b96ad.tar.gz
bcm5719-llvm-f54413c18e7dc3933d3aa2d16e82a835ae2b96ad.zip
Simplify canRelaxTls.
Check isTls in the called and pass a SymbolBody&. llvm-svn: 266879
-rw-r--r--lld/ELF/Writer.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index c7c714a5168..41ef156f6eb 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -273,8 +273,8 @@ template <bool Is64Bits> struct DenseMapInfo<SectionKey<Is64Bits>> {
};
}
-static bool canRelaxTls(uint32_t Type, const SymbolBody *S) {
- if (Config->Shared || (S && !S->isTls()))
+static bool canRelaxTls(uint32_t Type, const SymbolBody &S) {
+ if (Config->Shared)
return false;
// We know we are producing an executable.
@@ -291,7 +291,7 @@ static bool canRelaxTls(uint32_t Type, const SymbolBody *S) {
// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
// defined.
if (Target->isTlsInitialExecRel(Type))
- return !S->isPreemptible();
+ return !S.isPreemptible();
return false;
}
@@ -305,9 +305,12 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body,
if (!(C.getSectionHdr()->sh_flags & SHF_ALLOC))
return 0;
+ if (!Body.isTls())
+ return 0;
+
typedef typename ELFT::uint uintX_t;
if (Expr == R_TLSLD_PC || Expr == R_TLSLD) {
- if (canRelaxTls(Type, nullptr)) {
+ if (canRelaxTls(Type, Body)) {
C.Relocations.push_back(
{R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body});
return 2;
@@ -320,17 +323,14 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body,
return 1;
}
- if (!Body.isTls())
- return 0;
-
- if (Target->isTlsLocalDynamicRel(Type) && canRelaxTls(Type, nullptr)) {
+ if (Target->isTlsLocalDynamicRel(Type) && canRelaxTls(Type, Body)) {
C.Relocations.push_back(
{R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body});
return 1;
}
if (Target->isTlsGlobalDynamicRel(Type)) {
- if (!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(
@@ -359,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) && 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;
OpenPOWER on IntegriCloud