Use OutputSectionCommands in assignOffsets.
This allows moving clearOutputSections earlier.
llvm-svn: 304952
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 72b6457..a8ab143 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1216,12 +1216,6 @@
Out::ProgramHeaders->Size = sizeof(Elf_Phdr) * Phdrs.size();
}
- // Compute the size of .rela.dyn and .rela.plt early since we need
- // them to populate .dynamic.
- for (SyntheticSection *SS : {In<ELFT>::RelaDyn, In<ELFT>::RelaPlt})
- if (SS->getParent() && !SS->empty())
- SS->getParent()->assignOffsets();
-
if (!Script->Opt.HasSections)
Script->fabricateDefaultCommands();
for (BaseCommand *Base : Script->Opt.Commands)
@@ -1229,6 +1223,12 @@
OutputSectionCommands.push_back(Cmd);
clearOutputSections();
+ // Compute the size of .rela.dyn and .rela.plt early since we need
+ // them to populate .dynamic.
+ for (SyntheticSection *SS : {In<ELFT>::RelaDyn, In<ELFT>::RelaPlt})
+ if (SS->getParent() && !SS->empty())
+ SS->getParent()->assignOffsets();
+
// Dynamic section must be the last one in this list and dynamic
// symbol table section (DynSymTab) must be the first one.
applySynthetic({InX::DynSymTab, InX::Bss, InX::BssRelRo,