summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-02-05 00:10:02 +0000
committerRui Ueyama <ruiu@google.com>2016-02-05 00:10:02 +0000
commit0e53c7dd2c3e98d05b76687404c3c9821b61fcbf (patch)
tree33ca3ce0e2448b7966f54515513b84d6d77432e7
parenteb7d7f8729cdfc58dd85e81641eb6560f70b7c79 (diff)
downloadbcm5719-llvm-0e53c7dd2c3e98d05b76687404c3c9821b61fcbf.tar.gz
bcm5719-llvm-0e53c7dd2c3e98d05b76687404c3c9821b61fcbf.zip
ELF: Make names for TLS module indices shorter.
The previous names contained "Local" and "Current", but what we are handling is always local and current, so they were redundant. TlsIndex comes from "tls_index" struct that Ulrich Drepper is using in this document to describe this data structure in GOT. llvm-svn: 259852
-rw-r--r--lld/ELF/InputSection.cpp2
-rw-r--r--lld/ELF/OutputSections.cpp10
-rw-r--r--lld/ELF/OutputSections.h6
-rw-r--r--lld/ELF/Writer.cpp6
4 files changed, 13 insertions, 11 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 1d729684fec..5c4efb651cc 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -150,7 +150,7 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd,
if (Target->isTlsLocalDynamicRel(Type) &&
!Target->canRelaxTls(Type, nullptr)) {
Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc,
- Out<ELFT>::Got->getLocalTlsIndexVA() +
+ Out<ELFT>::Got->getTlsIndexVA() +
getAddend<ELFT>(RI));
continue;
}
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 1d338186caf..22470c107ac 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -88,10 +88,12 @@ template <class ELFT> bool GotSection<ELFT>::addDynTlsEntry(SymbolBody *Sym) {
return true;
}
-template <class ELFT> bool GotSection<ELFT>::addCurrentModuleTlsIndex() {
- if (LocalTlsIndexOff != uint32_t(-1))
+// Reserves TLS entries for a TLS module ID and a TLS block offset.
+// In total it takes two GOT slots.
+template <class ELFT> bool GotSection<ELFT>::addTlsIndex() {
+ if (TlsIndexOff != uint32_t(-1))
return false;
- LocalTlsIndexOff = Entries.size() * sizeof(uintX_t);
+ TlsIndexOff = Entries.size() * sizeof(uintX_t);
Entries.push_back(nullptr);
Entries.push_back(nullptr);
return true;
@@ -224,7 +226,7 @@ getOffset(const DynamicReloc<ELFT> &Rel) {
case DynamicReloc<ELFT>::Off_GTlsOffset:
return Out<ELFT>::Got->getGlobalDynAddr(*Sym) + sizeof(uintX_t);
case DynamicReloc<ELFT>::Off_LTlsIndex:
- return Out<ELFT>::Got->getLocalTlsIndexVA();
+ return Out<ELFT>::Got->getTlsIndexVA();
case DynamicReloc<ELFT>::Off_Sec:
return Rel.OffsetSec->getOffset(Rel.OffsetInSec) +
Rel.OffsetSec->OutSec->getVA();
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index debb07cd529..8251de8a60f 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -113,7 +113,7 @@ public:
void addEntry(SymbolBody *Sym);
void addMipsLocalEntry();
bool addDynTlsEntry(SymbolBody *Sym);
- bool addCurrentModuleTlsIndex();
+ bool addTlsIndex();
bool empty() const { return MipsLocalEntries == 0 && Entries.empty(); }
uintX_t getMipsLocalFullAddr(const SymbolBody &B);
uintX_t getMipsLocalPageAddr(uintX_t Addr);
@@ -130,11 +130,11 @@ public:
// the number of reserved entries. This method is MIPS-specific.
unsigned getMipsLocalEntriesNum() const;
- uintX_t getLocalTlsIndexVA() { return Base::getVA() + LocalTlsIndexOff; }
+ uintX_t getTlsIndexVA() { return Base::getVA() + TlsIndexOff; }
private:
std::vector<const SymbolBody *> Entries;
- uint32_t LocalTlsIndexOff = -1;
+ uint32_t TlsIndexOff = -1;
uint32_t MipsLocalEntries = 0;
llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 1a2fde9cbaf..f41c5d3f892 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -218,7 +218,7 @@ static bool handleTlsRelocation(unsigned Type, SymbolBody *Body,
if (Target->isTlsLocalDynamicRel(Type)) {
if (Target->canRelaxTls(Type, nullptr))
return true;
- if (Out<ELFT>::Got->addCurrentModuleTlsIndex())
+ if (Out<ELFT>::Got->addTlsIndex())
Out<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel,
DynamicReloc<ELFT>::Off_LTlsIndex,
nullptr});
@@ -229,8 +229,8 @@ static bool handleTlsRelocation(unsigned Type, SymbolBody *Body,
return false;
if (Target->isTlsGlobalDynamicRel(Type)) {
- bool Opt = Target->canRelaxTls(Type, Body);
- if (!Opt && Out<ELFT>::Got->addDynTlsEntry(Body)) {
+ if (!Target->canRelaxTls(Type, Body) &&
+ Out<ELFT>::Got->addDynTlsEntry(Body)) {
Out<ELFT>::RelaDyn->addReloc(
{Target->TlsModuleIndexRel, DynamicReloc<ELFT>::Off_GTlsIndex, Body});
Out<ELFT>::RelaDyn->addReloc(
OpenPOWER on IntegriCloud