diff options
author | 2015-09-14 18:05:33 +0600 | |
---|---|---|
committer | 2016-01-21 03:33:37 +0000 | |
commit | 4414822df8483d499fbac02563ebe8c7fc000563 (patch) | |
tree | bb28eecb8be4603c0ce6e9cd28d93c4983689c46 /disassembler/disassembler_x86.cc | |
parent | 6aadaef35ea52506db61e463910c2520b702ca5e (diff) |
ART: disassembler_x86 doesn't recognize NOPs
There are some variations of NOPs which are possible on x86.
Change-Id: I6aab3bc98682e521532cc746f3a371d9c5d98ee8
Diffstat (limited to 'disassembler/disassembler_x86.cc')
-rw-r--r-- | disassembler/disassembler_x86.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/disassembler/disassembler_x86.cc b/disassembler/disassembler_x86.cc index d4bef0fe7b..34d90ed09e 100644 --- a/disassembler/disassembler_x86.cc +++ b/disassembler/disassembler_x86.cc @@ -243,7 +243,38 @@ std::string DisassemblerX86::DumpAddress(uint8_t mod, uint8_t rm, uint8_t rex64, return address.str(); } +size_t DisassemblerX86::DumpNops(std::ostream& os, const uint8_t* instr) { +static constexpr uint8_t kNops[][10] = { + { }, + { 0x90 }, + { 0x66, 0x90 }, + { 0x0f, 0x1f, 0x00 }, + { 0x0f, 0x1f, 0x40, 0x00 }, + { 0x0f, 0x1f, 0x44, 0x00, 0x00 }, + { 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00 }, + { 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00 }, + { 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 } + }; + + for (size_t i = 1; i < arraysize(kNops); ++i) { + if (memcmp(instr, kNops[i], i) == 0) { + os << FormatInstructionPointer(instr) + << StringPrintf(": %22s \t nop \n", DumpCodeHex(instr, instr + i).c_str()); + return i; + } + } + + return 0; +} + size_t DisassemblerX86::DumpInstruction(std::ostream& os, const uint8_t* instr) { + size_t nop_size = DumpNops(os, instr); + if (nop_size != 0u) { + return nop_size; + } + const uint8_t* begin_instr = instr; bool have_prefixes = true; uint8_t prefix[4] = {0, 0, 0, 0}; @@ -400,6 +431,7 @@ DISASSEMBLER_ENTRY(cmp, case 0x89: opcode1 = "mov"; store = true; has_modrm = true; break; case 0x8A: opcode1 = "mov"; load = true; has_modrm = true; byte_operand = true; break; case 0x8B: opcode1 = "mov"; load = true; has_modrm = true; break; + case 0x9D: opcode1 = "popf"; break; case 0x0F: // 2 byte extended opcode instr++; |