x86: eliminate redundant REX prefixes in front of x86_64 instruction. bug reported by Aurélien Wailly

This commit is contained in:
Nguyen Anh Quynh 2014-12-13 01:41:49 +08:00
parent 03a1836454
commit 1cbc222626
1 changed files with 19 additions and 0 deletions

View File

@ -390,6 +390,25 @@ static int readPrefixes(struct InternalInstruction* insn)
bool hasAdSize = false;
bool hasOpSize = false;
if (insn->mode == MODE_64BIT) {
if (consumeByte(insn, &byte))
return -1;
if ((byte & 0xf0) == 0x40) {
while(true) {
if (lookAtByte(insn, &byte)) // out of input code
return -1;
if ((byte & 0xf0) == 0x40) {
// another REX prefix, but we only remember the last one
consumeByte(insn, &byte);
} else
break;
}
} else {
unconsumeByte(insn);
}
}
while (isPrefix) {
prefixLocation = insn->readerCursor;