Correctly disassemble truncated asm.

Patch by Richard Simth.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-01-06 16:48:42 +00:00
parent 8143a84c46
commit 2f867a63da
3 changed files with 9 additions and 3 deletions

View File

@ -511,7 +511,8 @@ static int getIDWithAttrMask(uint16_t* instructionID,
insn->opcode);
if (hasModRMExtension) {
readModRM(insn);
if (readModRM(insn))
return -1;
*instructionID = decode(insn->opcodeType,
instructionClass,
@ -860,7 +861,8 @@ static int readModRM(struct InternalInstruction* insn) {
if (insn->consumedModRM)
return 0;
consumeByte(insn, &insn->modRM);
if (consumeByte(insn, &insn->modRM))
return -1;
insn->consumedModRM = TRUE;
mod = modFromModRM(insn->modRM);

View File

@ -0,0 +1,4 @@
# RUN: llvm-mc --disassemble %s -triple=x86_64-apple-darwin9 |& FileCheck %s
# CHECK: warning
0x00

View File

@ -44,7 +44,7 @@ public:
uint64_t getExtent() const { return Bytes.size(); }
int readByte(uint64_t Addr, uint8_t *Byte) const {
if (Addr > getExtent())
if (Addr >= getExtent())
return -1;
*Byte = Bytes[Addr].first;
return 0;