diff options
author | Richard Mitton <richard@codersnotes.com> | 2013-08-30 21:19:48 +0000 |
---|---|---|
committer | Richard Mitton <richard@codersnotes.com> | 2013-08-30 21:19:48 +0000 |
commit | d4b3168609d4a6dfb8a948d87dc61f83855ac604 (patch) | |
tree | b212bc4179cbea652c081e67870c5db6c52db541 /lib/Target/X86/Disassembler | |
parent | 86d49563a65b3990d8ea7dac62d9222c1fd3b1cf (diff) | |
download | external_llvm-d4b3168609d4a6dfb8a948d87dc61f83855ac604.zip external_llvm-d4b3168609d4a6dfb8a948d87dc61f83855ac604.tar.gz external_llvm-d4b3168609d4a6dfb8a948d87dc61f83855ac604.tar.bz2 |
Fixed a bug where diassembling an instruction that had a prefix would cause LLVM to identify a 1-byte instruction, but then upon querying it for that 1-byte instruction would cause an undefined opcode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/Disassembler')
-rw-r--r-- | lib/Target/X86/Disassembler/X86DisassemblerDecoder.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c index bb195ee..b63fd5a 100644 --- a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c +++ b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c @@ -314,20 +314,22 @@ static int readPrefixes(struct InternalInstruction* insn) { while (isPrefix) { prefixLocation = insn->readerCursor; + /* If we fail reading prefixes, just stop here and let the opcode reader deal with it */ if (consumeByte(insn, &byte)) - return -1; + break; /* * If the byte is a LOCK/REP/REPNE prefix and not a part of the opcode, then * break and let it be disassembled as a normal "instruction". */ + if (insn->readerCursor - 1 == insn->startLocation && byte == 0xf0) + break; + + uint8_t nextByte; if (insn->readerCursor - 1 == insn->startLocation - && (byte == 0xf0 || byte == 0xf2 || byte == 0xf3)) { - uint8_t nextByte; - if (byte == 0xf0) - break; - if (lookAtByte(insn, &nextByte)) - return -1; + && (byte == 0xf2 || byte == 0xf3) + && !lookAtByte(insn, &nextByte)) + { /* * If the byte is 0xf2 or 0xf3, and any of the following conditions are * met: |