Skip to content

Commit 611ad2e

Browse files
int3memfrob
authored andcommitted
[llvm-objdump/mac] Print symbols at the same address deterministically
By using stable_sort. Added a test case which previously failed when expensive checks were enabled. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D105240
1 parent afb6b2a commit 611ad2e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RUN: llvm-mc %s --triple x86_64-apple-darwin -filetype=obj -o %t.o
2+
# RUN: llvm-objdump --macho -d %t.o | FileCheck %s
3+
4+
_foo:
5+
_bar:
6+
_baz:
7+
_qux:
8+
nop
9+
10+
## Ensure symbols with the same address are printed in a deterministic order
11+
# CHECK: _foo
12+
# CHECK-NEXT: _bar
13+
# CHECK-NEXT: _baz
14+
# CHECK-NEXT: _qux

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7318,7 +7318,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
73187318
BaseSegmentAddress);
73197319

73207320
// Sort the symbols by address, just in case they didn't come in that way.
7321-
llvm::sort(Symbols, SymbolSorter());
7321+
llvm::stable_sort(Symbols, SymbolSorter());
73227322

73237323
// Build a data in code table that is sorted on by the address of each entry.
73247324
uint64_t BaseAddress = 0;

0 commit comments

Comments
 (0)