[lld] r304339 - Move clearOutputSections earlier.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 13:22:27 PDT 2017
Author: rafael
Date: Wed May 31 15:22:27 2017
New Revision: 304339
URL: http://llvm.org/viewvc/llvm-project?rev=304339&view=rev
Log:
Move clearOutputSections earlier.
Another step into merging the linker script and non linker script code
paths.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=304339&r1=304338&r2=304339&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed May 31 15:22:27 2017
@@ -1085,7 +1085,12 @@ template <class ELFT> void OutputSection
return;
// 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();
if (Filler)
fill(Buf, Sections.empty() ? Sec->Size : Sections[0]->OutSecOff, Filler);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=304339&r1=304338&r2=304339&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed May 31 15:22:27 2017
@@ -300,13 +300,13 @@ template <class ELFT> void Writer<ELFT>:
openFile();
if (ErrorCount)
return;
+ clearOutputSections();
if (!Config->OFormatBinary) {
writeHeader();
writeSections();
} else {
writeSectionsBinary();
}
- clearOutputSections();
// 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.
More information about the llvm-commits
mailing list