decompiler  1.0.0
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
SegmentOp Class Reference

The segmented address operator. More...

#include <userop.hh>

Inheritance diagram for SegmentOp:
TermPatternOp UserPcodeOp

Public Member Functions

 SegmentOp (Architecture *g, const string &nm, int4 ind)
 Constructor. More...
 
AddrSpacegetSpace (void) const
 Get the address space being pointed to.
 
bool hasFarPointerSupport (void) const
 Return true, if this op supports far pointers.
 
bool isForced (void) const
 Return true if exceptions are thrown for bad unification.
 
int4 getBaseSize (void) const
 Get size in bytes of the base/segment value.
 
int4 getInnerSize (void) const
 Get size in bytes of the near value.
 
const VarnodeDatagetResolve (void) const
 Get the default register for resolving indirect segments.
 
virtual int4 getNumVariableTerms (void) const
 Get the number of input Varnodes expected.
 
virtual bool unify (Funcdata &data, PcodeOp *op, vector< Varnode * > &bindlist) const
 Gather the formal input Varnode objects given the root PcodeOp. More...
 
virtual uintb execute (const vector< uintb > &input) const
 Compute the output value of this operation, given constant inputs. More...
 
virtual void restoreXml (const Element *el)
 Restore the detailed description from an XML stream. More...
 
- Public Member Functions inherited from TermPatternOp
 TermPatternOp (Architecture *g, const string &nm, int4 ind)
 Constructor.
 
- Public Member Functions inherited from UserPcodeOp
 UserPcodeOp (Architecture *g, const string &nm, int4 ind)
 Construct from name and index.
 
const string & getName (void) const
 Get the low-level name of the p-code op.
 
int4 getIndex (void) const
 Get the constant id of the op.
 
virtual ~UserPcodeOp (void)
 Destructor.
 
virtual string getOperatorName (const PcodeOp *op) const
 Get the symbol representing this operation in decompiled code. More...
 

Static Private Member Functions

static uintb executeSide (const vector< OpFollow > &follow, uintb input)
 Execute a stream of operations (OpFollow) given a starting input value. More...
 

Private Attributes

AddrSpacespc
 The physical address space into which a segmented pointer points.
 
int4 baseinsize
 The size in bytes of the base or segment value.
 
int4 innerinsize
 The size in bytes of the near pointer value.
 
bool basepresent
 Is true is a base value must be present in the raw p-code.
 
bool forcesegment
 Is true if an exception is thrown when a segment op can't be unified.
 
bool supportsfarpointer
 Is true if the joined pair base:near acts as a far pointer.
 
vector< OpFollowbasefollow
 Sequence of operations performed on the base value.
 
vector< OpFollowinnerfollow
 Sequence of operations performed on the near value.
 
VarnodeData constresolve
 How to resolve constant near pointers.
 

Additional Inherited Members

- Protected Attributes inherited from UserPcodeOp
string name
 Low-level name of p-code operator.
 
int4 useropindex
 Index passed in the CALLOTHER op.
 
Architectureglb
 Architecture owning the user defined op.
 

Detailed Description

The segmented address operator.

This op is a placeholder for address mappings involving segments. The map goes between a high-level view of a pointer, consisting of multiple pieces, and a low-level view, where there is only a single absolute pointer. The mapping could be

The output of the operator is always a full low-level pointer. The operator takes two inputs:

High-level analysis can ignore the base/segment and any normalization on the near pointer. Emitted expressions involving this segment op prints only the near portion. Data-type information propagates only through this high-level side.

The decompiler looks for the term-tree defined in SegmentOp and replaces it with the SEGMENTOP operator in any p-code it analyzes. The core routine that looks for the term-tree is unify().

Constructor & Destructor Documentation

◆ SegmentOp()

SegmentOp::SegmentOp ( Architecture g,
const string &  nm,
int4  ind 
)

Constructor.

Parameters
gis the owning Architecture for this instance of the segment operation
nmis the low-level name of the segment operation
indis the constant id identifying the specific CALLOTHER variant

References constresolve, and VarnodeData::space.

Member Function Documentation

◆ execute()

uintb SegmentOp::execute ( const vector< uintb > &  input) const
virtual

Compute the output value of this operation, given constant inputs.

Parameters
inputis the ordered list of constant inputs
Returns
the resulting value as a constant

Implements TermPatternOp.

References basefollow, basepresent, executeSide(), and innerfollow.

Referenced by RuleSegment::applyOp(), EmulatePcodeOp::executeSegmentOp(), and SegmentedResolver::resolve().

◆ executeSide()

uintb SegmentOp::executeSide ( const vector< OpFollow > &  follow,
uintb  input 
)
staticprivate

Execute a stream of operations (OpFollow) given a starting input value.

Each operation is performed in turn, with output from the previous becoming input of the next. The final output is returned.

Parameters
followis the ordered set of operations to perform
inputis the constant input for the first operation
Returns
the final constant output

References CPUI_INT_AND, and CPUI_INT_LEFT.

Referenced by execute().

◆ restoreXml()

void SegmentOp::restoreXml ( const Element el)
virtual

Restore the detailed description from an XML stream.

The details of how a user defined operation behaves can be dynamically configured from an XML tag.

Parameters
elis the root XML element describing the op

Implements UserPcodeOp.

References basefollow, baseinsize, basepresent, constresolve, forcesegment, UserPcodeOp::getIndex(), Address::getOffset(), UserOpManage::getOp(), Address::getSpace(), AddrSpaceManager::getSpaceByName(), UserPcodeOp::glb, innerfollow, innerinsize, UserPcodeOp::name, VarnodeData::offset, Address::restoreXml(), VarnodeData::size, VarnodeData::space, spc, supportsfarpointer, UserPcodeOp::useropindex, and Architecture::userops.

Referenced by UserOpManage::parseSegmentOp().

◆ unify()

bool SegmentOp::unify ( Funcdata data,
PcodeOp op,
vector< Varnode * > &  bindlist 
) const
virtual

Gather the formal input Varnode objects given the root PcodeOp.

Parameters
datais the function being analyzed
opis the root operation
bindlistwill hold the ordered list of input Varnodes
Returns
true if the requisite inputs were found

Implements TermPatternOp.

References baseinsize, basepresent, PcodeOp::code(), CPUI_CALLOTHER, PcodeOp::getIn(), Varnode::getOffset(), innerinsize, Varnode::isConstant(), Funcdata::newConstant(), PcodeOp::numInput(), and UserPcodeOp::useropindex.

Referenced by ActionSegmentize::apply().


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