Skip to content

Commit

Permalink
[ELF] - Add predefined sections to output sections list in one place.
Browse files Browse the repository at this point in the history
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

llvm-svn: 275269
  • Loading branch information
George Rimar committed Jul 13, 2016
1 parent 418beb7 commit bd69903
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lld/ELF/Writer.cpp
Expand Up @@ -604,17 +604,6 @@ template <class ELFT> static void sortCtorsDtors(OutputSectionBase<ELFT> *S) {

// 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;
Expand Down Expand Up @@ -793,6 +782,17 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
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);
Expand Down

0 comments on commit bd69903

Please sign in to comment.