[lld] r320324 - Move RelaDyn to InX. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 10 11:44:42 PST 2017


Author: rafael
Date: Sun Dec 10 11:44:42 2017
New Revision: 320324

URL: http://llvm.org/viewvc/llvm-project?rev=320324&view=rev
Log:
Move RelaDyn to InX. NFC.

Modified:
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/SyntheticSections.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=320324&r1=320323&r2=320324&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Sun Dec 10 11:44:42 2017
@@ -114,9 +114,9 @@ static unsigned handleMipsTlsRelocation(
                                         int64_t Addend, RelExpr Expr) {
   if (Expr == R_MIPS_TLSLD) {
     if (InX::MipsGot->addTlsIndex() && Config->Pic)
-      In<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::MipsGot,
-                                   InX::MipsGot->getTlsIndexOff(), false,
-                                   nullptr, 0});
+      InX::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::MipsGot,
+                              InX::MipsGot->getTlsIndexOff(), false, nullptr,
+                              0});
     C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     return 1;
   }
@@ -124,11 +124,11 @@ static unsigned handleMipsTlsRelocation(
   if (Expr == R_MIPS_TLSGD) {
     if (InX::MipsGot->addDynTlsEntry(Sym) && Sym.IsPreemptible) {
       uint64_t Off = InX::MipsGot->getGlobalDynOffset(Sym);
-      In<ELFT>::RelaDyn->addReloc(
+      InX::RelaDyn->addReloc(
           {Target->TlsModuleIndexRel, InX::MipsGot, Off, false, &Sym, 0});
       if (Sym.IsPreemptible)
-        In<ELFT>::RelaDyn->addReloc({Target->TlsOffsetRel, InX::MipsGot,
-                                     Off + Config->Wordsize, false, &Sym, 0});
+        InX::RelaDyn->addReloc({Target->TlsOffsetRel, InX::MipsGot,
+                                Off + Config->Wordsize, false, &Sym, 0});
     }
     C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     return 1;
@@ -162,7 +162,7 @@ static unsigned handleARMTlsRelocation(R
 
   auto AddTlsReloc = [&](uint64_t Off, RelType Type, Symbol *Dest, bool Dyn) {
     if (Dyn)
-      In<ELFT>::RelaDyn->addReloc({Type, InX::Got, Off, false, Dest, 0});
+      InX::RelaDyn->addReloc({Type, InX::Got, Off, false, Dest, 0});
     else
       InX::Got->Relocations.push_back({R_ABS, Type, Off, 0, Dest});
   };
@@ -214,7 +214,7 @@ handleTlsRelocation(RelType Type, Symbol
       Config->Shared) {
     if (InX::Got->addDynTlsEntry(Sym)) {
       uint64_t Off = InX::Got->getGlobalDynOffset(Sym);
-      In<ELFT>::RelaDyn->addReloc(
+      InX::RelaDyn->addReloc(
           {Target->TlsDescRel, InX::Got, Off, !Sym.IsPreemptible, &Sym, 0});
     }
     if (Expr != R_TLSDESC_CALL)
@@ -230,9 +230,8 @@ handleTlsRelocation(RelType Type, Symbol
       return 2;
     }
     if (InX::Got->addTlsIndex())
-      In<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::Got,
-                                   InX::Got->getTlsIndexOff(), false, nullptr,
-                                   0});
+      InX::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::Got,
+                              InX::Got->getTlsIndexOff(), false, nullptr, 0});
     C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     return 1;
   }
@@ -248,14 +247,14 @@ handleTlsRelocation(RelType Type, Symbol
     if (Config->Shared) {
       if (InX::Got->addDynTlsEntry(Sym)) {
         uint64_t Off = InX::Got->getGlobalDynOffset(Sym);
-        In<ELFT>::RelaDyn->addReloc(
+        InX::RelaDyn->addReloc(
             {Target->TlsModuleIndexRel, InX::Got, Off, false, &Sym, 0});
 
         // If the symbol is preemptible we need the dynamic linker to write
         // the offset too.
         uint64_t OffsetOff = Off + Config->Wordsize;
         if (Sym.IsPreemptible)
-          In<ELFT>::RelaDyn->addReloc(
+          InX::RelaDyn->addReloc(
               {Target->TlsOffsetRel, InX::Got, OffsetOff, false, &Sym, 0});
         else
           InX::Got->Relocations.push_back(
@@ -273,7 +272,7 @@ handleTlsRelocation(RelType Type, Symbol
            Offset, Addend, &Sym});
       if (!Sym.isInGot()) {
         InX::Got->addEntry(Sym);
-        In<ELFT>::RelaDyn->addReloc(
+        InX::RelaDyn->addReloc(
             {Target->TlsGotRel, InX::Got, Sym.getGotOffset(), false, &Sym, 0});
       }
     } else {
@@ -545,7 +544,7 @@ template <class ELFT> static void addCop
     Sym->Used = true;
   }
 
-  In<ELFT>::RelaDyn->addReloc({Target->CopyRel, Sec, 0, false, SS, 0});
+  InX::RelaDyn->addReloc({Target->CopyRel, Sec, 0, false, SS, 0});
 }
 
 static void errorOrWarn(const Twine &Msg) {
@@ -839,7 +838,7 @@ template <class ELFT> static void addGot
     Type = Target->RelativeRel;
   else
     Type = Target->GotRel;
-  In<ELFT>::RelaDyn->addReloc({Type, InX::Got, Off, !Preemptible, &Sym, 0});
+  InX::RelaDyn->addReloc({Type, InX::Got, Off, !Preemptible, &Sym, 0});
 
   // REL type relocations don't have addend fields unlike RELAs, and
   // their addends are stored to the section to which they are applied.
@@ -967,8 +966,8 @@ static void scanRelocs(InputSectionBase
         // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
         InX::MipsGot->addEntry(Sym, Addend, Expr);
         if (Sym.isTls() && Sym.IsPreemptible)
-          In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, InX::MipsGot,
-                                       Sym.getGotOffset(), false, &Sym, 0});
+          InX::RelaDyn->addReloc({Target->TlsGotRel, InX::MipsGot,
+                                  Sym.getGotOffset(), false, &Sym, 0});
       } else if (!Sym.isInGot()) {
         addGotEntry<ELFT>(Sym, Preemptible);
       }
@@ -983,7 +982,7 @@ static void scanRelocs(InputSectionBase
             " cannot be used against shared object; recompile with -fPIC" +
             getLocation<ELFT>(Sec, Sym, Offset));
 
-      In<ELFT>::RelaDyn->addReloc(
+      InX::RelaDyn->addReloc(
           {Target->getDynRel(Type), &Sec, Offset, false, &Sym, Addend});
 
       // MIPS ABI turns using of GOT and dynamic relocations inside out.
@@ -1028,11 +1027,11 @@ static void scanRelocs(InputSectionBase
     // relocation. We can process some of it and and just ask the dynamic
     // linker to add the load address.
     if (Config->IsRela) {
-      In<ELFT>::RelaDyn->addReloc(
+      InX::RelaDyn->addReloc(
           {Target->RelativeRel, &Sec, Offset, true, &Sym, Addend});
     } else {
       // In REL, addends are stored to the target section.
-      In<ELFT>::RelaDyn->addReloc(
+      InX::RelaDyn->addReloc(
           {Target->RelativeRel, &Sec, Offset, true, &Sym, 0});
       Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     }

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=320324&r1=320323&r2=320324&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Sun Dec 10 11:44:42 2017
@@ -1078,9 +1078,9 @@ template <class ELFT> void DynamicSectio
     return; // Already finalized.
 
   this->Link = InX::DynStrTab->getParent()->SectionIndex;
-  if (In<ELFT>::RelaDyn->getParent() && !In<ELFT>::RelaDyn->empty()) {
-    addInSec(In<ELFT>::RelaDyn->DynamicTag, In<ELFT>::RelaDyn);
-    addSize(In<ELFT>::RelaDyn->SizeDynamicTag, In<ELFT>::RelaDyn->getParent());
+  if (InX::RelaDyn->getParent() && !InX::RelaDyn->empty()) {
+    addInSec(InX::RelaDyn->DynamicTag, InX::RelaDyn);
+    addSize(InX::RelaDyn->SizeDynamicTag, InX::RelaDyn->getParent());
 
     bool IsRela = Config->IsRela;
     addInt(IsRela ? DT_RELAENT : DT_RELENT,
@@ -1090,7 +1090,7 @@ template <class ELFT> void DynamicSectio
     // The problem is in the tight relation between dynamic
     // relocations and GOT. So do not emit this tag on MIPS.
     if (Config->EMachine != EM_MIPS) {
-      size_t NumRelativeRels = In<ELFT>::RelaDyn->getRelativeRelocCount();
+      size_t NumRelativeRels = InX::RelaDyn->getRelativeRelocCount();
       if (Config->ZCombreloc && NumRelativeRels)
         addInt(IsRela ? DT_RELACOUNT : DT_RELCOUNT, NumRelativeRels);
     }
@@ -2633,6 +2633,7 @@ MipsGotSection *InX::MipsGot;
 MipsRldMapSection *InX::MipsRldMap;
 PltSection *InX::Plt;
 PltSection *InX::Iplt;
+RelocationBaseSection *InX::RelaDyn;
 StringTableSection *InX::ShStrTab;
 StringTableSection *InX::StrTab;
 SymbolTableBaseSection *InX::SymTab;

Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=320324&r1=320323&r2=320324&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Sun Dec 10 11:44:42 2017
@@ -840,13 +840,13 @@ struct InX {
   static MipsRldMapSection *MipsRldMap;
   static PltSection *Plt;
   static PltSection *Iplt;
+  static RelocationBaseSection *RelaDyn;
   static StringTableSection *ShStrTab;
   static StringTableSection *StrTab;
   static SymbolTableBaseSection *SymTab;
 };
 
 template <class ELFT> struct In {
-  static RelocationBaseSection *RelaDyn;
   static RelocationSection<ELFT> *RelaPlt;
   static RelocationSection<ELFT> *RelaIplt;
   static VersionDefinitionSection<ELFT> *VerDef;
@@ -854,7 +854,6 @@ template <class ELFT> struct In {
   static VersionNeedSection<ELFT> *VerNeed;
 };
 
-template <class ELFT> RelocationBaseSection *In<ELFT>::RelaDyn;
 template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaPlt;
 template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaIplt;
 template <class ELFT> VersionDefinitionSection<ELFT> *In<ELFT>::VerDef;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=320324&r1=320323&r2=320324&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Dec 10 11:44:42 2017
@@ -252,10 +252,10 @@ template <class ELFT> static void create
   InX::DynStrTab = make<StringTableSection>(".dynstr", true);
   InX::Dynamic = make<DynamicSection<ELFT>>();
   if (Config->AndroidPackDynRelocs) {
-    In<ELFT>::RelaDyn = make<AndroidPackedRelocationSection<ELFT>>(
+    InX::RelaDyn = make<AndroidPackedRelocationSection<ELFT>>(
         Config->IsRela ? ".rela.dyn" : ".rel.dyn");
   } else {
-    In<ELFT>::RelaDyn = make<RelocationSection<ELFT>>(
+    InX::RelaDyn = make<RelocationSection<ELFT>>(
         Config->IsRela ? ".rela.dyn" : ".rel.dyn", Config->ZCombreloc);
   }
   InX::ShStrTab = make<StringTableSection>(".shstrtab", false);
@@ -335,7 +335,7 @@ template <class ELFT> static void create
 
     Add(InX::Dynamic);
     Add(InX::DynStrTab);
-    Add(In<ELFT>::RelaDyn);
+    Add(InX::RelaDyn);
   }
 
   // Add .got. MIPS' .got is so different from the other archs,
@@ -1343,15 +1343,14 @@ template <class ELFT> void Writer<ELFT>:
 
   // Dynamic section must be the last one in this list and dynamic
   // symbol table section (DynSymTab) must be the first one.
-  applySynthetic({InX::DynSymTab,     InX::Bss,          InX::BssRelRo,
-                  InX::GnuHashTab,    InX::HashTab,      InX::SymTab,
-                  InX::ShStrTab,      InX::StrTab,       In<ELFT>::VerDef,
-                  InX::DynStrTab,     InX::Got,          InX::MipsGot,
-                  InX::IgotPlt,       InX::GotPlt,       In<ELFT>::RelaDyn,
-                  In<ELFT>::RelaIplt, In<ELFT>::RelaPlt, InX::Plt,
-                  InX::Iplt,          InX::EhFrameHdr,   In<ELFT>::VerSym,
-                  In<ELFT>::VerNeed,  InX::Dynamic},
-                 [](SyntheticSection *SS) { SS->finalizeContents(); });
+  applySynthetic(
+      {InX::DynSymTab,    InX::Bss,          InX::BssRelRo, InX::GnuHashTab,
+       InX::HashTab,      InX::SymTab,       InX::ShStrTab, InX::StrTab,
+       In<ELFT>::VerDef,  InX::DynStrTab,    InX::Got,      InX::MipsGot,
+       InX::IgotPlt,      InX::GotPlt,       InX::RelaDyn,  In<ELFT>::RelaIplt,
+       In<ELFT>::RelaPlt, InX::Plt,          InX::Iplt,     InX::EhFrameHdr,
+       In<ELFT>::VerSym,  In<ELFT>::VerNeed, InX::Dynamic},
+      [](SyntheticSection *SS) { SS->finalizeContents(); });
 
   if (!Script->HasSectionsCommand && !Config->Relocatable)
     fixSectionAlignments();
@@ -1376,7 +1375,7 @@ template <class ELFT> void Writer<ELFT>:
       }
       if (InX::MipsGot)
         InX::MipsGot->updateAllocSize();
-      Changed |= In<ELFT>::RelaDyn->updateAllocSize();
+      Changed |= InX::RelaDyn->updateAllocSize();
     } while (Changed);
   }
 




More information about the llvm-commits mailing list