@@ -1141,33 +1141,23 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
1141
1141
std::vector<RelocationRef>::const_iterator RelEnd = Rels.end ();
1142
1142
// Disassemble symbol by symbol.
1143
1143
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])))
1161
1148
continue ;
1162
1149
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]);
1166
1151
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)
1170
1158
continue ;
1159
+ Start -= SectionAddr;
1160
+ End -= SectionAddr;
1171
1161
1172
1162
if (!PrintedSection) {
1173
1163
PrintedSection = true ;
0 commit comments