[llvm-commits] [llvm] r122962 - in /llvm/trunk: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c test/MC/Disassembler/X86/truncated-input.txt tools/llvm-mc/Disassembler.cpp
Rafael Espindola
rafael.espindola at gmail.com
Thu Jan 6 08:48:42 PST 2011
Author: rafael
Date: Thu Jan 6 10:48:42 2011
New Revision: 122962
URL: http://llvm.org/viewvc/llvm-project?rev=122962&view=rev
Log:
Correctly disassemble truncated asm.
Patch by Richard Simth.
Added:
llvm/trunk/test/MC/Disassembler/X86/truncated-input.txt
Modified:
llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c
llvm/trunk/tools/llvm-mc/Disassembler.cpp
Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c?rev=122962&r1=122961&r2=122962&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original)
+++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Thu Jan 6 10:48:42 2011
@@ -511,7 +511,8 @@
insn->opcode);
if (hasModRMExtension) {
- readModRM(insn);
+ if (readModRM(insn))
+ return -1;
*instructionID = decode(insn->opcodeType,
instructionClass,
@@ -860,7 +861,8 @@
if (insn->consumedModRM)
return 0;
- consumeByte(insn, &insn->modRM);
+ if (consumeByte(insn, &insn->modRM))
+ return -1;
insn->consumedModRM = TRUE;
mod = modFromModRM(insn->modRM);
Added: llvm/trunk/test/MC/Disassembler/X86/truncated-input.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/truncated-input.txt?rev=122962&view=auto
==============================================================================
--- llvm/trunk/test/MC/Disassembler/X86/truncated-input.txt (added)
+++ llvm/trunk/test/MC/Disassembler/X86/truncated-input.txt Thu Jan 6 10:48:42 2011
@@ -0,0 +1,4 @@
+# RUN: llvm-mc --disassemble %s -triple=x86_64-apple-darwin9 |& FileCheck %s
+
+# CHECK: warning
+0x00
Modified: llvm/trunk/tools/llvm-mc/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Disassembler.cpp?rev=122962&r1=122961&r2=122962&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/Disassembler.cpp (original)
+++ llvm/trunk/tools/llvm-mc/Disassembler.cpp Thu Jan 6 10:48:42 2011
@@ -44,7 +44,7 @@
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;
More information about the llvm-commits
mailing list