aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f66f3615fa4..501c10f35849 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1518,12 +1518,12 @@ template <class ELFT> void Writer<ELFT>::sortSections() {
if (auto *osd = dyn_cast<OutputDesc>(cmd))
osd->osec.sortRank = getSectionRank(osd->osec);
if (!script->hasSectionsCommand) {
- // We know that all the OutputSections are contiguous in this case.
- auto isSection = [](SectionCommand *cmd) { return isa<OutputDesc>(cmd); };
- std::stable_sort(
- llvm::find_if(script->sectionCommands, isSection),
- llvm::find_if(llvm::reverse(script->sectionCommands), isSection).base(),
- compareSections);
+ // OutputDescs are mostly contiguous, but may be interleaved with
+ // SymbolAssignments in the presence of INSERT commands.
+ auto mid = std::stable_partition(
+ script->sectionCommands.begin(), script->sectionCommands.end(),
+ [](SectionCommand *cmd) { return isa<OutputDesc>(cmd); });
+ std::stable_sort(script->sectionCommands.begin(), mid, compareSections);
}
// Process INSERT commands and update output section attributes. From this