From: Rui Ueyama Date: Fri, 5 Feb 2016 00:10:02 +0000 (+0000) Subject: ELF: Make names for TLS module indices shorter. X-Git-Tag: llvmorg-3.9.0-rc1~15053 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e53c7dd2c3e98d05b76687404c3c9821b61fcbf;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 1d72968..5c4efb6 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -150,7 +150,7 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, if (Target->isTlsLocalDynamicRel(Type) && !Target->canRelaxTls(Type, nullptr)) { Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc, - Out::Got->getLocalTlsIndexVA() + + Out::Got->getTlsIndexVA() + getAddend(RI)); continue; } diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 1d33818..22470c1 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -88,10 +88,12 @@ template bool GotSection::addDynTlsEntry(SymbolBody *Sym) { return true; } -template bool GotSection::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 bool GotSection::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 &Rel) { case DynamicReloc::Off_GTlsOffset: return Out::Got->getGlobalDynAddr(*Sym) + sizeof(uintX_t); case DynamicReloc::Off_LTlsIndex: - return Out::Got->getLocalTlsIndexVA(); + return Out::Got->getTlsIndexVA(); case DynamicReloc::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 debb07c..8251de8 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 Entries; - uint32_t LocalTlsIndexOff = -1; + uint32_t TlsIndexOff = -1; uint32_t MipsLocalEntries = 0; llvm::DenseMap MipsLocalGotPos; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 1a2fde9..f41c5d3 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::Got->addCurrentModuleTlsIndex()) + if (Out::Got->addTlsIndex()) Out::RelaDyn->addReloc({Target->TlsModuleIndexRel, DynamicReloc::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::Got->addDynTlsEntry(Body)) { + if (!Target->canRelaxTls(Type, Body) && + Out::Got->addDynTlsEntry(Body)) { Out::RelaDyn->addReloc( {Target->TlsModuleIndexRel, DynamicReloc::Off_GTlsIndex, Body}); Out::RelaDyn->addReloc(