From e73ac88d1b584ece15b93ee4d826a90ce2c1f370 Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Wed, 25 Jun 2014 16:43:28 +0200 Subject: [PATCH] util: LLVM disassembler off-by-one The disassembled memory region's end (variable "End") is exclusive now. Up to now, the two branches defining this variable disagreed on inclusiveness, leading to an infinite loop in one case. Change-Id: I055fc240f6ec2f4a1d1937e48617c86612cff5c5 --- src/core/util/llvmdisassembler/LLVMDisassembler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/util/llvmdisassembler/LLVMDisassembler.cpp b/src/core/util/llvmdisassembler/LLVMDisassembler.cpp index c5d03da7..0defe085 100644 --- a/src/core/util/llvmdisassembler/LLVMDisassembler.cpp +++ b/src/core/util/llvmdisassembler/LLVMDisassembler.cpp @@ -82,7 +82,7 @@ void LLVMDisassembler::disassemble() // Disassemble symbol by symbol. for (unsigned si = 0, se = Symbols.size(); si != se; ++si) { uint64_t Start = Symbols[si].first; - uint64_t End; + uint64_t End; // exclusive // The end is either the size of the section or the beginning of the next // symbol. if (Start >= SectSize) @@ -92,12 +92,12 @@ void LLVMDisassembler::disassemble() End = SectSize; // Make sure this symbol takes up space. else if (Symbols[si + 1].first != Start) - End = Symbols[si + 1].first - 1; + End = Symbols[si + 1].first; else // This symbol has the same address as the next symbol. Skip it. continue; - for (Index = Start; Index <= End; Index += Size) { + for (Index = Start; Index < End; Index += Size) { MCInst Inst; if (disas->getInstruction(Inst, Size, memoryObject, Index,