[PATCH] D105240: [llvm-objdump] Print symbols at the same address deterministically
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 15:54:46 PDT 2021
int3 created this revision.
int3 added reviewers: thakis, MaskRay, jhenderson, rupprecht, compnerd.
Herald added a subscriber: mgrang.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
By using stable_sort.
Added a test case which previously failed when expensive checks were
enabled.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105240
Files:
llvm/test/tools/llvm-objdump/MachO/disassemble-symbol-same-addr.test
llvm/tools/llvm-objdump/MachODump.cpp
Index: llvm/tools/llvm-objdump/MachODump.cpp
===================================================================
--- llvm/tools/llvm-objdump/MachODump.cpp
+++ llvm/tools/llvm-objdump/MachODump.cpp
@@ -7318,7 +7318,7 @@
BaseSegmentAddress);
// Sort the symbols by address, just in case they didn't come in that way.
- llvm::sort(Symbols, SymbolSorter());
+ llvm::stable_sort(Symbols, SymbolSorter());
// Build a data in code table that is sorted on by the address of each entry.
uint64_t BaseAddress = 0;
Index: llvm/test/tools/llvm-objdump/MachO/disassemble-symbol-same-addr.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/MachO/disassemble-symbol-same-addr.test
@@ -0,0 +1,10 @@
+# RUN: llvm-mc %s --triple x86_64-apple-darwin -filetype=obj -o %t.o
+# RUN: llvm-objdump --macho -d %t.o | FileCheck %s
+
+_foo:
+_bar:
+ nop
+
+## Enusre symbols with the same address are printed in a deterministic order
+# CHECK: _foo
+# CHECK-NEXT: _bar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105240.355708.patch
Type: text/x-patch
Size: 1057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210630/e81486f1/attachment.bin>
More information about the llvm-commits
mailing list