ELF: Make names for TLS module indices shorter.
authorRui Ueyama <ruiu@google.com>
Fri, 5 Feb 2016 00:10:02 +0000 (00:10 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 5 Feb 2016 00:10:02 +0000 (00:10 +0000)
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

lld/ELF/InputSection.cpp
lld/ELF/OutputSections.cpp
lld/ELF/OutputSections.h
lld/ELF/Writer.cpp

index 1d72968..5c4efb6 100644 (file)
@@ -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;
     }
index 1d33818..22470c1 100644 (file)
@@ -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();
index debb07c..8251de8 100644 (file)
@@ -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;
 
index 1a2fde9..f41c5d3 100644 (file)
@@ -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(