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:
parent
fb2bb22b6f
commit
64814fff0b
@ -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);
|
||||
|
4
test/MC/Disassembler/X86/truncated-input.txt
Normal file
4
test/MC/Disassembler/X86/truncated-input.txt
Normal file
@ -0,0 +1,4 @@
|
||||
# RUN: llvm-mc --disassemble %s -triple=x86_64-apple-darwin9 |& FileCheck %s
|
||||
|
||||
# CHECK: warning
|
||||
0x00
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user