[lld] r278449 - Remove OutputSectionBuilder::finalize.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 17:55:08 PDT 2016


Author: ruiu
Date: Thu Aug 11 19:55:08 2016
New Revision: 278449

URL: http://llvm.org/viewvc/llvm-project?rev=278449&view=rev
Log:
Remove OutputSectionBuilder::finalize.

The reason why we had to assign offsets only to sections that
don't contain layout sections were unclear. It turned out that
we can live without it.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=278449&r1=278448&r2=278449&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Aug 11 19:55:08 2016
@@ -167,7 +167,6 @@ public:
   }
   void flushSymbols();
   void flushSection();
-  void finalize();
 
 private:
   OutputSectionFactory<ELFT> &Factory;
@@ -236,16 +235,6 @@ template <class ELFT> void OutputSection
   Current = nullptr;
 }
 
-template <class ELFT> void OutputSectionBuilder<ELFT>::finalize() {
-  // Assign offsets to all sections which don't contain symbols
-  for (OutputSectionBase<ELFT> *S : *OutputSections)
-    if (llvm::find_if(OwningSections,
-                      [&](std::unique_ptr<LayoutInputSection<ELFT>> &L) {
-                        return L->OutSec == S;
-                      }) == OwningSections.end())
-      S->assignOffsets();
-}
-
 template <class ELFT>
 static bool compareName(InputSectionBase<ELFT> *A, InputSectionBase<ELFT> *B) {
   return A->getSectionName() < B->getSectionName();
@@ -325,7 +314,6 @@ void LinkerScript<ELFT>::createSections(
   // Remove from the output all the sections which did not meet
   // the optional constraints.
   filter();
-  Builder.finalize();
 }
 
 template <class R, class T>
@@ -357,11 +345,11 @@ template <class ELFT> void LinkerScript<
 }
 
 template <class ELFT> void assignOffsets(OutputSectionBase<ELFT> *Sec) {
-  // Non-zero size means we have assigned offsets earlier in
-  // OutputSectionBuilder<ELFT>::finalize
   auto *OutSec = dyn_cast<OutputSection<ELFT>>(Sec);
-  if (Sec->getSize() || !OutSec)
+  if (!OutSec) {
+    Sec->assignOffsets();
     return;
+  }
 
   typedef typename ELFT::uint uintX_t;
   uintX_t Off = 0;
@@ -448,6 +436,7 @@ template <class ELFT> void LinkerScript<
         Dot += Sec->getSize();
         continue;
       }
+      Sec->assignOffsets();
     }
   }
 




More information about the llvm-commits mailing list