decompiler
1.0.0
|
A (putative) switch variable Varnode and a constraint imposed by a CBRANCH. More...
#include <jumptable.hh>
Public Member Functions | |
GuardRecord (PcodeOp *bOp, PcodeOp *rOp, int4 path, const CircleRange &rng, Varnode *v) | |
Constructor. More... | |
PcodeOp * | getBranch (void) const |
Get the CBRANCH associated with this guard. | |
PcodeOp * | getReadOp (void) const |
Get the PcodeOp immediately causing the restriction. | |
int4 | getPath (void) const |
Get the specific path index going towards the switch. | |
const CircleRange & | getRange (void) const |
Get the range of values causing the switch path to be taken. | |
void | clear (void) |
Mark this guard as unused. | |
int4 | valueMatch (Varnode *vn2, Varnode *baseVn2, int4 bitsPreserved2) const |
Determine if this guard applies to the given Varnode. More... | |
Static Public Member Functions | |
static int4 | oneOffMatch (PcodeOp *op1, PcodeOp *op2) |
Return 1 if the two given PcodeOps produce exactly the same value, 0 if otherwise. More... | |
static Varnode * | quasiCopy (Varnode *vn, int4 &bitsPreserved) |
Compute the source of a quasi-COPY chain for the given Varnode. More... | |
Private Attributes | |
PcodeOp * | cbranch |
PcodeOp CBRANCH the branches around the switch. | |
PcodeOp * | readOp |
The immediate PcodeOp causing the restriction. | |
int4 | indpath |
Specific CBRANCH path going to the switch. | |
CircleRange | range |
Range of values causing the CBRANCH to take the path to the switch. | |
Varnode * | vn |
The Varnode being restricted. | |
Varnode * | baseVn |
Value being (quasi)copied to the Varnode. | |
int4 | bitsPreserved |
Number of bits copied (all other bits are zero) | |
A (putative) switch variable Varnode and a constraint imposed by a CBRANCH.
The record constrains a specific Varnode. If the associated CBRANCH is followed along the path that reaches the switch's BRANCHIND, then we have an explicit description of the possible values the Varnode can hold.
GuardRecord::GuardRecord | ( | PcodeOp * | bOp, |
PcodeOp * | rOp, | ||
int4 | path, | ||
const CircleRange & | rng, | ||
Varnode * | v | ||
) |
Constructor.
Return 1 if the two given PcodeOps produce exactly the same value, 0 if otherwise.
We up through only one level of PcodeOp calculation and only for certain binary ops where the second parameter is a constant.
References PcodeOp::code(), CPUI_INT_ADD, CPUI_INT_AND, CPUI_INT_LEFT, CPUI_INT_MULT, CPUI_INT_OR, CPUI_INT_RIGHT, CPUI_INT_SRIGHT, CPUI_INT_XOR, CPUI_SUBPIECE, and PcodeOp::getIn().
Compute the source of a quasi-COPY chain for the given Varnode.
A value is a quasi-copy if a sequence of PcodeOps producing it always hold the value as the least significant bits of their output Varnode, but the sequence may put other non-zero values in the upper bits. This method computes the earliest ancestor Varnode for which the given Varnode can be viewed as a quasi-copy.
vn | is the given Varnode |
bitsPreserved | will hold the number of least significant bits preserved by the sequence |
References PcodeOp::code(), CPUI_COPY, CPUI_INT_AND, CPUI_INT_OR, CPUI_INT_SEXT, CPUI_INT_ZEXT, CPUI_PIECE, CPUI_SUBPIECE, Varnode::getDef(), PcodeOp::getIn(), Varnode::getNZMask(), Varnode::getOffset(), Varnode::getSize(), Varnode::isConstant(), and mostsigbit_set().
Referenced by JumpBasic::calcRange(), and JumpBasic::markFoldableGuards().
Determine if this guard applies to the given Varnode.
The guard applies if we know the given Varnode holds the same value as the Varnode attached to the guard. So we return:
vn2 | is the given Varnode being tested against this guard |
baseVn2 | is the earliest Varnode from which the given Varnode is quasi-copied. |
bitsPreserved2 | is the number of potentially non-zero bits in the given Varnode |
References PcodeOp::code(), CPUI_INT_ADD, CPUI_LOAD, Varnode::getDef(), PcodeOp::getIn(), Varnode::getOffset(), Varnode::isConstant(), and Varnode::isWritten().
Referenced by JumpBasic::calcRange().