decompiler
1.0.0
|
Class encapsulating the action/behavior of specific pcode opcodes. More...
#include <opbehavior.hh>
Public Member Functions | |
OpBehavior (OpCode opc, bool isun) | |
A behavior constructor. More... | |
OpBehavior (OpCode opc, bool isun, bool isspec) | |
A special behavior constructor. More... | |
OpCode | getOpcode (void) const |
Get the opcode for this pcode operation. More... | |
bool | isSpecial (void) const |
Check if this is a special operator. More... | |
bool | isUnary (void) const |
Check if operator is unary. More... | |
virtual uintb | evaluateUnary (int4 sizeout, int4 sizein, uintb in1) const |
Emulate the unary op-code on an input value. More... | |
virtual uintb | evaluateBinary (int4 sizeout, int4 sizein, uintb in1, uintb in2) const |
Emulate the binary op-code on input values. More... | |
virtual uintb | recoverInputBinary (int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const |
Reverse the binary op-code operation, recovering an input value. More... | |
virtual uintb | recoverInputUnary (int4 sizeout, uintb out, int4 sizein) const |
Reverse the unary op-code operation, recovering the input value. More... | |
Static Public Member Functions | |
static void | registerInstructions (vector< OpBehavior *> &inst, const Translate *trans) |
Build all pcode behaviors. More... | |
Private Attributes | |
OpCode | opcode |
the internal enumeration for pcode types | |
bool | isunary |
true= use unary interfaces, false = use binary | |
bool | isspecial |
Is op not a normal unary or binary op. | |
Class encapsulating the action/behavior of specific pcode opcodes.
At the lowest level, a pcode op is one of a small set of opcodes that operate on varnodes (address space, offset, size). Classes derived from this base class encapsulate this basic behavior for each possible opcode. These classes describe the most basic behaviors and include:
|
inline |
A behavior constructor.
This kind of OpBehavior is associated with a particular opcode and is either unary or binary
opc | is the opcode of the behavior |
isun | is true if the behavior is unary, false if binary |
Referenced by registerInstructions().
|
inline |
A special behavior constructor.
This kind of OpBehavior can be set to special, if it neither unary or binary.
opc | is the opcode of the behavior |
isun | is true if the behavior is unary |
isspec | is true if the behavior is neither unary or binary |
|
virtual |
Emulate the binary op-code on input values.
sizeout | is the size of the output in bytes |
sizein | is the size of the inputs in bytes |
in1 | is the first input value |
in2 | is the second input value |
Reimplemented in ghidra::OpBehaviorSubpiece, ghidra::OpBehaviorPiece, ghidra::OpBehaviorFloatSub, ghidra::OpBehaviorFloatMult, ghidra::OpBehaviorFloatDiv, ghidra::OpBehaviorFloatAdd, ghidra::OpBehaviorFloatLessEqual, ghidra::OpBehaviorFloatLess, ghidra::OpBehaviorFloatNotEqual, ghidra::OpBehaviorFloatEqual, ghidra::OpBehaviorBoolOr, ghidra::OpBehaviorBoolAnd, ghidra::OpBehaviorBoolXor, ghidra::OpBehaviorIntSrem, ghidra::OpBehaviorIntRem, ghidra::OpBehaviorIntSdiv, ghidra::OpBehaviorIntDiv, ghidra::OpBehaviorIntMult, ghidra::OpBehaviorIntSright, ghidra::OpBehaviorIntRight, ghidra::OpBehaviorIntLeft, ghidra::OpBehaviorIntOr, ghidra::OpBehaviorIntAnd, ghidra::OpBehaviorIntXor, ghidra::OpBehaviorIntSborrow, ghidra::OpBehaviorIntScarry, ghidra::OpBehaviorIntCarry, ghidra::OpBehaviorIntSub, ghidra::OpBehaviorIntAdd, ghidra::OpBehaviorIntLessEqual, ghidra::OpBehaviorIntLess, ghidra::OpBehaviorIntSlessEqual, ghidra::OpBehaviorIntSless, ghidra::OpBehaviorNotEqual, and ghidra::OpBehaviorEqual.
References opcode.
Referenced by ghidra::TypeOp::evaluateBinary(), ghidra::OpBehaviorFloatEqual::evaluateBinary(), ghidra::OpBehaviorFloatNotEqual::evaluateBinary(), ghidra::OpBehaviorFloatLess::evaluateBinary(), ghidra::OpBehaviorFloatLessEqual::evaluateBinary(), ghidra::OpBehaviorFloatAdd::evaluateBinary(), ghidra::OpBehaviorFloatDiv::evaluateBinary(), ghidra::OpBehaviorFloatMult::evaluateBinary(), ghidra::OpBehaviorFloatSub::evaluateBinary(), ghidra::EmulatePcodeOp::executeBinary(), and ghidra::EmulateSnippet::executeBinary().
|
virtual |
Emulate the unary op-code on an input value.
sizeout | is the size of the output in bytes |
sizein | is the size of the input in bytes |
in1 | is the input value |
Reimplemented in ghidra::OpBehaviorLzcount, ghidra::OpBehaviorPopcount, ghidra::OpBehaviorFloatRound, ghidra::OpBehaviorFloatFloor, ghidra::OpBehaviorFloatCeil, ghidra::OpBehaviorFloatTrunc, ghidra::OpBehaviorFloatFloat2Float, ghidra::OpBehaviorFloatInt2Float, ghidra::OpBehaviorFloatSqrt, ghidra::OpBehaviorFloatAbs, ghidra::OpBehaviorFloatNeg, ghidra::OpBehaviorFloatNan, ghidra::OpBehaviorBoolNegate, ghidra::OpBehaviorIntNegate, ghidra::OpBehaviorInt2Comp, ghidra::OpBehaviorIntSext, ghidra::OpBehaviorIntZext, and ghidra::OpBehaviorCopy.
References opcode.
Referenced by ghidra::TypeOp::evaluateUnary(), ghidra::OpBehaviorFloatNan::evaluateUnary(), ghidra::OpBehaviorFloatNeg::evaluateUnary(), ghidra::OpBehaviorFloatAbs::evaluateUnary(), ghidra::OpBehaviorFloatSqrt::evaluateUnary(), ghidra::OpBehaviorFloatInt2Float::evaluateUnary(), ghidra::OpBehaviorFloatFloat2Float::evaluateUnary(), ghidra::OpBehaviorFloatTrunc::evaluateUnary(), ghidra::OpBehaviorFloatCeil::evaluateUnary(), ghidra::OpBehaviorFloatFloor::evaluateUnary(), ghidra::OpBehaviorFloatRound::evaluateUnary(), ghidra::EmulatePcodeOp::executeUnary(), and ghidra::EmulateSnippet::executeUnary().
|
inline |
Get the opcode for this pcode operation.
There is an internal enumeration value for each type of pcode operation. This routine returns that value.
|
inline |
Check if this is a special operator.
If this function returns false, the operation is a normal unary or binary operation which can be evaluated calling evaluateBinary() or evaluateUnary(). Otherwise, the operation requires special handling to emulate properly
|
inline |
Check if operator is unary.
The operated can either be evaluated as unary or binary
|
virtual |
Reverse the binary op-code operation, recovering an input value.
If the output value and one of the input values is known, recover the value of the other input.
slot | is the input slot to recover |
sizeout | is the size of the output in bytes |
out | is the output value |
sizein | is the size of the inputs in bytes |
in | is the known input value |
Reimplemented in ghidra::OpBehaviorIntSright, ghidra::OpBehaviorIntRight, ghidra::OpBehaviorIntLeft, ghidra::OpBehaviorIntSub, and ghidra::OpBehaviorIntAdd.
Referenced by ghidra::TypeOp::recoverInputBinary(), ghidra::OpBehaviorIntLeft::recoverInputBinary(), ghidra::OpBehaviorIntRight::recoverInputBinary(), and ghidra::OpBehaviorIntSright::recoverInputBinary().
|
virtual |
Reverse the unary op-code operation, recovering the input value.
If the output value is known, recover the input value.
sizeout | is the size of the output in bytes |
out | is the output value |
sizein | is the size of the input in bytes |
Reimplemented in ghidra::OpBehaviorIntNegate, ghidra::OpBehaviorInt2Comp, ghidra::OpBehaviorIntSext, ghidra::OpBehaviorIntZext, and ghidra::OpBehaviorCopy.
Referenced by ghidra::TypeOp::recoverInputUnary().
|
static |
Build all pcode behaviors.
This routine generates a vector of OpBehavior objects indexed by opcode
inst | is the vector of behaviors to be filled |
trans | is the translator object needed by the floating point behaviors |
References ghidra::CPUI_BOOL_AND, ghidra::CPUI_BOOL_NEGATE, ghidra::CPUI_BOOL_OR, ghidra::CPUI_BOOL_XOR, ghidra::CPUI_BRANCH, ghidra::CPUI_BRANCHIND, ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_CALLOTHER, ghidra::CPUI_CAST, ghidra::CPUI_CBRANCH, ghidra::CPUI_COPY, ghidra::CPUI_CPOOLREF, ghidra::CPUI_EXTRACT, ghidra::CPUI_FLOAT_ABS, ghidra::CPUI_FLOAT_ADD, ghidra::CPUI_FLOAT_CEIL, ghidra::CPUI_FLOAT_DIV, ghidra::CPUI_FLOAT_EQUAL, ghidra::CPUI_FLOAT_FLOAT2FLOAT, ghidra::CPUI_FLOAT_FLOOR, ghidra::CPUI_FLOAT_INT2FLOAT, ghidra::CPUI_FLOAT_LESS, ghidra::CPUI_FLOAT_LESSEQUAL, ghidra::CPUI_FLOAT_MULT, ghidra::CPUI_FLOAT_NAN, ghidra::CPUI_FLOAT_NEG, ghidra::CPUI_FLOAT_NOTEQUAL, ghidra::CPUI_FLOAT_ROUND, ghidra::CPUI_FLOAT_SQRT, ghidra::CPUI_FLOAT_SUB, ghidra::CPUI_FLOAT_TRUNC, ghidra::CPUI_INDIRECT, ghidra::CPUI_INSERT, ghidra::CPUI_INT_2COMP, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_AND, ghidra::CPUI_INT_CARRY, ghidra::CPUI_INT_DIV, ghidra::CPUI_INT_EQUAL, ghidra::CPUI_INT_LEFT, ghidra::CPUI_INT_LESS, ghidra::CPUI_INT_LESSEQUAL, ghidra::CPUI_INT_MULT, ghidra::CPUI_INT_NEGATE, ghidra::CPUI_INT_NOTEQUAL, ghidra::CPUI_INT_OR, ghidra::CPUI_INT_REM, ghidra::CPUI_INT_RIGHT, ghidra::CPUI_INT_SBORROW, ghidra::CPUI_INT_SCARRY, ghidra::CPUI_INT_SDIV, ghidra::CPUI_INT_SEXT, ghidra::CPUI_INT_SLESS, ghidra::CPUI_INT_SLESSEQUAL, ghidra::CPUI_INT_SREM, ghidra::CPUI_INT_SRIGHT, ghidra::CPUI_INT_SUB, ghidra::CPUI_INT_XOR, ghidra::CPUI_INT_ZEXT, ghidra::CPUI_LOAD, ghidra::CPUI_LZCOUNT, ghidra::CPUI_MAX, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_NEW, ghidra::CPUI_PIECE, ghidra::CPUI_POPCOUNT, ghidra::CPUI_PTRADD, ghidra::CPUI_PTRSUB, ghidra::CPUI_RETURN, ghidra::CPUI_SEGMENTOP, ghidra::CPUI_STORE, ghidra::CPUI_SUBPIECE, and OpBehavior().
Referenced by ghidra::EmulatePcodeCache::EmulatePcodeCache().