decompiler
1.0.0
|
A node in a tree structure of CPUI_PIECE operations. More...
#include <op.hh>
Public Member Functions | |
PieceNode (PcodeOp *op, int4 sl, int4 off, bool l) | |
Constructor. | |
bool | isLeaf (void) const |
Return true if this node is a leaf of the tree structure. | |
int4 | getTypeOffset (void) const |
Get the byte offset of this node into the data-type. | |
int4 | getSlot (void) const |
Get the input slot associated with this node. | |
PcodeOp * | getOp (void) const |
Get the PcodeOp reading this piece. | |
Varnode * | getVarnode (void) const |
Get the Varnode representing this piece. | |
Static Public Member Functions | |
static bool | isLeaf (Varnode *rootVn, Varnode *vn, int4 typeOffset) |
Determine if a Varnode is a leaf within the CONCAT tree rooted at the given Varnode. More... | |
static Varnode * | findRoot (Varnode *vn) |
static void | gatherPieces (vector< PieceNode > &stack, Varnode *rootVn, PcodeOp *op, int4 baseOffset) |
Build the CONCAT tree rooted at the given Varnode. More... | |
Private Attributes | |
PcodeOp * | pieceOp |
CPUI_PIECE operation combining this particular Varnode piece. | |
int4 | slot |
The particular slot of this Varnode within CPUI_PIECE. | |
int4 | typeOffset |
Byte offset into structure/array. | |
bool | leaf |
true if this is a leaf of the tree structure | |
A node in a tree structure of CPUI_PIECE operations.
If a group of Varnodes are concatenated into a larger structure, this object is used to explicitly gather the PcodeOps (and Varnodes) in the data-flow and view them as a unit. In a properly formed tree, for each CPUI_PIECE operation, the addresses of the input Varnodes and the output Varnode align according to the concatenation. Internal Varnodes can have only one descendant, but the leaf and the root Varnodes can each have multiple descendants
Find the root of the CONCAT tree of Varnodes marked either isProtoPartial() or isAddrTied(). This will be the maximal Varnode that containing the given Varnode (as storage), with a backward path to it through PIECE operations. All Varnodes along the path, except the root, will be marked as isProtoPartial() or isAddrTied().
References ghidra::Varnode::beginDescend(), ghidra::PcodeOp::code(), ghidra::PcodeOp::compareOrder(), ghidra::CPUI_PIECE, ghidra::Varnode::endDescend(), ghidra::Varnode::getAddr(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::Address::getSpace(), ghidra::Varnode::isAddrTied(), ghidra::AddrSpace::isBigEndian(), ghidra::Varnode::isProtoPartial(), and ghidra::Address::renormalize().
Referenced by ghidra::ActionMarkExplicit::baseExplicit(), and ghidra::Funcdata::linkProtoPartial().
|
static |
Build the CONCAT tree rooted at the given Varnode.
Recursively walk backwards from the root through CPUI_PIECE operations, stopping if a Varnode is deemed a leaf. Collect all Varnodes involved in the tree in a list. For each Varnode in the tree, record whether it is leaf and also calculate its offset within the data-type attached to the root.
stack | holds the markup for each node of the tree |
rootVn | is the given root of the tree |
op | is the current PIECE op to explore as part of the tree |
baseOffset | is the offset associated with the output of the current PIECE op |
References ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getSize(), ghidra::Varnode::getSpace(), and ghidra::AddrSpace::isBigEndian().
Referenced by ghidra::RulePieceStructure::applyOp(), and ghidra::Merge::groupPartialRoot().
Determine if a Varnode is a leaf within the CONCAT tree rooted at the given Varnode.
The CONCAT tree is the maximal set of Varnodes that are all inputs to CPUI_PIECE operations, with no other uses, and that all ultimately flow to the root Varnode. This method tests whether a Varnode is a leaf of this tree.
rootVn | is the given root of the CONCAT tree |
vn | is the Varnode to test as a leaf |
typeOffset | is byte offset of the test Varnode within fully concatenated value |
References ghidra::PcodeOp::code(), ghidra::CPUI_PIECE, ghidra::Varnode::getAddr(), ghidra::Varnode::getDef(), ghidra::Varnode::getSymbolEntry(), ghidra::Varnode::isAddrTied(), ghidra::Varnode::isMapped(), ghidra::Varnode::isWritten(), and ghidra::Varnode::loneDescend().