[PATCH] D76739: [llvm-objdump] Replace array_pod_sort with llvm::stable_sort
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 24 16:00:49 PDT 2020
MaskRay created this revision.
MaskRay added reviewers: davidb, echristo, jhenderson, thopre.
Herald added subscribers: llvm-commits, rupprecht.
Herald added a project: LLVM.
llvm-objdump.test has 3 array_pod_sort() used for symbolization.
array_pod_start() calls qsort() internally and can have different
behaviors across different libcs. Use llvm::stable_sort instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76739
Files:
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1202,11 +1202,13 @@
StringSaver Saver(A);
addPltEntries(Obj, AllSymbols, Saver);
- // Create a mapping from virtual address to section.
+ // Create a mapping from virtual address to section. An empty section can
+ // cause more than one section at the same address. Use a stable sort to
+ // stabalize the output.
std::vector<std::pair<uint64_t, SectionRef>> SectionAddresses;
for (SectionRef Sec : Obj->sections())
SectionAddresses.emplace_back(Sec.getAddress(), Sec);
- array_pod_sort(SectionAddresses.begin(), SectionAddresses.end());
+ stable_sort(SectionAddresses);
// Linked executables (.exe and .dll files) typically don't include a real
// symbol table but they might contain an export table.
@@ -1236,11 +1238,12 @@
}
// Sort all the symbols, this allows us to use a simple binary search to find
- // a symbol near an address.
+ // Multiple symbols can have the same address. Use a stable sort to stabalize
+ // the output.
StringSet<> FoundDisasmSymbolSet;
for (std::pair<const SectionRef, SectionSymbolsTy> &SecSyms : AllSymbols)
- array_pod_sort(SecSyms.second.begin(), SecSyms.second.end());
- array_pod_sort(AbsoluteSymbols.begin(), AbsoluteSymbols.end());
+ stable_sort(SecSyms.second);
+ stable_sort(AbsoluteSymbols);
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
if (FilterSections.empty() && !DisassembleAll &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76739.252450.patch
Type: text/x-patch
Size: 1622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200324/010049a1/attachment.bin>
More information about the llvm-commits
mailing list