[PATCH] D19981: [ELF] - add predefined sections to output sections list in one place.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 02:39:51 PDT 2016


grimar updated this revision to Diff 56390.
grimar added a comment.

Addressed review comments


http://reviews.llvm.org/D19981

Files:
  ELF/Writer.cpp

Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1285,17 +1285,6 @@
 
 // Create output section objects and add them to OutputSections.
 template <class ELFT> void Writer<ELFT>::createSections() {
-  // Add .interp first because some loaders want to see that section
-  // on the first page of the executable file when loaded into memory.
-  if (needsInterpSection())
-    OutputSections.push_back(Out<ELFT>::Interp);
-
-  // A core file does not usually contain unmodified segments except
-  // the first page of the executable. Add the build ID section now
-  // so that the section is included in the first page.
-  if (Out<ELFT>::BuildId)
-    OutputSections.push_back(Out<ELFT>::BuildId);
-
   // Create output sections for input object file sections.
   std::vector<OutputSectionBase<ELFT> *> RegularSections;
   OutputSectionFactory<ELFT> Factory;
@@ -1472,6 +1461,17 @@
       OutputSections.push_back(C);
   };
 
+  // A core file does not usually contain unmodified segments except
+  // the first page of the executable. Add the build ID section to beginning of
+  // the file so that the section is included in the first page.
+  if (Out<ELFT>::BuildId)
+    OutputSections.insert(OutputSections.begin(), Out<ELFT>::BuildId);
+
+  // Add .interp at first because some loaders want to see that section
+  // on the first page of the executable file when loaded into memory.
+  if (needsInterpSection())
+    OutputSections.insert(OutputSections.begin(), Out<ELFT>::Interp);
+
   // This order is not the same as the final output order
   // because we sort the sections using their attributes below.
   Add(Out<ELFT>::SymTab);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19981.56390.patch
Type: text/x-patch
Size: 1721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/bacf061b/attachment.bin>


More information about the llvm-commits mailing list