[lld] r275269 - [ELF] - Add predefined sections to output sections list in one place.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 07:26:32 PDT 2016
Author: grimar
Date: Wed Jul 13 09:26:31 2016
New Revision: 275269
URL: http://llvm.org/viewvc/llvm-project?rev=275269&view=rev
Log:
[ELF] - Add predefined sections to output sections list in one place.
Minor cleanup.
Currently it looks wierd that having method addPredefinedSections()
we still add 2 sections outside it without real reasons.
Patch fixes that.
Differential revision: http://reviews.llvm.org/D19981
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=275269&r1=275268&r2=275269&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Jul 13 09:26:31 2016
@@ -604,17 +604,6 @@ template <class ELFT> static void sortCt
// 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;
@@ -793,6 +782,17 @@ template <class ELFT> void Writer<ELFT>:
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);
More information about the llvm-commits
mailing list