diff options
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r-- | lld/ELF/Driver.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index b77e867eab2..a1b7e55e818 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -80,6 +80,7 @@ bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly, Config = make<Configuration>(); Driver = make<LinkerDriver>(); Script = make<LinkerScript>(); + Symtab = make<SymbolTable>(); Config->Argv = {Args.begin(), Args.end()}; Driver->main(Args, CanExitEarly); @@ -948,8 +949,6 @@ static void excludeLibs(opt::InputArgList &Args, ArrayRef<InputFile *> Files) { // Do actual linking. Note that when this function is called, // all linker scripts have already been parsed. template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { - SymbolTable<ELFT> Symtab; - elf::Symtab<ELFT>::X = &Symtab; Target = getTarget(); Config->MaxPageSize = getMaxPageSize(Args); @@ -979,64 +978,64 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { // Handle --trace-symbol. for (auto *Arg : Args.filtered(OPT_trace_symbol)) - Symtab.trace(Arg->getValue()); + Symtab->trace(Arg->getValue()); // Add all files to the symbol table. This will add almost all // symbols that we need to the symbol table. for (InputFile *F : Files) - Symtab.addFile(F); + Symtab->addFile<ELFT>(F); // If an entry symbol is in a static archive, pull out that file now // to complete the symbol table. After this, no new names except a // few linker-synthesized ones will be added to the symbol table. - if (Symtab.find(Config->Entry)) - Symtab.addUndefined(Config->Entry); + if (Symtab->find(Config->Entry)) + Symtab->addUndefined<ELFT>(Config->Entry); // Return if there were name resolution errors. if (ErrorCount) return; // Handle the `--undefined <sym>` options. - Symtab.scanUndefinedFlags(); + Symtab->scanUndefinedFlags<ELFT>(); // Handle undefined symbols in DSOs. - Symtab.scanShlibUndefined(); + Symtab->scanShlibUndefined<ELFT>(); // Handle the -exclude-libs option. if (Args.hasArg(OPT_exclude_libs)) excludeLibs(Args, Files); // Apply version scripts. - Symtab.scanVersionScript(); + Symtab->scanVersionScript(); // Create wrapped symbols for -wrap option. for (auto *Arg : Args.filtered(OPT_wrap)) - Symtab.addSymbolWrap(Arg->getValue()); + Symtab->addSymbolWrap<ELFT>(Arg->getValue()); // Create alias symbols for -defsym option. for (std::pair<StringRef, StringRef> &Def : getDefsym(Args)) - Symtab.addSymbolAlias(Def.first, Def.second); + Symtab->addSymbolAlias<ELFT>(Def.first, Def.second); - Symtab.addCombinedLTOObject(); + Symtab->addCombinedLTOObject<ELFT>(); if (ErrorCount) return; // 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->Opt.ReferencedSymbols) - Symtab.addUndefined(Sym); + Symtab->addUndefined<ELFT>(Sym); // Apply symbol renames for -wrap and -defsym - Symtab.applySymbolRenames(); + Symtab->applySymbolRenames(); // Now that we have a complete list of input files. // Beyond this point, no new files are added. // Aggregate all input sections into one place. - for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles()) + for (elf::ObjectFile<ELFT> *F : ObjectFile<ELFT>::Instances) for (InputSectionBase *S : F->getSections()) if (S && S != &InputSection::Discarded) InputSections.push_back(S); - for (BinaryFile *F : Symtab.getBinaryFiles()) + for (BinaryFile *F : BinaryFile::Instances) for (InputSectionBase *S : F->getSections()) InputSections.push_back(cast<InputSection>(S)); |