diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 939a40ef5886ac..66bf7d0f384883 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -2369,12 +2369,6 @@ template void LinkerDriver::link(opt::InputArgList &args) { // except a few linker-synthesized ones will be added to the symbol table. compileBitcodeFiles(); - // Handle --exclude-libs again because lto.tmp may reference additional - // libcalls symbols defined in an excluded archive. This may override - // versionId set by scanVersionScript(). - if (args.hasArg(OPT_exclude_libs)) - excludeLibs(args); - // Symbol resolution finished. Report backward reference problems. reportBackrefs(); if (errorCount()) @@ -2392,9 +2386,18 @@ template void LinkerDriver::link(opt::InputArgList &args) { !config->thinLTOModulesToCompile.empty()) return; + // Handle --exclude-libs again because lto.tmp may reference additional + // libcalls symbols defined in an excluded archive. This may override + // versionId set by scanVersionScript(). + if (args.hasArg(OPT_exclude_libs)) + excludeLibs(args); + // Apply symbol renames for --wrap and combine foo@v1 and foo@@v1. redirectSymbols(wrapped); + // Replace common symbols with regular symbols. + replaceCommonSymbols(); + { llvm::TimeTraceScope timeScope("Aggregate sections"); // Now that we have a complete list of input files. @@ -2479,9 +2482,6 @@ template void LinkerDriver::link(opt::InputArgList &args) { if (!config->relocatable) inputSections.push_back(createCommentSection()); - // Replace common symbols with regular symbols. - replaceCommonSymbols(); - // Split SHF_MERGE and .eh_frame sections into pieces in preparation for garbage collection. splitSections();