[lld] r305333 - Move clearOutputSections earlier. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 13 15:36:20 PDT 2017
Author: rafael
Date: Tue Jun 13 17:36:20 2017
New Revision: 305333
URL: http://llvm.org/viewvc/llvm-project?rev=305333&view=rev
Log:
Move clearOutputSections earlier. NFC.
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=305333&r1=305332&r2=305333&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jun 13 17:36:20 2017
@@ -1151,6 +1151,12 @@ template <class ELFT> void Writer<ELFT>:
removeUnusedSyntheticSections(OutputSections);
sortSections();
+ if (!Script->Opt.HasSections)
+ Script->fabricateDefaultCommands();
+ for (BaseCommand *Base : Script->Opt.Commands)
+ if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
+ OutputSectionCommands.push_back(Cmd);
+ clearOutputSections();
// This is a bit of a hack. A value of 0 means undef, so we set it
// to 1 t make __ehdr_start defined. The section number is not
@@ -1158,18 +1164,12 @@ template <class ELFT> void Writer<ELFT>:
Out::ElfHeader->SectionIndex = 1;
unsigned I = 1;
- for (OutputSection *Sec : OutputSections) {
+ for (OutputSectionCommand *Cmd : OutputSectionCommands) {
+ OutputSection *Sec = Cmd->Sec;
Sec->SectionIndex = I++;
Sec->ShName = InX::ShStrTab->addString(Sec->Name);
}
- if (!Script->Opt.HasSections)
- Script->fabricateDefaultCommands();
- for (BaseCommand *Base : Script->Opt.Commands)
- if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
- OutputSectionCommands.push_back(Cmd);
- clearOutputSections();
-
// Binary and relocatable output does not have PHDRS.
// The headers have to be created before finalize as that can influence the
// image base and the dynamic section on mips includes the image base.
More information about the llvm-commits
mailing list