Detemplate SymbolTable.

NFC, just makes it easier to access from non templated code.

llvm-svn: 309152
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 81748d5..ba4247e 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -118,7 +118,7 @@
 }
 
 template <class ELFT> static bool needsInterpSection() {
-  return !Symtab<ELFT>::X->getSharedFiles().empty() &&
+  return !SharedFile<ELFT>::Instances.empty() &&
          !Config->DynamicLinker.empty() && !Script->ignoreInterpSection();
 }
 
@@ -318,8 +318,8 @@
   Add(InX::BssRelRo);
 
   // Add MIPS-specific sections.
-  bool HasDynSymTab = !Symtab<ELFT>::X->getSharedFiles().empty() ||
-                      Config->Pic || Config->ExportDynamic;
+  bool HasDynSymTab = !SharedFile<ELFT>::Instances.empty() || Config->Pic ||
+                      Config->ExportDynamic;
   if (Config->EMachine == EM_MIPS) {
     if (!Config->Shared && HasDynSymTab) {
       InX::MipsRldMap = make<MipsRldMapSection>();
@@ -471,7 +471,7 @@
 template <class ELFT> void Writer<ELFT>::copyLocalSymbols() {
   if (!InX::SymTab)
     return;
-  for (elf::ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles()) {
+  for (elf::ObjectFile<ELFT> *F : ObjectFile<ELFT>::Instances) {
     for (SymbolBody *B : F->getLocalSymbols()) {
       if (!B->IsLocal)
         fatal(toString(F) +
@@ -760,16 +760,16 @@
                           uint8_t Binding = STB_WEAK) {
   // The linker generated symbols are added as STB_WEAK to allow user defined
   // ones to override them.
-  return Symtab<ELFT>::X->addRegular(Name, StOther, STT_NOTYPE, Value,
-                                     /*Size=*/0, Binding, Sec,
-                                     /*File=*/nullptr);
+  return Symtab->addRegular<ELFT>(Name, StOther, STT_NOTYPE, Value,
+                                  /*Size=*/0, Binding, Sec,
+                                  /*File=*/nullptr);
 }
 
 template <class ELFT>
 static DefinedRegular *
 addOptionalRegular(StringRef Name, SectionBase *Sec, uint64_t Val,
                    uint8_t StOther = STV_HIDDEN, uint8_t Binding = STB_GLOBAL) {
-  SymbolBody *S = Symtab<ELFT>::X->find(Name);
+  SymbolBody *S = Symtab->find(Name);
   if (!S)
     return nullptr;
   if (S->isInCurrentDSO())
@@ -803,21 +803,21 @@
     // to GOT. Default offset is 0x7ff0.
     // See "Global Data Symbols" in Chapter 6 in the following document:
     // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
-    ElfSym::MipsGp = Symtab<ELFT>::X->addAbsolute("_gp", STV_HIDDEN, STB_LOCAL);
+    ElfSym::MipsGp = Symtab->addAbsolute<ELFT>("_gp", STV_HIDDEN, STB_LOCAL);
 
     // On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
     // start of function and 'gp' pointer into GOT.
-    if (Symtab<ELFT>::X->find("_gp_disp"))
+    if (Symtab->find("_gp_disp"))
       ElfSym::MipsGpDisp =
-          Symtab<ELFT>::X->addAbsolute("_gp_disp", STV_HIDDEN, STB_LOCAL);
+          Symtab->addAbsolute<ELFT>("_gp_disp", STV_HIDDEN, STB_LOCAL);
 
     // The __gnu_local_gp is a magic symbol equal to the current value of 'gp'
     // pointer. This symbol is used in the code generated by .cpload pseudo-op
     // in case of using -mno-shared option.
     // https://sourceware.org/ml/binutils/2004-12/msg00094.html
-    if (Symtab<ELFT>::X->find("__gnu_local_gp"))
+    if (Symtab->find("__gnu_local_gp"))
       ElfSym::MipsLocalGp =
-          Symtab<ELFT>::X->addAbsolute("__gnu_local_gp", STV_HIDDEN, STB_LOCAL);
+          Symtab->addAbsolute<ELFT>("__gnu_local_gp", STV_HIDDEN, STB_LOCAL);
   }
 
   // The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention to
@@ -833,7 +833,7 @@
   // __tls_get_addr, so it's not defined anywhere. Create a hidden definition
   // to avoid the undefined symbol error.
   if (!InX::DynSymTab)
-    Symtab<ELFT>::X->addIgnored("__tls_get_addr");
+    Symtab->addIgnored<ELFT>("__tls_get_addr");
 
   // __ehdr_start is the location of ELF file headers. Note that we define
   // this symbol unconditionally even when using a linker script, which
@@ -893,7 +893,7 @@
 
   // Build a map from sections to their priorities.
   DenseMap<SectionBase *, int> SectionOrder;
-  for (elf::ObjectFile<ELFT> *File : Symtab<ELFT>::X->getObjectFiles()) {
+  for (elf::ObjectFile<ELFT> *File : ObjectFile<ELFT>::Instances) {
     for (SymbolBody *Body : File->getSymbols()) {
       auto *D = dyn_cast<DefinedRegular>(Body);
       if (!D || !D->Section)
@@ -1224,7 +1224,7 @@
 
   // Now that we have defined all possible global symbols including linker-
   // synthesized ones. Visit all symbols to give the finishing touches.
-  for (Symbol *S : Symtab<ELFT>::X->getSymbols()) {
+  for (Symbol *S : Symtab->getSymbols()) {
     SymbolBody *Body = S->body();
 
     if (!includeInSymtab(*Body))
@@ -1689,7 +1689,7 @@
 template <class ELFT> uint64_t Writer<ELFT>::getEntryAddr() {
   // Case 1, 2 or 3. As a special case, if the symbol is actually
   // a number, we'll use that number as an address.
-  if (SymbolBody *B = Symtab<ELFT>::X->find(Config->Entry))
+  if (SymbolBody *B = Symtab->find(Config->Entry))
     return B->getVA();
   uint64_t Addr;
   if (to_integer(Config->Entry, Addr))