From abd335a339cb2c5aaf30463ff8451f1eb6e223c7 Mon Sep 17 00:00:00 2001 From: James Henderson Date: Tue, 7 Apr 2020 11:51:26 +0100 Subject: [llvm-objdump] Fix unstable disassembly output for sections with same address When two sections shared the same address, the disassembly code was using pointer values when sorting (see the SectionRef less than operator). Since those values aren't guaranteed to have a specific order, this meant the disassembly code would sometimes change which section to pick when finding symbols targeted by calls in fully linked objects. This change fixes the non-determinism, so that the same section is always picked. This might have a negative impact in that now a section without any symbol might be picked over a section with symbols, but this will be addressed in a later commit. Fixes https://bugs.llvm.org/show_bug.cgi?id=45411. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D77640 --- llvm/tools/llvm-objdump/llvm-objdump.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp') diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 06a4978..2f9c6f1 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1249,7 +1249,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, std::vector> SectionAddresses; for (SectionRef Sec : Obj->sections()) SectionAddresses.emplace_back(Sec.getAddress(), Sec); - stable_sort(SectionAddresses); + llvm::stable_sort(SectionAddresses, llvm::less_first()); // Linked executables (.exe and .dll files) typically don't include a real // symbol table but they might contain an export table. -- cgit v1.1