diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-02-10 23:26:27 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-02-10 23:26:27 +0000 |
| commit | 2625882ebbb3752fb215ec94dc128019c3b381c5 (patch) | |
| tree | 8cea893aff9158b36ee974d1a5cd2b56e8e8078f /lld/ELF/OutputSections.cpp | |
| parent | c87d7d02e146b4ce92a8d908a87ade973777e469 (diff) | |
| download | bcm5719-llvm-2625882ebbb3752fb215ec94dc128019c3b381c5.tar.gz bcm5719-llvm-2625882ebbb3752fb215ec94dc128019c3b381c5.zip | |
ELF: Use stable sort to sort .{init,fini}_array sections.
Global constructors and destructors are guaranteed to be called
in the order as they appear in a translation unit. So we don't want
to mess up the order if they have the same priority.
llvm-svn: 260463
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index c1a05aca34f..b6b17878398 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -772,8 +772,9 @@ template <class ELFT> void OutputSection<ELFT>::sortByPriority() { std::vector<Pair> V; for (InputSection<ELFT> *S : Sections) V.push_back({getPriority(S->getSectionName()), S}); - std::sort(V.begin(), V.end(), - [](const Pair &A, const Pair &B) { return A.first < B.first; }); + std::stable_sort(V.begin(), V.end(), [](const Pair &A, const Pair &B) { + return A.first < B.first; + }); Sections.clear(); for (Pair &P : V) Sections.push_back(P.second); |

