Skip to content

Commit ce12ea8

Browse files
committed
[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 llvm-svn: 358806
1 parent 4d4b5d9 commit ce12ea8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,13 +1148,15 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
11481148
continue;
11491149

11501150
uint64_t Start = std::get<0>(Symbols[SI]);
1151+
if (Start < SectionAddr || StopAddress <= Start)
1152+
continue;
11511153

11521154
// The end is the section end, the beginning of the next symbol, or
11531155
// --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)
1156+
uint64_t End = std::min<uint64_t>(
1157+
SI + 1 < SE ? std::get<0>(Symbols[SI + 1]) : SectionAddr + SectSize,
1158+
StopAddress);
1159+
if (Start >= End || End <= StartAddress)
11581160
continue;
11591161
Start -= SectionAddr;
11601162
End -= SectionAddr;

0 commit comments

Comments
 (0)