aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-04-20 02:10:48 +0000
committerFangrui Song <maskray@google.com>2019-04-20 02:10:48 +0000
commit8f28f7a488158730410662be906c77216ab8e6cc (patch)
tree1507a08a250fd414ee696605510bab162bb797e5 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent4d2b9426b99f1d6d4d4b168a3133124ea85da7ea (diff)
downloadllvm-8f28f7a488158730410662be906c77216ab8e6cc.zip
llvm-8f28f7a488158730410662be906c77216ab8e6cc.tar.gz
llvm-8f28f7a488158730410662be906c77216ab8e6cc.tar.bz2
[llvm-objdump] Simplify --{start,stop}-address
llvm-svn: 358803
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index db8bfe3..fb12e75 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1141,33 +1141,23 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
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;