[PATCH] D105240: [llvm-objdump/mac] Print symbols at the same address deterministically

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 19:32:45 PDT 2021


int3 updated this revision to Diff 355750.
int3 marked an inline comment as done.
int3 retitled this revision from "[llvm-objdump] Print symbols at the same address deterministically" to "[llvm-objdump/mac] Print symbols at the same address deterministically".
int3 added a comment.

more symbols


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105240/new/

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,14 @@
+# 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:
+_baz:
+_qux:
+  nop
+
+## Ensure symbols with the same address are printed in a deterministic order
+# CHECK:      _foo
+# CHECK-NEXT: _bar
+# CHECK-NEXT: _baz
+# CHECK-NEXT: _qux


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105240.355750.patch
Type: text/x-patch
Size: 1111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/eb9a5a96/attachment.bin>


More information about the llvm-commits mailing list