[llvm] r358803 - [llvm-objdump] Simplify --{start,stop}-address
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 19 19:10:49 PDT 2019
Author: maskray
Date: Fri Apr 19 19:10:48 2019
New Revision: 358803
URL: http://llvm.org/viewvc/llvm-project?rev=358803&view=rev
Log:
[llvm-objdump] Simplify --{start,stop}-address
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=358803&r1=358802&r2=358803&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Fri Apr 19 19:10:48 2019
@@ -1141,33 +1141,23 @@ static void disassembleObject(const Targ
std::vector<RelocationRef>::const_iterator RelEnd = Rels.end();
// Disassemble symbol by symbol.
for (unsigned SI = 0, SE = Symbols.size(); SI != SE; ++SI) {
- uint64_t Start = std::get<0>(Symbols[SI]) - SectionAddr;
- // The end is either the section end or the beginning of the next
- // symbol.
- uint64_t End = (SI == SE - 1)
- ? SectSize
- : std::get<0>(Symbols[SI + 1]) - SectionAddr;
- // Don't try to disassemble beyond the end of section contents.
- if (End > SectSize)
- End = SectSize;
- // If this symbol has the same address as the next symbol, then skip it.
- if (Start >= End)
- continue;
-
- // Check if we need to skip symbol
- // Skip if the symbol's data is not between StartAddress and StopAddress
- if (End + SectionAddr <= StartAddress ||
- Start + SectionAddr >= StopAddress)
+ // Skip if --disassemble-functions is not empty and the symbol is not in
+ // the list.
+ if (!DisasmFuncsSet.empty() &&
+ !DisasmFuncsSet.count(std::get<1>(Symbols[SI])))
continue;
- // Stop disassembly at the stop address specified
- if (End + SectionAddr > StopAddress)
- End = StopAddress - SectionAddr;
+ uint64_t Start = std::get<0>(Symbols[SI]);
- /// Skip if user requested specific symbols and this is not in the list
- if (!DisasmFuncsSet.empty() &&
- !DisasmFuncsSet.count(std::get<1>(Symbols[SI])))
+ // 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)
continue;
+ Start -= SectionAddr;
+ End -= SectionAddr;
if (!PrintedSection) {
PrintedSection = true;
More information about the llvm-commits
mailing list