Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lld/ELF/Driver.cpp
Show First 20 Lines • Show All 963 Lines • ▼ Show 20 Lines | template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { | ||||
// Return if there were name resolution errors. | // Return if there were name resolution errors. | ||||
if (ErrorCount) | if (ErrorCount) | ||||
return; | return; | ||||
Symtab.scanUndefinedFlags(); | Symtab.scanUndefinedFlags(); | ||||
Symtab.scanShlibUndefined(); | Symtab.scanShlibUndefined(); | ||||
Symtab.scanVersionScript(); | Symtab.scanVersionScript(); | ||||
// Pass wrapped symbols to LTO | |||||
pcc: This comment and the one below aren't really accurate any more because this code is used in the… | |||||
I prefer a more concrete comment. Handle -wrap option. ruiu: I prefer a more concrete comment. `Handle -wrap option`. | |||||
for (auto *Arg : Args.filtered(OPT_wrap)) | |||||
Symtab.addSymbolWrap(Arg->getValue()); | |||||
// Pass alias symbols to LTO | |||||
Ditto. Handle --defsym=sym=alias option. ruiu: Ditto. `Handle --defsym=sym=alias option.` | |||||
for (std::pair<StringRef, StringRef> &Def : getDefsym(Args)) | |||||
Symtab.addSymbolAlias(Def.first, Def.second); | |||||
Symtab.addCombinedLTOObject(); | Symtab.addCombinedLTOObject(); | ||||
if (ErrorCount) | if (ErrorCount) | ||||
return; | return; | ||||
// Some symbols (such as __ehdr_start) are defined lazily only when there | // 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. | // are undefined symbols for them, so we add these to trigger that logic. | ||||
for (StringRef Sym : Script->Opt.ReferencedSymbols) | for (StringRef Sym : Script->Opt.ReferencedSymbols) | ||||
Symtab.addUndefined(Sym); | Symtab.addUndefined(Sym); | ||||
for (auto *Arg : Args.filtered(OPT_wrap)) | // Apply symbol renames for -wrap and -defsym | ||||
Symtab.wrap(Arg->getValue()); | Symtab.applySymbolRenames(); | ||||
// Handle --defsym=sym=alias option. | |||||
for (std::pair<StringRef, StringRef> &Def : getDefsym(Args)) | |||||
Symtab.alias(Def.first, Def.second); | |||||
// Now that we have a complete list of input files. | // Now that we have a complete list of input files. | ||||
// Beyond this point, no new files are added. | // Beyond this point, no new files are added. | ||||
// Aggregate all input sections into one place. | // Aggregate all input sections into one place. | ||||
for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles()) | for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles()) | ||||
for (InputSectionBase *S : F->getSections()) | for (InputSectionBase *S : F->getSections()) | ||||
if (S && S != &InputSection::Discarded) | if (S && S != &InputSection::Discarded) | ||||
InputSections.push_back(S); | InputSections.push_back(S); | ||||
Show All 25 Lines |
This comment and the one below aren't really accurate any more because this code is used in the non-LTO case as well.