Skip to content

Commit 8f28f7a

Browse files
committed
[llvm-objdump] Simplify --{start,stop}-address
llvm-svn: 358803
1 parent 4d2b942 commit 8f28f7a

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,33 +1141,23 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
11411141
std::vector<RelocationRef>::const_iterator RelEnd = Rels.end();
11421142
// Disassemble symbol by symbol.
11431143
for (unsigned SI = 0, SE = Symbols.size(); SI != SE; ++SI) {
1144-
uint64_t Start = std::get<0>(Symbols[SI]) - SectionAddr;
1145-
// The end is either the section end or the beginning of the next
1146-
// symbol.
1147-
uint64_t End = (SI == SE - 1)
1148-
? SectSize
1149-
: std::get<0>(Symbols[SI + 1]) - SectionAddr;
1150-
// Don't try to disassemble beyond the end of section contents.
1151-
if (End > SectSize)
1152-
End = SectSize;
1153-
// If this symbol has the same address as the next symbol, then skip it.
1154-
if (Start >= End)
1155-
continue;
1156-
1157-
// Check if we need to skip symbol
1158-
// Skip if the symbol's data is not between StartAddress and StopAddress
1159-
if (End + SectionAddr <= StartAddress ||
1160-
Start + SectionAddr >= StopAddress)
1144+
// Skip if --disassemble-functions is not empty and the symbol is not in
1145+
// the list.
1146+
if (!DisasmFuncsSet.empty() &&
1147+
!DisasmFuncsSet.count(std::get<1>(Symbols[SI])))
11611148
continue;
11621149

1163-
// Stop disassembly at the stop address specified
1164-
if (End + SectionAddr > StopAddress)
1165-
End = StopAddress - SectionAddr;
1150+
uint64_t Start = std::get<0>(Symbols[SI]);
11661151

1167-
/// Skip if user requested specific symbols and this is not in the list
1168-
if (!DisasmFuncsSet.empty() &&
1169-
!DisasmFuncsSet.count(std::get<1>(Symbols[SI])))
1152+
// The end is the section end, the beginning of the next symbol, or
1153+
// --stop-address.
1154+
uint64_t End = std::min<uint64_t>(SectionAddr + SectSize, StopAddress);
1155+
if (SI + 1 < SE)
1156+
End = std::min(End, std::get<0>(Symbols[SI + 1]));
1157+
if (Start >= End || Start >= StopAddress || End <= StartAddress)
11701158
continue;
1159+
Start -= SectionAddr;
1160+
End -= SectionAddr;
11711161

11721162
if (!PrintedSection) {
11731163
PrintedSection = true;

0 commit comments

Comments
 (0)