[llvm] r358806 - [llvm-objdump] Don't disassemble symbols before SectionAddr
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 20 00:19:25 PDT 2019
Author: maskray
Date: Sat Apr 20 00:19:24 2019
New Revision: 358806
URL: http://llvm.org/viewvc/llvm-project?rev=358806&view=rev
Log:
[llvm-objdump] Don't disassemble symbols before SectionAddr
This was caught by UBSAN
tools/llvm-objdump/X86/macho-disassembly-g-dsym.test
tools/llvm-objdump/X86/hex-displacement.test
Modified:
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=358806&r1=358805&r2=358806&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Sat Apr 20 00:19:24 2019
@@ -1148,13 +1148,15 @@ static void disassembleObject(const Targ
continue;
uint64_t Start = std::get<0>(Symbols[SI]);
+ if (Start < SectionAddr || StopAddress <= Start)
+ continue;
// The end is the section end, the beginning of the next symbol, or
// --stop-address.
- uint64_t End = std::min<uint64_t>(SectionAddr + SectSize, StopAddress);
- if (SI + 1 < SE)
- End = std::min(End, std::get<0>(Symbols[SI + 1]));
- if (Start >= End || Start >= StopAddress || End <= StartAddress)
+ uint64_t End = std::min<uint64_t>(
+ SI + 1 < SE ? std::get<0>(Symbols[SI + 1]) : SectionAddr + SectSize,
+ StopAddress);
+ if (Start >= End || End <= StartAddress)
continue;
Start -= SectionAddr;
End -= SectionAddr;
More information about the llvm-commits
mailing list