[lld] r249636 - ELF2: Initialize SyntheticOptional only once.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 16:46:11 PDT 2015


Author: ruiu
Date: Wed Oct  7 18:46:11 2015
New Revision: 249636

URL: http://llvm.org/viewvc/llvm-project?rev=249636&view=rev
Log:
ELF2: Initialize SyntheticOptional only once.

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

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=249636&r1=249635&r2=249636&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Oct  7 18:46:11 2015
@@ -147,6 +147,8 @@ getString(opt::InputArgList &Args, unsig
 }
 
 void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
+  initSymbols();
+
   // Parse command line options.
   opt::InputArgList Args = Parser.parse(ArgsArr);
 

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=249636&r1=249635&r2=249636&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Oct  7 18:46:11 2015
@@ -90,7 +90,6 @@ void SymbolTable::addUndefinedSym(String
 }
 
 template <class ELFT> void SymbolTable::addUndefinedSym(StringRef Name) {
-  Undefined<ELFT>::SyntheticOptional.setVisibility(STV_HIDDEN);
   resolve<ELFT>(new (Alloc)
                     Undefined<ELFT>(Name, Undefined<ELFT>::SyntheticOptional));
 }

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=249636&r1=249635&r2=249636&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Wed Oct  7 18:46:11 2015
@@ -86,6 +86,13 @@ std::unique_ptr<InputFile> Lazy::getMemb
   return createELFFile<ObjectFile>(MBRef);
 }
 
+void lld::elf2::initSymbols() {
+  Undefined<ELF32LE>::SyntheticOptional.setVisibility(STV_HIDDEN);
+  Undefined<ELF32BE>::SyntheticOptional.setVisibility(STV_HIDDEN);
+  Undefined<ELF64LE>::SyntheticOptional.setVisibility(STV_HIDDEN);
+  Undefined<ELF64BE>::SyntheticOptional.setVisibility(STV_HIDDEN);
+}
+
 template int SymbolBody::compare<ELF32LE>(SymbolBody *Other);
 template int SymbolBody::compare<ELF32BE>(SymbolBody *Other);
 template int SymbolBody::compare<ELF64LE>(SymbolBody *Other);

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=249636&r1=249635&r2=249636&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Wed Oct  7 18:46:11 2015
@@ -25,6 +25,10 @@ class SymbolBody;
 template <class ELFT> class ObjectFile;
 template <class ELFT> class OutputSection;
 
+// Initializes global objects defined in this file.
+// Called at the beginning of main().
+void initSymbols();
+
 // A real symbol object, SymbolBody, is usually accessed indirectly
 // through a Symbol. There's always one Symbol for each symbol name.
 // The resolver updates SymbolBody pointers as it resolves symbols.




More information about the llvm-commits mailing list