[lld] r259852 - ELF: Make names for TLS module indices shorter.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 4 16:10:03 PST 2016


Author: ruiu
Date: Thu Feb  4 18:10:02 2016
New Revision: 259852

URL: http://llvm.org/viewvc/llvm-project?rev=259852&view=rev
Log:
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.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=259852&r1=259851&r2=259852&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Feb  4 18:10:02 2016
@@ -150,7 +150,7 @@ void InputSectionBase<ELFT>::relocate(ui
     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;
     }

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259852&r1=259851&r2=259852&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Feb  4 18:10:02 2016
@@ -88,10 +88,12 @@ template <class ELFT> bool GotSection<EL
   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();

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=259852&r1=259851&r2=259852&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Thu Feb  4 18:10:02 2016
@@ -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;
 

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259852&r1=259851&r2=259852&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Feb  4 18:10:02 2016
@@ -218,7 +218,7 @@ static bool handleTlsRelocation(unsigned
   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
     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(




More information about the llvm-commits mailing list