[lld] r304654 - Convert another OutputSections use.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 23:51:22 PDT 2017


Author: rafael
Date: Sat Jun  3 01:51:22 2017
New Revision: 304654

URL: http://llvm.org/viewvc/llvm-project?rev=304654&view=rev
Log:
Convert another OutputSections use.

This allows moving clearOutputSections a bit earlier.

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=304654&r1=304653&r2=304654&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Jun  3 01:51:22 2017
@@ -257,19 +257,20 @@ template <class ELFT> void Writer<ELFT>:
   if (ErrorCount)
     return;
 
-  if (!Script->Opt.HasSections) {
+  if (!Script->Opt.HasSections)
     Script->fabricateDefaultCommands();
-    if (!Config->Relocatable)
-      fixSectionAlignments();
-  } else {
+  else
     Script->synchronize();
-  }
 
   for (BaseCommand *Base : Script->Opt.Commands)
     if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
       OutputSectionCommands.push_back(Cmd);
 
   clearOutputSections();
+
+  if (!Script->Opt.HasSections &&!Config->Relocatable)
+    fixSectionAlignments();
+
   // If -compressed-debug-sections is specified, we need to compress
   // .debug_* sections. Do it right now because it changes the size of
   // output sections.
@@ -1523,11 +1524,12 @@ template <class ELFT> void Writer<ELFT>:
       PageAlign(P.First);
     // Find the first section after PT_GNU_RELRO. If it is in a PT_LOAD we
     // have to align it to a page.
-    auto End = OutputSections.end();
-    auto I = std::find(OutputSections.begin(), End, P.Last);
+    auto End = OutputSectionCommands.end();
+    auto I =
+        std::find(OutputSectionCommands.begin(), End, Script->getCmd(P.Last));
     if (I == End || (I + 1) == End)
       continue;
-    OutputSection *Sec = *(I + 1);
+    OutputSection *Sec = (*(I + 1))->Sec;
     if (needsPtLoad(Sec))
       PageAlign(Sec);
   }




More information about the llvm-commits mailing list