From 4e20e8e24d6acc219e09e117cac3b52d6b11a7f3 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Mon, 10 Nov 2014 07:43:49 +0800 Subject: [PATCH] x86: 0x66 & 0x67 cannot be anywhere. this fixes CRC32 instruction --- arch/X86/X86DisassemblerDecoder.c | 5 +---- arch/X86/X86DisassemblerDecoder.h | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/X86/X86DisassemblerDecoder.c b/arch/X86/X86DisassemblerDecoder.c index 22b996d9..50358f46 100644 --- a/arch/X86/X86DisassemblerDecoder.c +++ b/arch/X86/X86DisassemblerDecoder.c @@ -365,10 +365,6 @@ static bool isPrefixAtLocation(struct InternalInstruction* insn, uint8_t prefix, uint64_t location) { - // allow 0x66 & 0x67 to be put anywhere - if (prefix == 0x66 || prefix == 0x67) - return insn->prefixPresent[prefix] == 1; - if (insn->prefixPresent[prefix] == 1 && insn->prefixLocations[prefix] == location) return true; @@ -545,6 +541,7 @@ static int readPrefixes(struct InternalInstruction* insn) insn->vectorExtensionType = TYPE_NO_VEX_XOP; + if (byte == 0x62) { uint8_t byte1, byte2; diff --git a/arch/X86/X86DisassemblerDecoder.h b/arch/X86/X86DisassemblerDecoder.h index f64ebe5b..02dd03ec 100644 --- a/arch/X86/X86DisassemblerDecoder.h +++ b/arch/X86/X86DisassemblerDecoder.h @@ -568,6 +568,9 @@ typedef struct InternalInstruction { /* 1 if the prefix byte, 0xf2 or 0xf3 is xacquire or xrelease */ bool xAcquireRelease; + /* contains the location (for use with the reader) of the prefix byte */ + uint64_t prefixLocations[0x100]; + /* The value of the vector extension prefix(EVEX/VEX/XOP), if present */ uint8_t vectorExtensionPrefix[4]; @@ -596,8 +599,6 @@ typedef struct InternalInstruction { /* Prefix state */ - /* contains the location (for use with the reader) of the prefix byte */ - uint64_t prefixLocations[0x100]; /* The type of the vector extension prefix */ VectorExtensionType vectorExtensionType; /* The location where a mandatory prefix would have to be (i.e., right before