1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Correctly disassemble truncated asm.

Patch by Richard Simth.

llvm-svn: 122962
This commit is contained in:
Rafael Espindola 2011-01-06 16:48:42 +00:00
parent fb2bb22b6f
commit 64814fff0b
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;