mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
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:
parent
8143a84c46
commit
2f867a63da
@ -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