decompiler  1.0.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ghidra::PieceNode Class Reference

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.
 
PcodeOpgetOp (void) const
 Get the PcodeOp reading this piece.
 
VarnodegetVarnode (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 VarnodefindRoot (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

PcodeOppieceOp
 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
 

Detailed Description

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

Member Function Documentation

◆ findRoot()

Varnode * ghidra::PieceNode::findRoot ( Varnode vn)
static

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().

Returns
the root of the CONCAT tree

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().

◆ gatherPieces()

void ghidra::PieceNode::gatherPieces ( vector< PieceNode > &  stack,
Varnode rootVn,
PcodeOp op,
int4  baseOffset 
)
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.

Parameters
stackholds the markup for each node of the tree
rootVnis the given root of the tree
opis the current PIECE op to explore as part of the tree
baseOffsetis 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().

◆ isLeaf()

bool ghidra::PieceNode::isLeaf ( Varnode rootVn,
Varnode vn,
int4  typeOffset 
)
static

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.

Parameters
rootVnis the given root of the CONCAT tree
vnis the Varnode to test as a leaf
typeOffsetis byte offset of the test Varnode within fully concatenated value
Returns
true is the test Varnode is a leaf of the tree

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().


The documentation for this class was generated from the following files: