Move clearOutputSections earlier.

Another step into merging the linker script and non linker script code
paths.

llvm-svn: 304339
This commit is contained in:
Rafael Espindola 2017-05-31 20:22:27 +00:00
parent db5e56f7b2
commit 969c6512c2
2 changed files with 7 additions and 2 deletions

View File

@ -1085,7 +1085,12 @@ template <class ELFT> void OutputSectionCommand::writeTo(uint8_t *Buf) {
return; return;
// Write leading padding. // Write leading padding.
ArrayRef<InputSection *> Sections = Sec->Sections; std::vector<InputSection *> Sections;
for (BaseCommand *Cmd : Commands)
if (auto *ISD = dyn_cast<InputSectionDescription>(Cmd))
for (InputSection *IS : ISD->Sections)
if (IS->Live)
Sections.push_back(IS);
uint32_t Filler = getFiller(); uint32_t Filler = getFiller();
if (Filler) if (Filler)
fill(Buf, Sections.empty() ? Sec->Size : Sections[0]->OutSecOff, Filler); fill(Buf, Sections.empty() ? Sec->Size : Sections[0]->OutSecOff, Filler);

View File

@ -300,13 +300,13 @@ template <class ELFT> void Writer<ELFT>::run() {
openFile(); openFile();
if (ErrorCount) if (ErrorCount)
return; return;
clearOutputSections();
if (!Config->OFormatBinary) { if (!Config->OFormatBinary) {
writeHeader(); writeHeader();
writeSections(); writeSections();
} else { } else {
writeSectionsBinary(); writeSectionsBinary();
} }
clearOutputSections();
// Backfill .note.gnu.build-id section content. This is done at last // Backfill .note.gnu.build-id section content. This is done at last
// because the content is usually a hash value of the entire output file. // because the content is usually a hash value of the entire output file.