summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index a8ab1437e4e..ad95a8acced 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1207,6 +1207,12 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
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);
+
// 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.
@@ -1216,11 +1222,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
Out::ProgramHeaders->Size = sizeof(Elf_Phdr) * Phdrs.size();
}
- if (!Script->Opt.HasSections)
- Script->fabricateDefaultCommands();
- for (BaseCommand *Base : Script->Opt.Commands)
- if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
- OutputSectionCommands.push_back(Cmd);
clearOutputSections();
// Compute the size of .rela.dyn and .rela.plt early since we need
OpenPOWER on IntegriCloud