[lld] r344290 - Remove SymbolTable::addUndefined<ELF32LE>(StringRef).

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 11 13:34:29 PDT 2018


Author: ruiu
Date: Thu Oct 11 13:34:29 2018
New Revision: 344290

URL: http://llvm.org/viewvc/llvm-project?rev=344290&view=rev
Log:
Remove SymbolTable::addUndefined<ELF32LE>(StringRef).

Because we can implement the function as a non-member function.

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/SymbolTable.h

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=344290&r1=344289&r2=344290&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Oct 11 13:34:29 2018
@@ -1342,6 +1342,11 @@ static void findKeepUniqueSections(opt::
   }
 }
 
+template <class ELFT> static Symbol *addUndefined(StringRef Name) {
+  return Symtab->addUndefined<ELFT>(Name, STB_GLOBAL, STV_DEFAULT, 0, false,
+                                    nullptr);
+}
+
 // The --wrap option is a feature to rename symbols so that you can write
 // wrappers for existing functions. If you pass `-wrap=foo`, all
 // occurrences of symbol `foo` are resolved to `wrap_foo` (so, you are
@@ -1375,8 +1380,8 @@ static std::vector<WrappedSymbol> addWra
     if (!Sym)
       continue;
 
-    Symbol *Real = Symtab->addUndefined<ELFT>(Saver.save("__real_" + Name));
-    Symbol *Wrap = Symtab->addUndefined<ELFT>(Saver.save("__wrap_" + Name));
+    Symbol *Real = addUndefined<ELFT>(Saver.save("__real_" + Name));
+    Symbol *Wrap = addUndefined<ELFT>(Saver.save("__wrap_" + Name));
     V.push_back({Sym, Real, Wrap});
 
     // We want to tell LTO not to inline symbols to be overwritten
@@ -1483,8 +1488,8 @@ template <class ELFT> void LinkerDriver:
 
   // Some symbols (such as __ehdr_start) are defined lazily only when there
   // are undefined symbols for them, so we add these to trigger that logic.
-  for (StringRef Sym : Script->ReferencedSymbols)
-    Symtab->addUndefined<ELFT>(Sym);
+  for (StringRef Name : Script->ReferencedSymbols)
+    addUndefined<ELFT>(Name);
 
   // Handle the `--undefined <sym>` options.
   for (StringRef S : Config->Undefined)

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=344290&r1=344289&r2=344290&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Oct 11 13:34:29 2018
@@ -241,12 +241,6 @@ std::pair<Symbol *, bool> SymbolTable::i
   return {S, WasInserted};
 }
 
-template <class ELFT> Symbol *SymbolTable::addUndefined(StringRef Name) {
-  return addUndefined<ELFT>(Name, STB_GLOBAL, STV_DEFAULT,
-                            /*Type*/ 0,
-                            /*CanOmitFromDynSym*/ false, /*File*/ nullptr);
-}
-
 static uint8_t getVisibility(uint8_t StOther) { return StOther & 3; }
 
 template <class ELFT>
@@ -779,11 +773,6 @@ template void SymbolTable::addFile<ELF32
 template void SymbolTable::addFile<ELF64LE>(InputFile *);
 template void SymbolTable::addFile<ELF64BE>(InputFile *);
 
-template Symbol *SymbolTable::addUndefined<ELF32LE>(StringRef);
-template Symbol *SymbolTable::addUndefined<ELF32BE>(StringRef);
-template Symbol *SymbolTable::addUndefined<ELF64LE>(StringRef);
-template Symbol *SymbolTable::addUndefined<ELF64BE>(StringRef);
-
 template Symbol *SymbolTable::addUndefined<ELF32LE>(StringRef, uint8_t, uint8_t,
                                                     uint8_t, bool, InputFile *);
 template Symbol *SymbolTable::addUndefined<ELF32BE>(StringRef, uint8_t, uint8_t,

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=344290&r1=344289&r2=344290&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Thu Oct 11 13:34:29 2018
@@ -45,10 +45,10 @@ public:
                        uint8_t Visibility = llvm::ELF::STV_HIDDEN,
                        uint8_t Binding = llvm::ELF::STB_GLOBAL);
 
-  template <class ELFT> Symbol *addUndefined(StringRef Name);
   template <class ELFT>
   Symbol *addUndefined(StringRef Name, uint8_t Binding, uint8_t StOther,
                        uint8_t Type, bool CanOmitFromDynSym, InputFile *File);
+
   Symbol *addRegular(StringRef Name, uint8_t StOther, uint8_t Type,
                      uint64_t Value, uint64_t Size, uint8_t Binding,
                      SectionBase *Section, InputFile *File);




More information about the llvm-commits mailing list