[lld] r304751 - Move clearOutputSections earlier.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 16:43:49 PDT 2017


Author: rafael
Date: Mon Jun  5 18:43:49 2017
New Revision: 304751

URL: http://llvm.org/viewvc/llvm-project?rev=304751&view=rev
Log:
Move clearOutputSections earlier.

This moves clearOutputSections and OutputSectionCommands creation as
early as possible without changing other code.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=304751&r1=304750&r2=304751&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Jun  5 18:43:49 2017
@@ -258,13 +258,7 @@ template <class ELFT> void Writer<ELFT>:
   if (ErrorCount)
     return;
 
-  for (BaseCommand *Base : Script->Opt.Commands)
-    if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
-      OutputSectionCommands.push_back(Cmd);
-
-  clearOutputSections();
-
-  if (!Script->Opt.HasSections &&!Config->Relocatable)
+  if (!Script->Opt.HasSections && !Config->Relocatable)
     fixSectionAlignments();
 
   // If -compressed-debug-sections is specified, we need to compress
@@ -1267,6 +1261,9 @@ template <class ELFT> void Writer<ELFT>:
     Script->fabricateDefaultCommands();
   else
     Script->synchronize();
+  for (BaseCommand *Base : Script->Opt.Commands)
+    if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
+      OutputSectionCommands.push_back(Cmd);
 
   // Fill other section headers. The dynamic table is finalized
   // at the end because some tags like RELSZ depend on result
@@ -1277,6 +1274,8 @@ template <class ELFT> void Writer<ELFT>:
   // createThunks may have added local symbols to the static symbol table
   applySynthetic({InX::SymTab, InX::ShStrTab, InX::StrTab},
                  [](SyntheticSection *SS) { SS->postThunkContents(); });
+
+  clearOutputSections();
 }
 
 template <class ELFT> void Writer<ELFT>::addPredefinedSections() {




More information about the llvm-commits mailing list