ELF2: Initialize SyntheticOptional only once.

llvm-svn: 249636
This commit is contained in:
Rui Ueyama 2015-10-07 23:46:11 +00:00
parent e66e001c90
commit 9ea49c7948
4 changed files with 13 additions and 1 deletions

View File

@ -147,6 +147,8 @@ getString(opt::InputArgList &Args, unsigned Key, StringRef Default = "") {
} }
void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
initSymbols();
// Parse command line options. // Parse command line options.
opt::InputArgList Args = Parser.parse(ArgsArr); opt::InputArgList Args = Parser.parse(ArgsArr);

View File

@ -90,7 +90,6 @@ void SymbolTable::addUndefinedSym(StringRef Name) {
} }
template <class ELFT> void SymbolTable::addUndefinedSym(StringRef Name) { template <class ELFT> void SymbolTable::addUndefinedSym(StringRef Name) {
Undefined<ELFT>::SyntheticOptional.setVisibility(STV_HIDDEN);
resolve<ELFT>(new (Alloc) resolve<ELFT>(new (Alloc)
Undefined<ELFT>(Name, Undefined<ELFT>::SyntheticOptional)); Undefined<ELFT>(Name, Undefined<ELFT>::SyntheticOptional));
} }

View File

@ -86,6 +86,13 @@ std::unique_ptr<InputFile> Lazy::getMember() {
return createELFFile<ObjectFile>(MBRef); 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<ELF32LE>(SymbolBody *Other);
template int SymbolBody::compare<ELF32BE>(SymbolBody *Other); template int SymbolBody::compare<ELF32BE>(SymbolBody *Other);
template int SymbolBody::compare<ELF64LE>(SymbolBody *Other); template int SymbolBody::compare<ELF64LE>(SymbolBody *Other);

View File

@ -25,6 +25,10 @@ class SymbolBody;
template <class ELFT> class ObjectFile; template <class ELFT> class ObjectFile;
template <class ELFT> class OutputSection; 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 // A real symbol object, SymbolBody, is usually accessed indirectly
// through a Symbol. There's always one Symbol for each symbol name. // through a Symbol. There's always one Symbol for each symbol name.
// The resolver updates SymbolBody pointers as it resolves symbols. // The resolver updates SymbolBody pointers as it resolves symbols.