summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/OutputSections.cpp5
-rw-r--r--lld/test/ELF/init_fini_priority.s18
2 files changed, 16 insertions, 7 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);
diff --git a/lld/test/ELF/init_fini_priority.s b/lld/test/ELF/init_fini_priority.s
index d46ae6f061e..84e5dc35e9d 100644
--- a/lld/test/ELF/init_fini_priority.s
+++ b/lld/test/ELF/init_fini_priority.s
@@ -14,16 +14,24 @@ _start:
.long 2
.section .init_array.5, "aw", @init_array
.byte 3
+.section .init_array, "aw", @init_array
+ .byte 4
+.section .init_array, "aw", @init_array
+ .byte 5
.section .fini_array, "aw", @fini_array
.align 8
- .byte 4
+ .byte 0x11
.section .fini_array.100, "aw", @fini_array
- .long 5
+ .long 0x12
.section .fini_array.5, "aw", @fini_array
- .byte 6
+ .byte 0x13
+.section .fini_array, "aw", @fini_array
+ .byte 0x14
+.section .fini_array, "aw", @fini_array
+ .byte 0x15
// CHECK: Contents of section .init_array:
-// CHECK-NEXT: 03020000 00000000 01
+// CHECK-NEXT: 03020000 00000000 010405
// CHECK: Contents of section .fini_array:
-// CHECK-NEXT: 06050000 00000000 04
+// CHECK-NEXT: 13120000 00000000 111415
OpenPOWER on IntegriCloud