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
This commit is contained in:
Richard Mitton
2013-08-30 21:19:48 +00:00
parent 86d49563a6
commit d4b3168609
2 changed files with 68 additions and 7 deletions

View File

@@ -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: