Skip to content

Commit 987ca37

Browse files
committed
Use a stable sort in two places.
1 parent 97e9907 commit 987ca37

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ impl<'a, 's> Context<'a, 's> {
341341
// If we have both a public symbol and a placeholder symbol at the same offset,
342342
// make it so that the symbol with name comes first, so that we keep it during
343343
// the deduplication.
344-
global_functions.sort_unstable_by_key(|p| {
344+
// If there are multiple symbols at the same address, we want to keep the first
345+
// one, so we use a stable sort.
346+
global_functions.sort_by_key(|p| {
345347
(
346348
p.start_offset.section,
347349
p.start_offset.offset,
@@ -948,7 +950,9 @@ impl<'a, 's> BasicModuleInfo<'a, 's> {
948950
}
949951
}
950952
// Sort and de-duplicate, so that we can use binary search during lookup.
951-
functions.sort_unstable_by_key(|p| (p.offset.section, p.offset.offset));
953+
// Use a stable sort: if there are multiple symbols at the same address,
954+
// we want to keep the first one.
955+
functions.sort_by_key(|p| (p.offset.section, p.offset.offset));
952956
functions.dedup_by_key(|p| p.offset);
953957

954958
Ok(BasicModuleInfo {

0 commit comments

Comments
 (0)