[ELF] SHF_LINK_ORDER should sort based on InputSectionDescriptions
This change alters the sorting for OutputSections with the SHF_LINK_ORDER
flag in OutputSection::finalize() to use the InputSectionDescription
representation and not the OutputSection::Sections representation.
Differential revision: https://reviews.llvm.org/D33772
llvm-svn: 304700
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index f68e07f..79ca67e 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -257,11 +257,6 @@
if (ErrorCount)
return;
- if (!Script->Opt.HasSections)
- Script->fabricateDefaultCommands();
- else
- Script->synchronize();
-
for (BaseCommand *Base : Script->Opt.Commands)
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
OutputSectionCommands.push_back(Cmd);
@@ -1261,6 +1256,12 @@
applySynthetic({InX::MipsGot},
[](SyntheticSection *SS) { SS->updateAllocSize(); });
}
+
+ if (!Script->Opt.HasSections)
+ Script->fabricateDefaultCommands();
+ else
+ Script->synchronize();
+
// Fill other section headers. The dynamic table is finalized
// at the end because some tags like RELSZ depend on result
// of finalizing other sections.