ROSE
0.9.6a
|
Disassembler for the x86 architecture. More...
#include <DisassemblerX86.h>
Classes | |
class | ExceptionX86 |
Same as Disassembler::Exception except with a different constructor for ease of use in DisassemblerX86. More... | |
Public Member Functions | |
DisassemblerX86 (size_t wordsize) | |
DisassemblerX86 (const DisassemblerX86 &other) | |
virtual | ~DisassemblerX86 () |
virtual DisassemblerX86 * | clone () const |
Creates a new copy of a disassembler. More... | |
virtual bool | can_disassemble (SgAsmGenericHeader *) const |
See Disassembler::can_disassemble. More... | |
virtual SgAsmInstruction * | disassembleOne (const MemoryMap *map, rose_addr_t start_va, AddressSet *successors=NULL) |
See Disassembler::disassembleOne. More... | |
virtual SgAsmInstruction * | make_unknown_instruction (const Exception &) |
Make an unknown instruction from an exception. More... | |
Public Member Functions inherited from Disassembler | |
Disassembler () | |
Disassembler (const Disassembler &other) | |
virtual | ~Disassembler () |
void | disassemble (SgAsmInterpretation *, AddressSet *successors=NULL, BadMap *bad=NULL) |
This high-level method disassembles instructions belonging to part of a file described by an executable file header as indicated by the specified interpretation. More... | |
void | set_registers (const RegisterDictionary *rdict) |
Specifies the registers available on this architecture. More... | |
const RegisterDictionary * | get_registers () const |
Returns the dictionary used for looking up register names. More... | |
void | set_partitioner (class Partitioner *p) |
Specifies the instruction partitioner to use when partitioning instructions into functions. More... | |
class Partitioner * | get_partitioner () const |
Returns the partitioner object set by set_partitioner(). More... | |
void | set_search (unsigned bits) |
Specifies the heuristics used when searching for instructions. More... | |
unsigned | get_search () const |
Returns a bit mask of SearchHeuristic bits representing which heuristics would be used when searching for instructions. More... | |
void | set_wordsize (size_t) |
Specifies the word size for the SEARCH_WORDS heuristic. More... | |
size_t | get_wordsize () const |
Returns the word size used by the SEARCH_WORDS heuristic. More... | |
void | set_alignment (size_t) |
Specifies the alignment for the SEARCH_WORDS heuristic. More... | |
size_t | get_alignment () const |
Returns the alignment used by the SEARCH_WORDS heuristic. More... | |
void | set_sex (ByteOrder::Endianness sex) |
Specifies the byte order for the SEARCH_WORDS heuristic. More... | |
ByteOrder::Endianness | get_sex () const |
Returns the byte order used by the SEARCH_WORDS heuristic. More... | |
void | set_debug (FILE *f) |
Sends disassembler diagnostics to the specified output stream. More... | |
FILE * | get_debug () const |
Returns the file currently used for debugging; null implies no debugging. More... | |
size_t | get_ndisassembled () const |
Returns the number of instructions successfully disassembled. More... | |
void | set_protection (unsigned bitvec) |
Normally the disassembler will only read memory when the execute permission is turned on for the memory. More... | |
unsigned | get_protection () const |
Returns a bit vector describing which bits must be enabled in the MemoryMap in order for the disassembler to read from that memory. More... | |
void | set_progress_reporting (FILE *, unsigned min_interval) |
Set progress reporting properties. More... | |
SgAsmInstruction * | disassembleOne (const unsigned char *buf, rose_addr_t buf_va, size_t buf_size, rose_addr_t start_va, AddressSet *successors=NULL) |
Similar in functionality to the disassembleOne method that takes a MemoryMap argument, except the content buffer is mapped 1:1 to virtual memory beginning at the specified address. More... | |
InstructionMap | disassembleBlock (const MemoryMap *map, rose_addr_t start_va, AddressSet *successors=NULL, InstructionMap *cache=NULL) |
Like the disassembleOne method except it disassembles a basic block's worth of instructions beginning at the specified virtual address. More... | |
InstructionMap | disassembleBlock (const unsigned char *buf, rose_addr_t buf_va, size_t buf_size, rose_addr_t start_va, AddressSet *successors=NULL, InstructionMap *cache=NULL) |
Similar in functionality to the disassembleBlock method that takes a MemoryMap argument, except the supplied buffer is mapped 1:1 to virtual memory beginning at the specified address. More... | |
InstructionMap | disassembleBuffer (const MemoryMap *map, size_t start_va, AddressSet *successors=NULL, BadMap *bad=NULL) |
Disassembles instructions from the content buffer beginning at the specified virtual address and including all instructions that are direct or indirect successors of the first instruction. More... | |
InstructionMap | disassembleBuffer (const unsigned char *buf, rose_addr_t buf_va, size_t buf_size, rose_addr_t start_va, AddressSet *successors=NULL, BadMap *bad=NULL) |
Similar in functionality to the disassembleBuffer methods that take a MemoryMap argument, except the supplied buffer is mapped 1:1 to virtual memory beginning at the specified address. More... | |
InstructionMap | disassembleBuffer (const MemoryMap *map, AddressSet workset, AddressSet *successors=NULL, BadMap *bad=NULL) |
Similar in functionality to the disassembleBuffer methods that take a single starting virtual address, except this one tries to disassemble from all the addresses specified in the workset. More... | |
InstructionMap | disassembleSection (SgAsmGenericSection *section, rose_addr_t section_va, rose_addr_t start_offset, AddressSet *successors=NULL, BadMap *bad=NULL) |
Disassembles instructions in the specified section by assuming that it's mapped to a particular starting address. More... | |
InstructionMap | disassembleInterp (SgAsmInterpretation *interp, AddressSet *successors=NULL, BadMap *bad=NULL) |
Disassembles instructions in a particular binary interpretation. More... | |
void | search_following (AddressSet *worklist, const InstructionMap &bb, rose_addr_t bb_va, const MemoryMap *map, const InstructionMap &tried) |
Adds the address following a basic block to the list of addresses that should be disassembled. More... | |
void | search_immediate (AddressSet *worklist, const InstructionMap &bb, const MemoryMap *map, const InstructionMap &tried) |
Adds values of immediate operands to the list of addresses that should be disassembled. More... | |
void | search_words (AddressSet *worklist, const MemoryMap *map, const InstructionMap &tried) |
Adds all word-aligned values to work list, provided they specify a virtual address in the map . More... | |
void | search_next_address (AddressSet *worklist, rose_addr_t start_va, const MemoryMap *map, const InstructionMap &insns, const InstructionMap &tried, bool avoid_overlaps) |
Finds the lowest virtual address, greater than or equal to start_va , which does not correspond to a previous disassembly attempt as evidenced by its presence in the supplied instructions or bad map. More... | |
void | search_function_symbols (AddressSet *worklist, const MemoryMap *, SgAsmGenericHeader *) |
Adds addresses that correspond to function symbols. More... | |
void | update_progress (SgAsmInstruction *) |
Updates progress information. More... | |
void | progress (FILE *, const char *fmt,...) const __attribute__((format(printf |
Conditionally prints a progress report. More... | |
void | mark_referenced_instructions (SgAsmInterpretation *, const MemoryMap *, const InstructionMap &) |
Marks parts of the file that correspond to instructions as having been referenced. More... | |
AddressSet | get_block_successors (const InstructionMap &, bool *complete) |
Calculates the successor addresses of a basic block and adds them to a successors set. More... | |
Private Types | |
enum | RegisterMode { rmLegacyByte, rmRexByte, rmWord, rmDWord, rmQWord, rmSegment, rmST, rmMM, rmXMM, rmControl, rmDebug, rmReturnNull } |
ModR/M settings that create register expressions (or rmReturnNull for no register) More... | |
enum | MMPrefix { mmNone, mmF3, mm66, mmF2 } |
Private Member Functions | |
uint8_t | getByte () |
Returns the next byte of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More... | |
uint16_t | getWord () |
Returns the next two-byte, little endian word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More... | |
uint32_t | getDWord () |
Returns the next four-byte, little endian double word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More... | |
uint64_t | getQWord () |
Returns the next eight-byte, little endian quad word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More... | |
SgAsmExpression * | currentDataSegment () const |
Constructs a register reference expression for the current data segment based on whether a segment override prefix has been encountered. More... | |
X86InstructionSize | effectiveAddressSize () const |
Returns the size of instruction addresses. More... | |
RegisterMode | effectiveOperandMode () const |
Returns the register mode for the instruction's effective operand size. More... | |
X86InstructionSize | effectiveOperandSize () const |
Returns the size of the operands. More... | |
SgAsmType * | effectiveOperandType () const |
Returns the data type for the instruction's effective operand size. More... | |
bool | longMode () const |
Returns true if we're disassembling 64-bit code. More... | |
MMPrefix | mmPrefix () const |
void | not64 () const |
Throws an exception if the instruction being disassembled is not valid for 64-bit mode. More... | |
void | setRex (uint8_t prefix) |
Sets the rexPresent flag along with rexW, rexR, rexX, and/or rexB based on the instruction prefix, which should be a value between 0x40 and 0x4f, inclusive. More... | |
SgAsmExpression * | makeAddrSizeValue (int64_t val, size_t bit_offset, size_t bit_size) |
Constructs an expression for the specified address size. More... | |
SgAsmx86Instruction * | makeInstruction (X86InstructionKind kind, const std::string &mnemonic, SgAsmExpression *op1=NULL, SgAsmExpression *op2=NULL, SgAsmExpression *op3=NULL, SgAsmExpression *op4=NULL) |
Creates an instruction with optional operands. More... | |
SgAsmx86RegisterReferenceExpression * | makeIP () |
Constructs a register reference expression for the instruction pointer register. More... | |
SgAsmx86RegisterReferenceExpression * | makeOperandRegisterByte (bool rexExtension, uint8_t registerNumber) |
SgAsmx86RegisterReferenceExpression * | makeOperandRegisterFull (bool rexExtension, uint8_t registerNumber) |
SgAsmx86RegisterReferenceExpression * | makeRegister (uint8_t fullRegisterNumber, RegisterMode, SgAsmType *registerType=NULL) const |
Constructs a register reference expression. More... | |
SgAsmx86RegisterReferenceExpression * | makeRegisterEffective (uint8_t fullRegisterNumber) |
SgAsmx86RegisterReferenceExpression * | makeRegisterEffective (bool rexExtension, uint8_t registerNumber) |
SgAsmExpression * | makeSegmentRegister (X86SegmentRegister so, bool insn64) const |
Constructs a register reference expression for a segment register. More... | |
void | getModRegRM (RegisterMode regMode, RegisterMode rmMode, SgAsmType *t, SgAsmType *tForReg=NULL) |
Decodes the ModR/M byte of an instruction. More... | |
SgAsmMemoryReferenceExpression * | decodeModrmMemory () |
Decodes the ModR/M byte to a memory reference expression. More... | |
void | fillInModRM (RegisterMode rmMode, SgAsmType *t) |
If ModR/M is a memory reference, fill in its type; otherwise, make a register with the appropriate mode and put it into the modrm data member. More... | |
SgAsmExpression * | makeModrmNormal (RegisterMode, SgAsmType *mrType) |
Builds the register or memory reference expression for the ModR/M byte. More... | |
SgAsmx86RegisterReferenceExpression * | makeModrmRegister (RegisterMode, SgAsmType *mrType=NULL) |
Builds the register reference expression for the ModR/M byte. More... | |
void | requireMemory () const |
Throw an exceptions if the instruction requires the "Mod" part of the ModR/M byte to have the value 3. More... | |
SgAsmExpression * | getImmByte () |
SgAsmExpression * | getImmWord () |
SgAsmExpression * | getImmDWord () |
SgAsmExpression * | getImmQWord () |
SgAsmExpression * | getImmForAddr () |
SgAsmExpression * | getImmIv () |
SgAsmExpression * | getImmJz () |
SgAsmExpression * | getImmByteAsIv () |
SgAsmExpression * | getImmIzAsIv () |
SgAsmExpression * | getImmJb () |
SgAsmx86Instruction * | disassemble () |
Disassembles an instruction. More... | |
SgAsmx86Instruction * | decodeOpcode0F () |
Disassemble an instruction following the 0x0f prefix. More... | |
SgAsmx86Instruction * | decodeOpcode0F38 () |
Disassemble SSE3 instructions. More... | |
SgAsmx86Instruction * | decodeX87InstructionD8 () |
Disassembles an instruction with primary opcode 0xd8. More... | |
SgAsmx86Instruction * | decodeX87InstructionD9 () |
Disassembles an instruction with primary opcode 0xd9. More... | |
SgAsmx86Instruction * | decodeX87InstructionDA () |
Disassembles an instruction with primary opcode 0xda. More... | |
SgAsmx86Instruction * | decodeX87InstructionDB () |
Disassembles an instruction with primary opcode 0xdb. More... | |
SgAsmx86Instruction * | decodeX87InstructionDC () |
Disassembles an instruction with primary opcode 0xdc. More... | |
SgAsmx86Instruction * | decodeX87InstructionDD () |
Disassembles an instruction with primary opcode 0xdd. More... | |
SgAsmx86Instruction * | decodeX87InstructionDE () |
Disassembles an instruction with primary opcode 0xde. More... | |
SgAsmx86Instruction * | decodeX87InstructionDF () |
Disassembles an instruction with primary opcode 0xdf. More... | |
SgAsmx86Instruction * | decodeGroup1 (SgAsmExpression *imm) |
Disassembles ADD, OR, ADC, SBB, AND, SUB, XOR, CMP. More... | |
SgAsmx86Instruction * | decodeGroup1a () |
Disassembles POP. More... | |
SgAsmx86Instruction * | decodeGroup2 (SgAsmExpression *count) |
Disassembles ROL, ROR, RCL, RCR, SHL, SHR, SHL, SAR. More... | |
SgAsmx86Instruction * | decodeGroup3 (SgAsmExpression *immMaybe) |
Disassembles TEST, NOT, NEG, MUL, IMUL, DIV, IDIV. More... | |
SgAsmx86Instruction * | decodeGroup4 () |
Disassembles INC, DEC. More... | |
SgAsmx86Instruction * | decodeGroup5 () |
Disassembles INC, DEC, CALL, FARCALL, JMP, FARJMP, PUSH. More... | |
SgAsmx86Instruction * | decodeGroup6 () |
Disassembles SLDT, STR, LLDT, LTR, VERR, VERW. More... | |
SgAsmx86Instruction * | decodeGroup7 () |
Disassembles VMCALL, VMLAUNCH, VMRESUME, VMXOFF, SGDT, MONITOR, MWAIT, SIDT, SGDT, XGETBV, XSETBV, LGDT, VMRUN, VMMCALL, VMLOAD, VMSAVE, STGI, CLGI, SKINIT, INVLPGA, LIDT, SMSW, LMSW, SWAPGS, RDTSCP, INVLPG. More... | |
SgAsmx86Instruction * | decodeGroup8 (SgAsmExpression *imm) |
Disassembles BT, BTS, BTR, BTC. More... | |
SgAsmx86Instruction * | decodeGroup11 (SgAsmExpression *imm) |
Disassembles MOV. More... | |
SgAsmx86Instruction * | decodeGroup15 () |
Disassembles FXSAVE, FXRSTOR, LDMXCSR, STMXCSR, XSAVE, LFENCE, XRSTOR, MFENCE, SFENCE, CLFLUSH. More... | |
SgAsmx86Instruction * | decodeGroup16 () |
Disassembles PREFETCHNTA, PREFETCH0, PREFETCH1, PREFETCH2, PREFETCH. More... | |
SgAsmx86Instruction * | decodeGroupP () |
Disassembles PREFETCH, PREFETCHW. More... | |
void | init (size_t wordsize) |
Initialize instances of this class. More... | |
void | startInstruction (SgAsmx86Instruction *insn) |
Resets disassembler state to beginning of an instruction for assembly. More... | |
void | startInstruction (rose_addr_t start_va, const uint8_t *buf, size_t bufsz) |
Resets disassembler state to beginning of an instruction for disassembly. More... | |
Static Private Member Functions | |
static RegisterMode | sizeToMode (X86InstructionSize) |
Returns the register mode for the specified instruction size. More... | |
static SgAsmType * | sizeToType (X86InstructionSize s) |
Returns a data type associated with an instruction size. More... | |
Private Attributes | |
X86InstructionSize | insnSize |
Default size of instructions, based on architecture; see init() More... | |
uint64_t | ip |
Virtual address for start of instruction. More... | |
SgUnsignedCharList | insnbuf |
Buffer containing bytes of instruction. More... | |
size_t | insnbufat |
Index of next byte to be read from or write to insnbuf. More... | |
X86SegmentRegister | segOverride |
Set by 0x26,0x2e,0x36,0x3e,0x64,0x65 prefixes. More... | |
X86BranchPrediction | branchPrediction |
bool | branchPredictionEnabled |
bool | rexPresent |
bool | rexW |
bool | rexR |
bool | rexX |
bool | rexB |
Set by 0x40-0x4f prefixes; extended registers present; see setRex() More... | |
bool | sizeMustBe64Bit |
Set if effective operand size must be 64 bits. More... | |
bool | operandSizeOverride |
Set by the 0x66 prefix; used by effectiveOperandSize() and mmPrefix() More... | |
bool | addressSizeOverride |
Set by the 0x67 prefix; used by effectiveAddressSize() More... | |
bool | lock |
Set by the 0xf0 prefix. More... | |
X86RepeatPrefix | repeatPrefix |
Set by 0xf2 (repne) and 0xf3 (repe) prefixes. More... | |
bool | modregrmByteSet |
True if modregrmByte is initialized. More... | |
uint8_t | modregrmByte |
Set by instructions that use ModR/M when the ModR/M byte is read. More... | |
uint8_t | modeField |
Value (0-3) of high-order two bits of modregrmByte; see getModRegRM() More... | |
uint8_t | regField |
Value (0-7) of bits 3-5 inclusive of modregrmByte; see getModRegRM() More... | |
uint8_t | rmField |
Value (0-7) of bits 0-3 inclusive of modregrmByte; see getModRegRM() More... | |
SgAsmExpression * | modrm |
Register or memory ref expr built from modregrmByte; see getModRegRM() More... | |
SgAsmExpression * | reg |
Register reference expression built from modregrmByte; see getModRegRM() More... | |
bool | isUnconditionalJump |
True for jmp, farjmp, ret, retf, iret, and hlt. More... | |
Additional Inherited Members | |
Public Types inherited from Disassembler | |
enum | SearchHeuristic { SEARCH_FOLLOWING = 0x0001, SEARCH_IMMEDIATE = 0x0002, SEARCH_WORDS = 0x0004, SEARCH_ALLBYTES = 0x0008, SEARCH_UNUSED = 0x0010, SEARCH_NONEXE = 0x0020, SEARCH_DEADEND = 0x0040, SEARCH_UNKNOWN = 0x0080, SEARCH_FUNCSYMS = 0x0100, SEARCH_DEFAULT = 0x0101 } |
Heuristics used to find instructions to disassemble. More... | |
typedef std::set< rose_addr_t > | AddressSet |
An AddressSet contains virtual addresses (alternatively, relative virtual addresses) for such things as specifying which virtual addresses should be disassembled. More... | |
typedef Map< rose_addr_t, SgAsmInstruction * > | InstructionMap |
The InstructionMap is a mapping from (absolute) virtual address to disassembled instruction. More... | |
typedef Map< rose_addr_t, Exception > | BadMap |
The BadMap is a mapping from (absolute) virtual address to information about a failed disassembly attempt at that address. More... | |
Static Public Member Functions inherited from Disassembler | |
static unsigned | parse_switches (const std::string &s, unsigned initial=SEARCH_DEFAULT) |
Given a string (presumably from the ROSE command-line), parse it and return the bit vector describing which search heuristics should be employed by the disassembler. More... | |
static void | register_subclass (Disassembler *) |
Register a disassembler instance. More... | |
static Disassembler * | lookup (SgAsmGenericHeader *) |
Finds a suitable disassembler. More... | |
static Disassembler * | lookup (SgAsmInterpretation *) |
Finds a suitable disassembler. More... | |
static void | disassembleInterpretation (SgAsmInterpretation *) |
This class method is for backward compatibility with the disassembleInterpretation() function in the old Disassembler namespace. More... | |
Protected Attributes inherited from Disassembler | |
const RegisterDictionary * | p_registers |
Description of registers available for this platform. More... | |
class Partitioner * | p_partitioner |
Used for placing instructions into blocks and functions. More... | |
unsigned | p_search |
Mask of SearchHeuristic bits specifying instruction searching. More... | |
FILE * | p_debug |
Set to non-null to get debugging info. More... | |
size_t | p_wordsize |
Word size used by SEARCH_WORDS. More... | |
ByteOrder::Endianness | p_sex |
Byte order for SEARCH_WORDS. More... | |
size_t | p_alignment |
Word alignment constraint for SEARCH_WORDS (0 and 1 imply byte). More... | |
size_t | p_ndisassembled |
Total number of instructions disassembled by disassembleBlock() More... | |
unsigned | p_protection |
Memory protection bits that must be set to disassemble. More... | |
Static Protected Attributes inherited from Disassembler | |
static std::vector < Disassembler * > | disassemblers |
List of disassembler subclasses. More... | |
static time_t | progress_interval = 10 |
Minimum interval between progress reports. More... | |
static time_t | progress_time = 0 |
Time of last report, or zero if no report has been generated. More... | |
static FILE * | progress_file = stderr |
File to which reports are made. More... | |
static RTS_mutex_t | class_mutex = RTS_MUTEX_INITIALIZER(RTS_LAYER_DISASSEMBLER_CLASS) |
Mutex for class-wide thread safety. More... | |
Disassembler for the x86 architecture.
Most of the useful disassembly methods can be found in the superclass. There's really not much reason to use this class directly or to call any of these methods directly.
Definition at line 11 of file DisassemblerX86.h.
|
private |
ModR/M settings that create register expressions (or rmReturnNull for no register)
Enumerator | |
---|---|
rmLegacyByte | |
rmRexByte | |
rmWord | |
rmDWord | |
rmQWord | |
rmSegment | |
rmST | |
rmMM | |
rmXMM | |
rmControl | |
rmDebug | |
rmReturnNull |
Definition at line 72 of file DisassemblerX86.h.
|
private |
Enumerator | |
---|---|
mmNone | |
mmF3 | |
mm66 | |
mmF2 |
Definition at line 78 of file DisassemblerX86.h.
|
inline |
|
inline |
Definition at line 27 of file DisassemblerX86.h.
|
inlinevirtual |
Definition at line 38 of file DisassemblerX86.h.
|
inlinevirtual |
Creates a new copy of a disassembler.
The new copy has all the same settings as the original.
Thread safety: The thread safety of this virtual method depends on the implementation in the subclass.
Implements Disassembler.
Definition at line 40 of file DisassemblerX86.h.
References DisassemblerX86().
|
virtual |
See Disassembler::can_disassemble.
Implements Disassembler.
Definition at line 46 of file DisassemblerX86.C.
References SgAsmGenericHeader::get_isa(), Disassembler::get_wordsize(), SgAsmExecutableFileFormat::ISA_FAMILY_MASK, SgAsmExecutableFileFormat::ISA_IA32_Family, SgAsmExecutableFileFormat::ISA_X8664_Family, and isSgAsmDOSFileHeader().
|
virtual |
See Disassembler::disassembleOne.
Implements Disassembler.
Definition at line 80 of file DisassemblerX86.C.
References disassemble(), Disassembler::get_protection(), SgAsmx86Instruction::get_successors(), MemoryMap::read(), startInstruction(), and Disassembler::update_progress().
|
virtual |
Make an unknown instruction from an exception.
Implements Disassembler.
Definition at line 111 of file DisassemblerX86.C.
References Disassembler::Exception::bytes, makeInstruction(), SgAsmInstruction::set_raw_bytes(), and x86_unknown_instruction.
|
private |
Returns the next byte of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().
Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.
Definition at line 124 of file DisassemblerX86.C.
References insnbuf, and insnbufat.
Referenced by decodeModrmMemory(), decodeOpcode0F(), decodeOpcode0F38(), disassemble(), getImmByte(), getImmByteAsIv(), getImmJb(), getModRegRM(), and getWord().
|
private |
Returns the next two-byte, little endian word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().
Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.
Definition at line 134 of file DisassemblerX86.C.
References getByte().
Referenced by decodeModrmMemory(), getDWord(), getImmJz(), and getImmWord().
|
private |
Returns the next four-byte, little endian double word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().
Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.
Definition at line 142 of file DisassemblerX86.C.
References getWord().
Referenced by decodeModrmMemory(), getImmDWord(), getImmJz(), and getQWord().
|
private |
Returns the next eight-byte, little endian quad word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().
Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.
Definition at line 150 of file DisassemblerX86.C.
References getDWord().
Referenced by getImmQWord().
|
private |
Constructs a register reference expression for the current data segment based on whether a segment override prefix has been encountered.
Definition at line 165 of file DisassemblerX86.C.
References insnSize, makeSegmentRegister(), segOverride, x86_insnsize_64, x86_segreg_ds, and x86_segreg_none.
Referenced by disassemble().
|
private |
Returns the size of instruction addresses.
The effective address size is normally based on the default instruction size. However, if the disassembler encounters the 0x67 instruction prefix ("Address-size Override Prefix") as indicated by the addressSizeOverride data member being set, then other sizes are used. See pattent 6571330.
Definition at line 172 of file DisassemblerX86.C.
References addressSizeOverride, insnSize, x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by decodeModrmMemory(), getImmForAddr(), makeAddrSizeValue(), and makeInstruction().
|
inlineprivate |
Returns the register mode for the instruction's effective operand size.
Definition at line 125 of file DisassemblerX86.h.
References effectiveOperandSize(), and sizeToMode().
Referenced by decodeGroup7(), decodeOpcode0F(), disassemble(), and makeRegisterEffective().
|
private |
Returns the size of the operands.
The operand size is normally based on the default instruction size; however, if the disassembler encounters the 0x66 instruction prefix ("Precision-size Override Prefix") as indicated by the operandSizeOverride data member being set, then other sizes are used. See pattent 6571330.
Definition at line 187 of file DisassemblerX86.C.
References insnSize, operandSizeOverride, rexPresent, rexW, sizeMustBe64Bit, x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by decodeOpcode0F(), disassemble(), effectiveOperandMode(), effectiveOperandType(), getImmIv(), getImmIzAsIv(), getImmJz(), and makeInstruction().
|
inlineprivate |
Returns the data type for the instruction's effective operand size.
Definition at line 135 of file DisassemblerX86.h.
References effectiveOperandSize(), and sizeToType().
Referenced by decodeOpcode0F(), and disassemble().
|
inlineprivate |
Returns true if we're disassembling 64-bit code.
Definition at line 140 of file DisassemblerX86.h.
References insnSize, and x86_insnsize_64.
Referenced by disassemble(), and not64().
|
private |
Definition at line 216 of file DisassemblerX86.C.
References mm66, mmF2, mmF3, mmNone, operandSizeOverride, repeatPrefix, x86_repeat_none, x86_repeat_repe, and x86_repeat_repne.
Referenced by decodeOpcode0F(), and decodeOpcode0F38().
|
inlineprivate |
Throws an exception if the instruction being disassembled is not valid for 64-bit mode.
Definition at line 148 of file DisassemblerX86.h.
References longMode().
Referenced by decodeOpcode0F(), and disassemble().
|
private |
Sets the rexPresent flag along with rexW, rexR, rexX, and/or rexB based on the instruction prefix, which should be a value between 0x40 and 0x4f, inclusive.
Definition at line 245 of file DisassemblerX86.C.
References rexB, rexPresent, rexR, rexW, and rexX.
Referenced by disassemble().
|
staticprivate |
Returns the register mode for the specified instruction size.
Definition at line 255 of file DisassemblerX86.C.
References rmDWord, rmQWord, rmWord, x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by decodeModrmMemory(), effectiveOperandMode(), and makeOperandRegisterFull().
|
staticprivate |
Returns a data type associated with an instruction size.
For instance, a 32-bit instruction returns the type for a double word.
Definition at line 266 of file DisassemblerX86.C.
References SgAsmTypeWord::createType(), SgAsmTypeDoubleWord::createType(), SgAsmTypeQuadWord::createType(), x86_insnsize_16, x86_insnsize_32, x86_insnsize_64, and x86_insnsize_none.
Referenced by effectiveOperandType(), and makeIP().
|
private |
Constructs an expression for the specified address size.
The bit_offset
and bit_size
are the offset and size where val
was found in the instruction raw bytes.
Definition at line 286 of file DisassemblerX86.C.
References effectiveAddressSize(), SageBuilderAsm::makeDWordValue(), SageBuilderAsm::makeQWordValue(), SageBuilderAsm::makeWordValue(), SgAsmValueExpression::set_bit_offset(), SgAsmValueExpression::set_bit_size(), x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by decodeModrmMemory().
|
private |
Creates an instruction with optional operands.
Many of the instruction attributes come from the current state of this disassembler object (see the instruction-related data members below). In order that the new instruction contains the correct number of raw instruction bytes (p_raw_bytes) it should be called after all the instruction bytes have been read, otherwise remember to call set_raw_bytes() explicitly.
Definition at line 308 of file DisassemblerX86.C.
References SageBuilderAsm::appendOperand(), branchPrediction, branchPredictionEnabled, effectiveAddressSize(), effectiveOperandSize(), insnbuf, insnbufat, insnSize, ip, lock, repeatPrefix, segOverride, SgAsmx86Instruction::set_branchPrediction(), SgAsmx86Instruction::set_lockPrefix(), SgAsmInstruction::set_operandList(), SgNode::set_parent(), SgAsmInstruction::set_raw_bytes(), SgAsmx86Instruction::set_repeatPrefix(), SgAsmx86Instruction::set_segmentOverride(), and x86_segreg_none.
Referenced by decodeGroup1(), decodeGroup11(), decodeGroup15(), decodeGroup16(), decodeGroup1a(), decodeGroup2(), decodeGroup3(), decodeGroup4(), decodeGroup5(), decodeGroup6(), decodeGroup7(), decodeGroup8(), decodeGroupP(), decodeOpcode0F(), decodeOpcode0F38(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), disassemble(), and make_unknown_instruction().
|
private |
Constructs a register reference expression for the instruction pointer register.
Definition at line 347 of file DisassemblerX86.C.
References Disassembler::get_registers(), insnSize, RegisterDictionary::lookup(), name, SgAsmExpression::set_type(), sizeToType(), x86_insnsize_16, x86_insnsize_32, x86_insnsize_64, and x86_insnsize_none.
Referenced by decodeModrmMemory().
|
private |
Definition at line 365 of file DisassemblerX86.C.
References makeRegister(), rexPresent, rmLegacyByte, and rmRexByte.
Referenced by disassemble().
|
private |
Definition at line 372 of file DisassemblerX86.C.
References insnSize, makeRegister(), and sizeToMode().
Referenced by decodeModrmMemory().
|
private |
Constructs a register reference expression.
The registerType
is only used for vector registers that can have more than one type.
Definition at line 394 of file DisassemblerX86.C.
References BYTET, DWORDT, Disassembler::get_registers(), LDOUBLET, RegisterDictionary::lookup(), name, StringUtility::numberToString(), QWORDT, rmControl, rmDebug, rmDWord, rmLegacyByte, rmMM, rmQWord, rmReturnNull, rmRexByte, rmSegment, rmST, rmWord, rmXMM, SgAsmExpression::set_type(), and WORDT.
Referenced by decodeModrmMemory(), decodeOpcode0F(), decodeX87InstructionD8(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), disassemble(), fillInModRM(), makeModrmNormal(), makeModrmRegister(), makeOperandRegisterByte(), makeOperandRegisterFull(), makeRegisterEffective(), and makeSegmentRegister().
|
inlineprivate |
Definition at line 197 of file DisassemblerX86.h.
References effectiveOperandMode(), and makeRegister().
Referenced by decodeOpcode0F(), and disassemble().
|
inlineprivate |
Definition at line 202 of file DisassemblerX86.h.
References effectiveOperandMode(), and makeRegister().
|
private |
Constructs a register reference expression for a segment register.
Definition at line 495 of file DisassemblerX86.C.
References makeRegister(), rmSegment, x86_segreg_cs, x86_segreg_ds, x86_segreg_es, x86_segreg_fs, x86_segreg_gs, x86_segreg_none, and x86_segreg_ss.
Referenced by currentDataSegment(), and decodeModrmMemory().
|
private |
Decodes the ModR/M byte of an instruction.
The ModR/M byte is used to carry operand information when the first byte (after prefixes) cannot do so. It consists of three parts:
The regMode
is the register kind for the "R" bits and is used when constructing the DisassemblerX86::reg data member. The rmMode
is the register kind for the "RM" field when the mode refers to a register.
Definition at line 521 of file DisassemblerX86.C.
References getByte(), makeModrmNormal(), makeModrmRegister(), modeField, modregrmByte, modregrmByteSet, modrm, reg, regField, and rmField.
Referenced by decodeGroup15(), decodeGroup7(), decodeGroupP(), decodeOpcode0F(), decodeOpcode0F38(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), and disassemble().
|
private |
Decodes the ModR/M byte to a memory reference expression.
See makeModrmNormal().
Definition at line 535 of file DisassemblerX86.C.
References effectiveAddressSize(), getByte(), getDWord(), getWord(), insnbufat, insnSize, SageBuilderAsm::makeAdd(), makeAddrSizeValue(), SageBuilderAsm::makeByteValue(), SageBuilderAsm::makeDWordValue(), makeIP(), SageBuilderAsm::makeMemoryReference(), SageBuilderAsm::makeMul(), makeOperandRegisterFull(), makeRegister(), makeSegmentRegister(), SageBuilderAsm::makeWordValue(), modeField, modregrmByteSet, offset, rexB, rexX, rmField, rmWord, segOverride, SgAsmValueExpression::set_bit_offset(), SgAsmValueExpression::set_bit_size(), sizeToMode(), x86_insnsize_16, x86_insnsize_64, x86_segreg_ds, x86_segreg_none, and x86_segreg_ss.
Referenced by makeModrmNormal().
|
private |
If ModR/M is a memory reference, fill in its type; otherwise, make a register with the appropriate mode and put it into the modrm data member.
Definition at line 706 of file DisassemblerX86.C.
References isSgAsmMemoryReferenceExpression(), makeRegister(), modeField, modrm, rexB, rmField, and SgAsmExpression::set_type().
Referenced by decodeGroup15(), decodeGroup7(), decodeOpcode0F(), and disassemble().
|
private |
Builds the register or memory reference expression for the ModR/M byte.
See getModRegRM().
Definition at line 716 of file DisassemblerX86.C.
References decodeModrmMemory(), makeRegister(), modeField, modregrmByteSet, modrm, rexB, rexPresent, rmField, rmLegacyByte, rmRexByte, and SgAsmExpression::set_type().
Referenced by decodeX87InstructionD9(), decodeX87InstructionDB(), decodeX87InstructionDF(), and getModRegRM().
|
private |
Builds the register reference expression for the ModR/M byte.
See getModRegRM(). The mrType
is only used for vector registers.
Definition at line 732 of file DisassemblerX86.C.
References makeRegister(), modregrmByteSet, regField, rexPresent, rexR, rmLegacyByte, and rmRexByte.
Referenced by decodeOpcode0F(), decodeX87InstructionDA(), and getModRegRM().
|
inlineprivate |
Throw an exceptions if the instruction requires the "Mod" part of the ModR/M byte to have the value 3.
Definition at line 246 of file DisassemblerX86.h.
References modeField, and modregrmByteSet.
Referenced by decodeGroup15(), decodeGroup16(), decodeGroupP(), decodeOpcode0F(), and disassemble().
|
private |
Definition at line 749 of file DisassemblerX86.C.
References getByte(), insnbufat, SageBuilderAsm::makeByteValue(), SgAsmValueExpression::set_bit_offset(), and SgAsmValueExpression::set_bit_size().
Referenced by decodeOpcode0F(), and disassemble().
|
private |
Definition at line 759 of file DisassemblerX86.C.
References getWord(), insnbufat, SageBuilderAsm::makeWordValue(), SgAsmValueExpression::set_bit_offset(), and SgAsmValueExpression::set_bit_size().
Referenced by disassemble(), getImmForAddr(), getImmIv(), and getImmIzAsIv().
|
private |
Definition at line 769 of file DisassemblerX86.C.
References getDWord(), insnbufat, SageBuilderAsm::makeDWordValue(), SgAsmValueExpression::set_bit_offset(), and SgAsmValueExpression::set_bit_size().
Referenced by getImmForAddr(), getImmIv(), and getImmIzAsIv().
|
private |
Definition at line 779 of file DisassemblerX86.C.
References getQWord(), insnbufat, SageBuilderAsm::makeQWordValue(), SgAsmValueExpression::set_bit_offset(), and SgAsmValueExpression::set_bit_size().
Referenced by getImmForAddr(), and getImmIv().
|
private |
Definition at line 789 of file DisassemblerX86.C.
References effectiveAddressSize(), getImmDWord(), getImmQWord(), getImmWord(), x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by disassemble().
|
private |
Definition at line 800 of file DisassemblerX86.C.
References effectiveOperandSize(), getImmDWord(), getImmQWord(), getImmWord(), x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by disassemble().
|
private |
Definition at line 811 of file DisassemblerX86.C.
References effectiveOperandSize(), getDWord(), getWord(), insnbufat, insnSize, ip, SageBuilderAsm::makeDWordValue(), SageBuilderAsm::makeQWordValue(), SageBuilderAsm::makeWordValue(), SgAsmValueExpression::set_bit_offset(), SgAsmValueExpression::set_bit_size(), x86_insnsize_16, and x86_insnsize_32.
Referenced by decodeOpcode0F(), and disassemble().
|
private |
Definition at line 843 of file DisassemblerX86.C.
References getByte(), insnbufat, SageBuilderAsm::makeByteValue(), SgAsmValueExpression::set_bit_offset(), and SgAsmValueExpression::set_bit_size().
Referenced by disassemble().
|
private |
Definition at line 855 of file DisassemblerX86.C.
References effectiveOperandSize(), getImmDWord(), getImmWord(), x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by disassemble().
|
private |
Definition at line 871 of file DisassemblerX86.C.
References getByte(), insnbufat, insnSize, ip, SageBuilderAsm::makeDWordValue(), SageBuilderAsm::makeQWordValue(), SageBuilderAsm::makeWordValue(), SgAsmValueExpression::set_bit_offset(), SgAsmValueExpression::set_bit_size(), x86_insnsize_16, and x86_insnsize_32.
Referenced by disassemble().
|
private |
Disassembles an instruction.
This is the workhorse: it reads and decodes bytes of the instruction in a huge switch statement.
Definition at line 903 of file DisassemblerX86.C.
References addressSizeOverride, branchPrediction, branchPredictionEnabled, BYTET, currentDataSegment(), decodeGroup1(), decodeGroup11(), decodeGroup1a(), decodeGroup2(), decodeGroup3(), decodeGroup4(), decodeGroup5(), decodeOpcode0F(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), DWORDT, effectiveOperandMode(), effectiveOperandSize(), effectiveOperandType(), fillInModRM(), getByte(), getImmByte(), getImmByteAsIv(), getImmForAddr(), getImmIv(), getImmIzAsIv(), getImmJb(), getImmJz(), getImmWord(), getModRegRM(), isUnconditionalJump, lock, longMode(), SageBuilderAsm::makeByteValue(), makeInstruction(), SageBuilderAsm::makeMemoryReference(), makeOperandRegisterByte(), makeRegister(), makeRegisterEffective(), modrm, not64(), operandSizeOverride, reg, regField, repeatPrefix, requireMemory(), rexB, rmDWord, rmLegacyByte, rmReturnNull, rmSegment, rmWord, segOverride, setRex(), sizeMustBe64Bit, WORDT, x86_aaa, x86_aad, x86_aam, x86_aas, x86_adc, x86_add, x86_and, x86_arpl, x86_bound, x86_branch_prediction_not_taken, x86_branch_prediction_taken, x86_call, x86_cbw, x86_cdq, x86_cdqe, x86_clc, x86_cld, x86_cli, x86_cmc, x86_cmp, x86_cmpsb, x86_cmpsd, x86_cmpsq, x86_cmpsw, x86_cqo, x86_cwd, x86_cwde, x86_daa, x86_das, x86_dec, x86_enter, x86_farcall, x86_farjmp, x86_hlt, x86_imul, x86_in, x86_inc, x86_insb, x86_insd, x86_insnsize_16, x86_insnsize_32, x86_insnsize_64, x86_insw, x86_int, x86_int1, x86_int3, x86_into, x86_iret, x86_ja, x86_jae, x86_jb, x86_jbe, x86_jcxz, x86_je, x86_jecxz, x86_jg, x86_jge, x86_jl, x86_jle, x86_jmp, x86_jne, x86_jno, x86_jns, x86_jo, x86_jpe, x86_jpo, x86_jrcxz, x86_js, x86_lahf, x86_lds, x86_lea, x86_leave, x86_les, x86_lodsb, x86_lodsd, x86_lodsq, x86_lodsw, x86_loop, x86_loopnz, x86_loopz, x86_mov, x86_movsb, x86_movsd, x86_movsq, x86_movsw, x86_movsxd, x86_nop, x86_or, x86_out, x86_outsb, x86_outsd, x86_outsw, x86_pause, x86_pop, x86_popa, x86_popad, x86_popf, x86_popfd, x86_popfq, x86_push, x86_pusha, x86_pushad, x86_pushf, x86_pushfd, x86_pushfq, x86_rep_insb, x86_rep_insd, x86_rep_insw, x86_rep_lodsb, x86_rep_lodsd, x86_rep_lodsq, x86_rep_lodsw, x86_rep_movsb, x86_rep_movsd, x86_rep_movsq, x86_rep_movsw, x86_rep_outsb, x86_rep_outsd, x86_rep_outsw, x86_rep_stosb, x86_rep_stosd, x86_rep_stosq, x86_rep_stosw, x86_repe_cmpsb, x86_repe_cmpsd, x86_repe_cmpsq, x86_repe_cmpsw, x86_repe_scasb, x86_repe_scasd, x86_repe_scasq, x86_repe_scasw, x86_repeat_none, x86_repeat_repe, x86_repeat_repne, x86_repne_cmpsb, x86_repne_cmpsd, x86_repne_cmpsq, x86_repne_cmpsw, x86_repne_scasb, x86_repne_scasd, x86_repne_scasq, x86_repne_scasw, x86_ret, x86_retf, x86_sahf, x86_salc, x86_sbb, x86_scasb, x86_scasd, x86_scasq, x86_scasw, x86_segreg_cs, x86_segreg_ds, x86_segreg_es, x86_segreg_fs, x86_segreg_gs, x86_segreg_ss, x86_stc, x86_std, x86_sti, x86_stosb, x86_stosd, x86_stosq, x86_stosw, x86_sub, x86_test, x86_wait, x86_xchg, x86_xlatb, and x86_xor.
Referenced by disassembleOne().
|
private |
Disassemble an instruction following the 0x0f prefix.
Definition at line 2675 of file DisassemblerX86.C.
References branchPredictionEnabled, BYTET, decodeGroup15(), decodeGroup16(), decodeGroup6(), decodeGroup7(), decodeGroup8(), decodeGroupP(), decodeOpcode0F38(), DOUBLET, DQWORDT, DWORDT, effectiveOperandMode(), effectiveOperandSize(), effectiveOperandType(), fillInModRM(), FLOATT, getByte(), getImmByte(), getImmJz(), getModRegRM(), isSgAsmx86RegisterReferenceExpression(), isUnconditionalJump, makeInstruction(), makeModrmRegister(), makeRegister(), makeRegisterEffective(), mm66, mmF2, mmF3, mmNone, mmPrefix(), modeField, modrm, not64(), operandSizeOverride, QWORDT, reg, regField, repeatPrefix, requireMemory(), rexB, rmControl, rmDebug, rmDWord, rmLegacyByte, rmMM, rmReturnNull, rmSegment, rmWord, rmXMM, SgAsmExpression::set_type(), V16BYTET, V2DOUBLET, V2DWORDT, V2FLOATT, V2QWORDT, V4DWORDT, V4FLOATT, V4WORDT, V8BYTET, V8WORDT, WORDT, x86_addpd, x86_addps, x86_addsd, x86_addss, x86_addsubpd, x86_addsubps, x86_andnpd, x86_andnps, x86_andpd, x86_andps, x86_bsf, x86_bsr, x86_bswap, x86_bt, x86_btc, x86_btr, x86_bts, x86_clts, x86_cmova, x86_cmovae, x86_cmovb, x86_cmovbe, x86_cmove, x86_cmovg, x86_cmovge, x86_cmovl, x86_cmovle, x86_cmovne, x86_cmovno, x86_cmovns, x86_cmovo, x86_cmovpe, x86_cmovpo, x86_cmovs, x86_cmppd, x86_cmpps, x86_cmpsd, x86_cmpss, x86_cmpxchg, x86_cmpxchg16b, x86_cmpxchg8b, x86_comisd, x86_comiss, x86_cpuid, x86_cvtdq2pd, x86_cvtdq2ps, x86_cvtpd2dq, x86_cvtpd2pi, x86_cvtpd2ps, x86_cvtpi2pd, x86_cvtpi2ps, x86_cvtps2dq, x86_cvtps2pd, x86_cvtps2pi, x86_cvtsd2si, x86_cvtsd2ss, x86_cvtsi2sd, x86_cvtsi2ss, x86_cvtss2sd, x86_cvtss2si, x86_cvttpd2dq, x86_cvttpd2pi, x86_cvttps2dq, x86_cvttps2pi, x86_cvttsd2si, x86_cvttss2si, x86_divpd, x86_divps, x86_divsd, x86_divss, x86_emms, x86_extrq, x86_femms, x86_getsec, x86_haddpd, x86_haddps, x86_hsubpd, x86_hsubps, x86_imul, x86_insertq, x86_insnsize_64, x86_invd, x86_ja, x86_jae, x86_jb, x86_jbe, x86_je, x86_jg, x86_jge, x86_jl, x86_jle, x86_jmpe, x86_jne, x86_jno, x86_jns, x86_jo, x86_jpe, x86_jpo, x86_js, x86_lar, x86_lddqu, x86_lfs, x86_lgs, x86_lsl, x86_lss, x86_lzcnt, x86_maxpd, x86_maxps, x86_maxsd, x86_maxss, x86_minpd, x86_minps, x86_minsd, x86_minss, x86_mov, x86_movapd, x86_movaps, x86_movd, x86_movddup, x86_movdq2q, x86_movdqa, x86_movdqu, x86_movhlps, x86_movhpd, x86_movhps, x86_movlhps, x86_movlpd, x86_movlps, x86_movmskpd, x86_movmskps, x86_movntdq, x86_movnti, x86_movntpd, x86_movntps, x86_movntq, x86_movntsd, x86_movntss, x86_movq, x86_movq2dq, x86_movsd_sse, x86_movshdup, x86_movsldup, x86_movss, x86_movsx, x86_movupd, x86_movups, x86_movzx, x86_mulpd, x86_mulps, x86_mulsd, x86_mulss, x86_nop, x86_orpd, x86_orps, x86_packssdw, x86_packsswb, x86_packuswb, x86_paddb, x86_paddd, x86_paddq, x86_paddsb, x86_paddsw, x86_paddusb, x86_paddusw, x86_paddw, x86_palignr, x86_pand, x86_pandn, x86_pavgb, x86_pavgusb, x86_pavgw, x86_pcmpeqb, x86_pcmpeqd, x86_pcmpeqw, x86_pcmpgtb, x86_pcmpgtd, x86_pcmpgtw, x86_pextrw, x86_pf2id, x86_pf2iw, x86_pfacc, x86_pfadd, x86_pfcmpeq, x86_pfcmpge, x86_pfcmpgt, x86_pfmax, x86_pfmin, x86_pfmul, x86_pfnacc, x86_pfpnacc, x86_pfrcp, x86_pfrcpit1, x86_pfrcpit2, x86_pfrsqit1, x86_pfrsqrt, x86_pfsub, x86_pfsubr, x86_pi2fd, x86_pi2fw, x86_pinsrw, x86_pmaddwd, x86_pmaxsw, x86_pmaxub, x86_pminsw, x86_pminub, x86_pmovmskb, x86_pmulhrw, x86_pmulhuw, x86_pmulhw, x86_pmullw, x86_pmuludq, x86_pop, x86_popcnt, x86_por, x86_psadbw, x86_pshufd, x86_pshufhw, x86_pshuflw, x86_pshufw, x86_pslld, x86_pslldq, x86_psllq, x86_psllw, x86_psrad, x86_psraq, x86_psraw, x86_psrld, x86_psrldq, x86_psrlq, x86_psrlw, x86_psubb, x86_psubd, x86_psubq, x86_psubsb, x86_psubsw, x86_psubusb, x86_psubusw, x86_psubw, x86_pswapd, x86_punpckhbw, x86_punpckhdq, x86_punpckhqdq, x86_punpckhwd, x86_punpcklbw, x86_punpckldq, x86_punpcklqdq, x86_punpcklwd, x86_push, x86_pxor, x86_rcpps, x86_rcpss, x86_rdmsr, x86_rdpmc, x86_rdtsc, x86_repeat_repe, x86_rsm, x86_rsqrtps, x86_rsqrtss, x86_seta, x86_setae, x86_setb, x86_setbe, x86_sete, x86_setg, x86_setge, x86_setl, x86_setle, x86_setne, x86_setno, x86_setns, x86_seto, x86_setpe, x86_setpo, x86_sets, x86_shld, x86_shrd, x86_shufpd, x86_shufps, x86_sqrtpd, x86_sqrtps, x86_sqrtsd, x86_sqrtss, x86_subpd, x86_subps, x86_subsd, x86_subss, x86_syscall, x86_sysenter, x86_sysexit, x86_sysret, x86_ucomisd, x86_ucomiss, x86_ud2, x86_unpckhpd, x86_unpckhps, x86_unpcklpd, x86_unpcklps, x86_vmclear, x86_vmptrld, x86_vmptrst, x86_vmxon, x86_wbinvd, x86_wrmsr, x86_xadd, x86_xorpd, and x86_xorps.
Referenced by disassemble().
|
private |
Disassemble SSE3 instructions.
Definition at line 5120 of file DisassemblerX86.C.
References getByte(), getModRegRM(), makeInstruction(), mm66, mmF2, mmF3, mmNone, mmPrefix(), modrm, reg, rmMM, rmXMM, V2DWORDT, V4DWORDT, and x86_pshufb.
Referenced by decodeOpcode0F().
|
private |
Disassembles an instruction with primary opcode 0xd8.
Definition at line 5147 of file DisassemblerX86.C.
References FLOATT, getModRegRM(), isSgAsmMemoryReferenceExpression(), makeInstruction(), makeRegister(), modregrmByte, modrm, regField, rmReturnNull, rmST, SgAsmExpression::set_type(), x86_fadd, x86_fcom, x86_fcomp, x86_fdiv, x86_fdivr, x86_fmul, x86_fsub, and x86_fsubr.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xd9.
Definition at line 5181 of file DisassemblerX86.C.
References BYTET, FLOATT, getModRegRM(), isSgAsmMemoryReferenceExpression(), makeInstruction(), makeModrmNormal(), modeField, modregrmByte, modrm, regField, rmReturnNull, rmST, SgAsmExpression::set_type(), WORDT, x86_f2xm1, x86_fabs, x86_fchs, x86_fcos, x86_fdecstp, x86_fincstp, x86_fld, x86_fld1, x86_fldcw, x86_fldenv, x86_fldl2e, x86_fldl2t, x86_fldlg2, x86_fldln2, x86_fldpi, x86_fldz, x86_fnop, x86_fnstcw, x86_fnstenv, x86_fpatan, x86_fprem, x86_fprem1, x86_fptan, x86_frndint, x86_fscale, x86_fsin, x86_fsincos, x86_fsqrt, x86_fst, x86_fstp, x86_ftst, x86_fxam, x86_fxch, x86_fxtract, x86_fyl2x, and x86_fyl2xp1.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xda.
Definition at line 5259 of file DisassemblerX86.C.
References DWORDT, getModRegRM(), makeInstruction(), makeModrmRegister(), makeRegister(), modeField, modregrmByte, modrm, regField, rmReturnNull, rmST, x86_fcmovb, x86_fcmovbe, x86_fcmove, x86_fcmovu, x86_fiadd, x86_ficom, x86_ficomp, x86_fidiv, x86_fidivr, x86_fimul, x86_fisub, x86_fisubr, and x86_fucompp.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xdb.
Definition at line 5294 of file DisassemblerX86.C.
References DWORDT, getModRegRM(), isSgAsmMemoryReferenceExpression(), LDOUBLET, makeInstruction(), makeModrmNormal(), makeRegister(), modeField, modregrmByte, modrm, regField, rmReturnNull, rmST, SgAsmExpression::set_type(), x86_fcmovnb, x86_fcmovnbe, x86_fcmovne, x86_fcmovnu, x86_fcomi, x86_fild, x86_fist, x86_fistp, x86_fisttp, x86_fld, x86_fnclex, x86_fninit, x86_fstp, and x86_fucomi.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xdc.
Definition at line 5339 of file DisassemblerX86.C.
References DOUBLET, getModRegRM(), makeInstruction(), makeRegister(), modeField, modrm, regField, rmReturnNull, rmST, x86_fadd, x86_fcom, x86_fcomp, x86_fdiv, x86_fdivr, x86_fmul, x86_fsub, and x86_fsubr.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xdd.
Definition at line 5372 of file DisassemblerX86.C.
References BYTET, DOUBLET, getModRegRM(), isSgAsmMemoryReferenceExpression(), makeInstruction(), makeRegister(), modeField, modrm, QWORDT, regField, rmReturnNull, rmST, SgAsmExpression::set_type(), WORDT, x86_ffree, x86_fisttp, x86_fld, x86_fnsave, x86_fnstsw, x86_frstor, x86_fst, x86_fstp, x86_fucom, and x86_fucomp.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xde.
Definition at line 5423 of file DisassemblerX86.C.
References getModRegRM(), makeInstruction(), makeRegister(), modeField, modregrmByte, modrm, reg, regField, rmReturnNull, rmST, WORDT, x86_faddp, x86_fcompp, x86_fdivp, x86_fdivrp, x86_fiadd, x86_ficom, x86_ficomp, x86_fidiv, x86_fidivr, x86_fimul, x86_fisub, x86_fisubr, x86_fmulp, x86_fsubp, and x86_fsubrp.
Referenced by disassemble().
|
private |
Disassembles an instruction with primary opcode 0xdf.
Definition at line 5461 of file DisassemblerX86.C.
References BYTET, getModRegRM(), isSgAsmMemoryReferenceExpression(), makeInstruction(), makeModrmNormal(), makeRegister(), modeField, modregrmByte, modrm, QWORDT, regField, rmReturnNull, rmST, rmWord, SgAsmExpression::set_type(), WORDT, x86_fbld, x86_fbstp, x86_fcomip, x86_fild, x86_fist, x86_fistp, x86_fisttp, x86_fnstsw, and x86_fucomip.
Referenced by disassemble().
|
private |
Disassembles ADD, OR, ADC, SBB, AND, SUB, XOR, CMP.
Definition at line 5503 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, x86_adc, x86_add, x86_and, x86_cmp, x86_or, x86_sbb, x86_sub, and x86_xor.
Referenced by disassemble().
|
private |
Disassembles POP.
Definition at line 5521 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, and x86_pop.
Referenced by disassemble().
|
private |
Disassembles ROL, ROR, RCL, RCR, SHL, SHR, SHL, SAR.
Definition at line 5529 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, x86_rcl, x86_rcr, x86_rol, x86_ror, x86_sar, x86_shl, and x86_shr.
Referenced by disassemble().
|
private |
Disassembles TEST, NOT, NEG, MUL, IMUL, DIV, IDIV.
Definition at line 5547 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, x86_div, x86_idiv, x86_imul, x86_mul, x86_neg, x86_not, and x86_test.
Referenced by disassemble().
|
private |
Disassembles INC, DEC.
Definition at line 5574 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, x86_dec, and x86_inc.
Referenced by disassemble().
|
private |
Disassembles INC, DEC, CALL, FARCALL, JMP, FARJMP, PUSH.
Definition at line 5586 of file DisassemblerX86.C.
References isUnconditionalJump, makeInstruction(), modrm, regField, x86_call, x86_dec, x86_farcall, x86_farjmp, x86_inc, x86_jmp, and x86_push.
Referenced by disassemble().
|
private |
Disassembles SLDT, STR, LLDT, LTR, VERR, VERW.
Definition at line 5615 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, x86_lldt, x86_ltr, x86_sldt, x86_str, x86_verr, and x86_verw.
Referenced by decodeOpcode0F().
|
private |
Disassembles VMCALL, VMLAUNCH, VMRESUME, VMXOFF, SGDT, MONITOR, MWAIT, SIDT, SGDT, XGETBV, XSETBV, LGDT, VMRUN, VMMCALL, VMLOAD, VMSAVE, STGI, CLGI, SKINIT, INVLPGA, LIDT, SMSW, LMSW, SWAPGS, RDTSCP, INVLPG.
Definition at line 5633 of file DisassemblerX86.C.
References BYTET, effectiveOperandMode(), fillInModRM(), getModRegRM(), makeInstruction(), modeField, modrm, regField, rmField, rmReturnNull, rmWord, WORDT, x86_clgi, x86_invlpg, x86_invlpga, x86_lgdt, x86_lidt, x86_lmsw, x86_monitor, x86_mwait, x86_rdtscp, x86_sgdt, x86_sidt, x86_skinit, x86_smsw, x86_stgi, x86_swapgs, x86_vmcall, x86_vmlaunch, x86_vmload, x86_vmmcall, x86_vmresume, x86_vmrun, x86_vmsave, x86_vmxoff, x86_xgetbv, and x86_xsetbv.
Referenced by decodeOpcode0F().
|
private |
Disassembles BT, BTS, BTR, BTC.
Definition at line 5723 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, x86_bt, x86_btc, x86_btr, and x86_bts.
Referenced by decodeOpcode0F().
|
private |
Disassembles MOV.
Definition at line 5741 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, and x86_mov.
Referenced by disassemble().
|
private |
Disassembles FXSAVE, FXRSTOR, LDMXCSR, STMXCSR, XSAVE, LFENCE, XRSTOR, MFENCE, SFENCE, CLFLUSH.
Definition at line 5752 of file DisassemblerX86.C.
References BYTET, DWORDT, fillInModRM(), getModRegRM(), makeInstruction(), modeField, modrm, regField, requireMemory(), rmReturnNull, x86_clflush, x86_fxrstor, x86_fxsave, x86_ldmxcsr, x86_lfence, x86_mfence, x86_sfence, x86_stmxcsr, x86_xrstor, and x86_xsave.
Referenced by decodeOpcode0F().
|
private |
Disassembles PREFETCHNTA, PREFETCH0, PREFETCH1, PREFETCH2, PREFETCH.
Definition at line 5802 of file DisassemblerX86.C.
References makeInstruction(), modrm, regField, requireMemory(), x86_prefetch, x86_prefetchnta, x86_prefetcht0, x86_prefetcht1, and x86_prefetcht2.
Referenced by decodeOpcode0F().
|
private |
Disassembles PREFETCH, PREFETCHW.
Definition at line 5815 of file DisassemblerX86.C.
References BYTET, getModRegRM(), makeInstruction(), modrm, regField, requireMemory(), rmLegacyByte, rmReturnNull, x86_prefetch, and x86_prefetchw.
Referenced by decodeOpcode0F().
|
private |
Initialize instances of this class.
Called by constructor.
Definition at line 59 of file DisassemblerX86.C.
References RegisterDictionary::dictionary_amd64(), RegisterDictionary::dictionary_i286(), RegisterDictionary::dictionary_pentium4(), Disassembler::get_registers(), insnSize, ByteOrder::ORDER_LSB, Disassembler::set_alignment(), Disassembler::set_registers(), Disassembler::set_sex(), Disassembler::set_wordsize(), startInstruction(), x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.
Referenced by DisassemblerX86().
|
inlineprivate |
Resets disassembler state to beginning of an instruction for assembly.
Definition at line 364 of file DisassemblerX86.h.
References branchPrediction, branchPredictionEnabled, SgAsmStatement::get_address(), SgAsmx86Instruction::get_baseSize(), SgAsmx86Instruction::get_branchPrediction(), SgAsmx86Instruction::get_lockPrefix(), SgAsmx86Instruction::get_segmentOverride(), insnSize, lock, segOverride, and x86_branch_prediction_none.
Referenced by disassembleOne(), and init().
|
inlineprivate |
Resets disassembler state to beginning of an instruction for disassembly.
Definition at line 374 of file DisassemblerX86.h.
References addressSizeOverride, branchPrediction, branchPredictionEnabled, insnbuf, insnbufat, ip, isUnconditionalJump, lock, modeField, modregrmByte, modregrmByteSet, modrm, operandSizeOverride, reg, regField, repeatPrefix, rexB, rexPresent, rexR, rexW, rexX, rmField, segOverride, sizeMustBe64Bit, x86_branch_prediction_none, x86_repeat_none, and x86_segreg_none.
|
private |
Default size of instructions, based on architecture; see init()
Definition at line 396 of file DisassemblerX86.h.
Referenced by currentDataSegment(), decodeModrmMemory(), effectiveAddressSize(), effectiveOperandSize(), getImmJb(), getImmJz(), init(), longMode(), makeInstruction(), makeIP(), makeOperandRegisterFull(), and startInstruction().
|
private |
Virtual address for start of instruction.
Definition at line 399 of file DisassemblerX86.h.
Referenced by getImmJb(), getImmJz(), makeInstruction(), and startInstruction().
|
private |
Buffer containing bytes of instruction.
Definition at line 400 of file DisassemblerX86.h.
Referenced by getByte(), makeInstruction(), and startInstruction().
|
private |
Index of next byte to be read from or write to insnbuf.
Definition at line 401 of file DisassemblerX86.h.
Referenced by decodeModrmMemory(), getByte(), getImmByte(), getImmByteAsIv(), getImmDWord(), getImmJb(), getImmJz(), getImmQWord(), getImmWord(), makeInstruction(), and startInstruction().
|
private |
Set by 0x26,0x2e,0x36,0x3e,0x64,0x65 prefixes.
Definition at line 404 of file DisassemblerX86.h.
Referenced by currentDataSegment(), decodeModrmMemory(), disassemble(), makeInstruction(), and startInstruction().
|
private |
Definition at line 405 of file DisassemblerX86.h.
Referenced by disassemble(), makeInstruction(), and startInstruction().
|
private |
Definition at line 406 of file DisassemblerX86.h.
Referenced by decodeOpcode0F(), disassemble(), makeInstruction(), and startInstruction().
|
private |
Definition at line 407 of file DisassemblerX86.h.
Referenced by effectiveOperandSize(), makeModrmNormal(), makeModrmRegister(), makeOperandRegisterByte(), setRex(), and startInstruction().
|
private |
Definition at line 407 of file DisassemblerX86.h.
Referenced by effectiveOperandSize(), setRex(), and startInstruction().
|
private |
Definition at line 407 of file DisassemblerX86.h.
Referenced by makeModrmRegister(), setRex(), and startInstruction().
|
private |
Definition at line 407 of file DisassemblerX86.h.
Referenced by decodeModrmMemory(), setRex(), and startInstruction().
|
private |
Set by 0x40-0x4f prefixes; extended registers present; see setRex()
Definition at line 407 of file DisassemblerX86.h.
Referenced by decodeModrmMemory(), decodeOpcode0F(), disassemble(), fillInModRM(), makeModrmNormal(), setRex(), and startInstruction().
|
private |
Set if effective operand size must be 64 bits.
Definition at line 408 of file DisassemblerX86.h.
Referenced by disassemble(), effectiveOperandSize(), and startInstruction().
|
private |
Set by the 0x66 prefix; used by effectiveOperandSize() and mmPrefix()
Definition at line 409 of file DisassemblerX86.h.
Referenced by decodeOpcode0F(), disassemble(), effectiveOperandSize(), mmPrefix(), and startInstruction().
|
private |
Set by the 0x67 prefix; used by effectiveAddressSize()
Definition at line 410 of file DisassemblerX86.h.
Referenced by disassemble(), effectiveAddressSize(), and startInstruction().
|
private |
Set by the 0xf0 prefix.
Definition at line 411 of file DisassemblerX86.h.
Referenced by disassemble(), makeInstruction(), and startInstruction().
|
private |
Set by 0xf2 (repne) and 0xf3 (repe) prefixes.
Definition at line 412 of file DisassemblerX86.h.
Referenced by decodeOpcode0F(), disassemble(), makeInstruction(), mmPrefix(), and startInstruction().
|
private |
True if modregrmByte is initialized.
Definition at line 413 of file DisassemblerX86.h.
Referenced by decodeModrmMemory(), getModRegRM(), makeModrmNormal(), makeModrmRegister(), requireMemory(), and startInstruction().
|
private |
Set by instructions that use ModR/M when the ModR/M byte is read.
Definition at line 414 of file DisassemblerX86.h.
Referenced by decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDE(), decodeX87InstructionDF(), getModRegRM(), and startInstruction().
|
private |
Value (0-3) of high-order two bits of modregrmByte; see getModRegRM()
Definition at line 415 of file DisassemblerX86.h.
Referenced by decodeGroup15(), decodeGroup7(), decodeModrmMemory(), decodeOpcode0F(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), fillInModRM(), getModRegRM(), makeModrmNormal(), requireMemory(), and startInstruction().
|
private |
Value (0-7) of bits 3-5 inclusive of modregrmByte; see getModRegRM()
Definition at line 416 of file DisassemblerX86.h.
Referenced by decodeGroup1(), decodeGroup11(), decodeGroup15(), decodeGroup16(), decodeGroup1a(), decodeGroup2(), decodeGroup3(), decodeGroup4(), decodeGroup5(), decodeGroup6(), decodeGroup7(), decodeGroup8(), decodeGroupP(), decodeOpcode0F(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), disassemble(), getModRegRM(), makeModrmRegister(), and startInstruction().
|
private |
Value (0-7) of bits 0-3 inclusive of modregrmByte; see getModRegRM()
Definition at line 417 of file DisassemblerX86.h.
Referenced by decodeGroup7(), decodeModrmMemory(), fillInModRM(), getModRegRM(), makeModrmNormal(), and startInstruction().
|
private |
Register or memory ref expr built from modregrmByte; see getModRegRM()
Definition at line 418 of file DisassemblerX86.h.
Referenced by decodeGroup1(), decodeGroup11(), decodeGroup15(), decodeGroup16(), decodeGroup1a(), decodeGroup2(), decodeGroup3(), decodeGroup4(), decodeGroup5(), decodeGroup6(), decodeGroup7(), decodeGroup8(), decodeGroupP(), decodeOpcode0F(), decodeOpcode0F38(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), disassemble(), fillInModRM(), getModRegRM(), makeModrmNormal(), and startInstruction().
|
private |
Register reference expression built from modregrmByte; see getModRegRM()
Definition at line 419 of file DisassemblerX86.h.
Referenced by decodeOpcode0F(), decodeOpcode0F38(), decodeX87InstructionDE(), disassemble(), getModRegRM(), and startInstruction().
|
private |
True for jmp, farjmp, ret, retf, iret, and hlt.
Definition at line 420 of file DisassemblerX86.h.
Referenced by decodeGroup5(), decodeOpcode0F(), disassemble(), and startInstruction().