[lld] abc388e - [ELF] Move excludeLibs/redirectSymbols/replaceCommonSymbols adjacent

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 27 00:32:00 PST 2021


Author: Fangrui Song
Date: 2021-12-27T00:31:55-08:00
New Revision: abc388ed3cf0ef7e617ebe243d3b0b32d29e69a5

URL: https://github.com/llvm/llvm-project/commit/abc388ed3cf0ef7e617ebe243d3b0b32d29e69a5
DIFF: https://github.com/llvm/llvm-project/commit/abc388ed3cf0ef7e617ebe243d3b0b32d29e69a5.diff

LOG: [ELF] Move excludeLibs/redirectSymbols/replaceCommonSymbols adjacent

Make post-thinlto-index symbol resolution passes closer.

Added: 
    

Modified: 
    lld/ELF/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 939a40ef5886..66bf7d0f3848 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2369,12 +2369,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
   // except a few linker-synthesized ones will be added to the symbol table.
   compileBitcodeFiles<ELFT>();
 
-  // 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 <class ELFT> 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 at 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 <class ELFT> 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<ELFT>();
 


        


More information about the llvm-commits mailing list