[lld] r307107 - Move clearOutputSections earlier. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 4 14:05:26 PDT 2017


Author: rafael
Date: Tue Jul  4 14:05:26 2017
New Revision: 307107

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

This is finally getting to the point where output sections are
constructed.

createOrphanCommands and fabricateDefaultCommands are moved out so
they can be merged with existing code in followup commits.

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=307107&r1=307106&r2=307107&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jul  4 14:05:26 2017
@@ -152,10 +152,6 @@ template <class ELFT> static void combin
 }
 
 template <class ELFT> void Writer<ELFT>::clearOutputSections() {
-  if (Script->Opt.HasSections)
-    Script->createOrphanCommands();
-  else
-    Script->fabricateDefaultCommands();
   // Clear the OutputSections to make sure it is not used anymore. Any
   // code from this point on should be using the linker script
   // commands.
@@ -185,6 +181,7 @@ template <class ELFT> void Writer<ELFT>:
     // Linker scripts may have left some input sections unassigned.
     // Assign such sections using the default rule.
     Script->addOrphanSections(Factory);
+    Script->createOrphanCommands();
   } else {
     // If linker script does not contain SECTIONS commands, create
     // output sections by default rules. We still need to give the
@@ -192,13 +189,13 @@ template <class ELFT> void Writer<ELFT>:
     // non-SECTIONS commands such as ASSERT.
     createSections();
     Script->processCommands(Factory);
+    Script->fabricateDefaultCommands();
   }
+  clearOutputSections();
 
   if (Config->Discard != DiscardPolicy::All)
     copyLocalSymbols();
 
-  clearOutputSections();
-
   if (Config->CopyRelocs)
     addSectionSymbols();
 




More information about the llvm-commits mailing list