1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_DispatcherX86_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_DispatcherX86_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics.h>
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/base_object.hpp>
11 #include <boost/serialization/export.hpp>
12 #include <boost/serialization/split_member.hpp>
15 namespace BinaryAnalysis {
16 namespace InstructionSemantics {
69 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
71 friend class boost::serialization::access;
74 void save(S &s,
const unsigned )
const {
75 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Super);
76 s & BOOST_SERIALIZATION_NVP(processorMode_);
80 void load(S &s,
const unsigned ) {
81 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Super);
82 s & BOOST_SERIALIZATION_NVP(processorMode_);
88 BOOST_SERIALIZATION_SPLIT_MEMBER();
163 enum AccessMode { READ_REGISTER, PEEK_REGISTER };
227 size_t rotateSignificantBits);
238 size_t shiftSignificantBits);
285 typedef const SgAsmExpressionPtrList &A;
286 virtual void p(D, Ops, I, A) = 0;
288 virtual void assert_args(I insn, A args,
size_t nargs);
289 void check_arg_width(D d, I insn, A args);
298 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
RegisterDescriptor REG_R14
Cached register.
virtual void pushFloatingPoint(const BaseSemantics::SValuePtr &valueToPush)
Push floating-point value onto FP stack.
RegisterDescriptor REG_ECX
Cached register.
RegisterDescriptor REG_AH
Cached register.
virtual int iprocKey(SgAsmInstruction *insn_) const override
Given an instruction, return the InsnProcessor key that can be used as an index into the iproc_table...
RegisterDescriptor REG_AX
Cached register.
RegisterDescriptor REG_RDI
Cached register.
RegisterDescriptor REG_RSI
Cached register.
RegisterDescriptor REG_CX
Cached register.
RegisterDescriptor REG_anyDX
Cached register.
virtual BaseSemantics::SValuePtr greaterOrEqualToTen(const BaseSemantics::SValuePtr &value)
Determines whether value is greater than or equal to ten.
virtual BaseSemantics::SValuePtr doRotateOperation(X86InstructionKind kind, const BaseSemantics::SValuePtr &operand, const BaseSemantics::SValuePtr &total_rotate, size_t rotateSignificantBits)
Implements the RCL, RCR, ROL, and ROR instructions for various operand sizes.
RegisterDescriptor REG_FPSTATUS
Cached register.
RegisterDescriptor REG_SI
Cached register.
RegisterDescriptor REG_ESI
Cached register.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
Base class for machine instructions.
RegisterDescriptor REG_EBX
Cached register.
void regcache_init()
Load the cached register descriptors.
RegisterDescriptor REG_IP
Cached register.
RegisterDescriptor REG_anyBX
Cached register.
RegisterDescriptor REG_MXCSR
Cached register.
RegisterDescriptor REG_CH
Cached register.
virtual BaseSemantics::SValuePtr parity(const BaseSemantics::SValuePtr &v)
Returns true if byte v has an even number of bits set; false for an odd number.
RegisterDescriptor REG_anyIP
Cached register.
virtual BaseSemantics::SValuePtr saturateUnsignedToUnsigned(const BaseSemantics::SValuePtr &, size_t narrowerWidth)
Convert an unsigned value to a narrower unsigned type.
RegisterDescriptor REG_RIP
Cached register.
RegisterDescriptor REG_RBP
Cached register.
RegisterDescriptor REG_R11
Cached register.
RegisterDescriptor REG_BL
Cached register.
RegisterDescriptor REG_anyDI
Cached register.
Main namespace for the ROSE library.
RegisterDescriptor REG_EDI
Cached register.
RegisterDescriptor REG_R9
Cached register.
virtual void setFlagsForResult(const BaseSemantics::SValuePtr &result)
Set parity, sign, and zero flags appropriate for result value.
virtual BaseSemantics::SValuePtr doAddOperation(BaseSemantics::SValuePtr a, BaseSemantics::SValuePtr b, bool invertCarries, const BaseSemantics::SValuePtr &carryIn)
Adds two values and adjusts flags.
virtual void writeRegister(RegisterDescriptor, const BaseSemantics::SValuePtr &result)
Architecture-specific write to register.
RegisterDescriptor REG_DX
Cached register.
RegisterDescriptor REG_PF
Cached register.
virtual RegisterDictionary::RegisterDescriptors get_usual_registers() const
Get list of common registers.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
RegisterDescriptor REG_SF
Cached register.
RegisterDescriptor REG_FPCTL
Cached register.
virtual void repLeave(X86RepeatPrefix, const BaseSemantics::SValuePtr &in_loop, rose_addr_t insn_va, bool honorZeroFlag)
Leave a loop for a REP-, REPE-, or REPNE-prefixed instruction.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
RegisterDescriptor REG_anyCX
Cached register.
static DispatcherX86Ptr promote(const BaseSemantics::DispatcherPtr &)
Dynamic cast to a DispatcherX86Ptr with assertion.
RegisterDescriptor REG_DF
Cached register.
Dispatches instructions through the RISC layer.
RegisterDescriptor REG_FS
Cached register.
RegisterDescriptor REG_anySP
Cached register.
RegisterDescriptor REG_AF
Cached register.
Base class for all x86 instruction processors.
RegisterDescriptor REG_RBX
Cached register.
Rose::BinaryAnalysis::RegisterDescriptors RegisterDescriptors
List of register descriptors in dictionary.
RegisterDescriptor REG_ESP
Cached register.
virtual void write(SgAsmExpression *e, const BaseSemantics::SValuePtr &value, size_t addr_nbits=0) override
Writes to an L-value expression.
RegisterDescriptor REG_RFLAGS
Cached register.
RegisterDescriptor REG_EIP
Cached register.
RegisterDescriptor REG_EFLAGS
Cached register.
void processorMode(X86InstructionSize m)
CPU mode of operation.
Functor that knows how to dispatch a single kind of instruction.
void iproc_init()
Loads the iproc table with instruction processing functors.
Describes (part of) a physical CPU register.
RegisterDescriptor REG_R12
Cached register.
RegisterDescriptor REG_GS
Cached register.
RegisterDescriptor REG_SP
Cached register.
RegisterDescriptor REG_R10
Cached register.
virtual BaseSemantics::SValuePtr repEnter(X86RepeatPrefix)
Enters a loop for a REP-, REPE-, or REPNE-prefixed instruction.
virtual BaseSemantics::SValuePtr saturateSignedToSigned(const BaseSemantics::SValuePtr &, size_t narrowerWidth)
Convert a signed value to a narrower signed type.
RegisterDescriptor REG_RDX
Cached register.
RegisterDescriptor REG_DS
Cached register.
virtual BaseSemantics::SValuePtr saturateSignedToUnsigned(const BaseSemantics::SValuePtr &, size_t narrowerWidth)
Convert a signed value to a narrower unsigned type.
RegisterDescriptor REG_anySI
Cached register.
RegisterDescriptor REG_R8
Cached register.
X86InstructionSize processorMode() const
CPU mode of operation.
RegisterDescriptor REG_EDX
Cached register.
DispatcherX86Ptr Ptr
Shared-ownership pointer.
Represents one Intel x86 machine instruction.
virtual void popFloatingPoint()
Pop the top item from the floating point stack.
RegisterDescriptor REG_R13
Cached register.
virtual BaseSemantics::SValuePtr fixMemoryAddress(const BaseSemantics::SValuePtr &address) const
Extend or truncate value to propert memory address width.
Base class for expressions.
RegisterDescriptor REG_anyFLAGS
Cached register.
RegisterDescriptor REG_ST0
Cached register.
void memory_init()
Make sure memory properties are set up correctly.
RegisterDescriptor REG_ZF
Cached register.
RegisterDescriptor REG_OF
Cached register.
virtual RegisterDescriptor stackPointerRegister() const override
Returns the stack pointer register.
RegisterDescriptor REG_FPSTATUS_TOP
Cached register.
virtual RegisterDescriptor callReturnRegister() const override
Returns the function call return address register.
RegisterDescriptor REG_BP
Cached register.
virtual RegisterDescriptor stackFrameRegister() const override
Returns the stack call frame register.
RegisterDescriptor REG_RAX
Cached register.
RegisterDescriptor REG_EAX
Cached register.
RegisterDescriptor REG_RCX
Cached register.
virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor, AccessMode mode=READ_REGISTER)
Architecture-specific read from register.
virtual BaseSemantics::SValuePtr doIncOperation(const BaseSemantics::SValuePtr &a, bool dec, bool setCarry)
Increments or decrements a value and adjusts flags.
Rose::BinaryAnalysis::X86InstructionKind get_kind() const
Property: Instruction kind.
virtual void initializeState(const BaseSemantics::StatePtr &) override
Initialize the state.
virtual BaseSemantics::SValuePtr doShiftOperation(X86InstructionKind kind, const BaseSemantics::SValuePtr &operand, const BaseSemantics::SValuePtr &source_bits, const BaseSemantics::SValuePtr &total_shift, size_t shiftSignificantBits)
Implements the SHR, SAR, SHL, SAL, SHRD, and SHLD instructions for various operand sizes...
RegisterDescriptor REG_CS
Cached register.
RegisterDescriptor REG_EBP
Cached register.
RegisterDescriptor REG_DH
Cached register.
X86InstructionKind
List of all x86 instructions known to the ROSE disassembler/assembler.
RegisterDescriptor REG_anyAX
Cached register.
Base class for most instruction semantics RISC operators.
RegisterDescriptor REG_anyBP
Cached register.
virtual BaseSemantics::SValuePtr invertMaybe(const BaseSemantics::SValuePtr &value, bool maybe)
Conditionally invert the bits of value.
virtual BaseSemantics::SValuePtr readFloatingPointStack(size_t position)
Read a value from the floating point stack.
static DispatcherX86Ptr instance()
Construct a prototypical dispatcher.
RegisterDescriptor REG_AL
Cached register.
RegisterDescriptor REG_BX
Cached register.
RegisterDescriptor REG_DI
Cached register.
RegisterDescriptor REG_SS
Cached register.
RegisterDescriptor REG_CF
Cached register.
RegisterDescriptor REG_RSP
Cached register.
RegisterDictionaryPtr regdict
See registerDictionary property.
BaseSemantics::Dispatcher Super
Base type.
RegisterDescriptor REG_CL
Cached register.
X86InstructionSize
Intel x86 instruction size constants.
virtual BaseSemantics::DispatcherPtr create(const BaseSemantics::RiscOperatorsPtr &, size_t addrWidth, const RegisterDictionaryPtr &) const override
Virtual constructor.
RegisterDescriptor REG_DL
Cached register.
RegisterDescriptor REG_BH
Cached register.
boost::shared_ptr< class DispatcherX86 > DispatcherX86Ptr
Shared-ownership pointer to an x86 instruction dispatcher.
RegisterDescriptor REG_ES
Cached register.
virtual RegisterDescriptor instructionPointerRegister() const override
Returns the instruction pointer register.
RegisterDescriptor REG_FLAGS
Cached register.
X86RepeatPrefix
Intel x86 instruction repeat prefix.
RegisterDescriptor REG_TF
Cached register.
RegisterDescriptor REG_R15
Cached register.
virtual BaseSemantics::SValuePtr flagsCombo(X86InstructionKind k)
Return a Boolean for the specified flag combo for an instruction.