[ELF] Use stable_sort for compareByFilePosition

The comment at the top of compareByFilePosition indicates that it relies
on stable_sort to preserve the order of synthetic sections. We were
using sort instead of stable_sort, however, leading to incorrect
synthetic section ordering.

Differential Revision: https://reviews.llvm.org/D35473

llvm-svn: 308207
This commit is contained in:
Shoaib Meenai 2017-07-17 19:42:19 +00:00
parent f9dc3deaa6
commit e1d7776c53

View File

@ -1084,7 +1084,7 @@ template <class ELFT> void OutputSectionCommand::finalize() {
}
if ((Sec->Flags & SHF_LINK_ORDER)) {
std::sort(Sections.begin(), Sections.end(), compareByFilePosition);
std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);
for (int I = 0, N = Sections.size(); I < N; ++I)
*ScriptSections[I] = Sections[I];