decompiler 1.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ghidra::ConstructTpl Class Reference

P-code semantics for Constructor in a SLEIGH specification. More...

#include <semantics.hh>

Public Member Functions

 ConstructTpl (void)
 Construct an empty ConstructTpl.
 
 ~ConstructTpl (void)
 Destructor. More...
 
uint4 delaySlot (void) const
 Return the number of bytes in the delay slot.
 
uint4 numLabels (void) const
 Get the number of labels.
 
const vector< OpTpl * > & getOpvec (void) const
 Get the sequence of p-code operations.
 
HandleTpl * getResult (void) const
 Get the export result.
 
bool addOp (OpTpl *ot)
 Add an operation to the end of the sequence. More...
 
bool addOpList (const vector< OpTpl * > &oplist)
 Add a list of operations to the end of the sequence. More...
 
void setResult (HandleTpl *t)
 Set the export HandleTpl for this.
 
int4 fillinBuild (vector< int4 > &check, AddrSpace *const_space)
 Make sure there is a build directive for all sub-constructors. More...
 
bool buildOnly (void) const
 Check if all operations are build directives. More...
 
void changeHandleIndex (const vector< int4 > &handmap)
 Remap handle indices for all operations. More...
 
void setInput (VarnodeTpl *vn, int4 index, int4 slot)
 Set the VarnodeTpl input for a particular OpTpl in the sequence. More...
 
void setOutput (VarnodeTpl *vn, int4 index)
 Set the VarnodeTpl output for a particular OpTpl in the sequence. More...
 
void deleteOps (const vector< int4 > &indices)
 Delete the given set of operations. More...
 
void encode (Encoder &encoder, int4 sectionid) const
 Encode details of this semantic sequence to an output stream. More...
 
int4 decode (Decoder &decoder)
 Decode a semantic sequence from a stream. More...
 

Protected Member Functions

void setOpvec (vector< OpTpl * > &opvec)
 Set the sequence of OpTpl.
 
void setNumLabels (uint4 val)
 Set the number of labels.
 

Protected Attributes

uint4 delayslot
 (Minimum) number of bytes in the delay slot
 
uint4 numlabels
 Number of label templates.
 
vector< OpTpl * > vec
 Sequence of operations performed by the Constructor.
 
HandleTpl * result
 Final exported value (or NULL)
 

Friends

class SleighCompile
 

Detailed Description

P-code semantics for Constructor in a SLEIGH specification.

This encodes a sequence of OpTpl representing the semantic action of the Constructor, and if present, the HandleTpl representing the final exported value.

Constructor & Destructor Documentation

◆ ~ConstructTpl()

ghidra::ConstructTpl::~ConstructTpl ( void  )

Destructor.

ConstructTpl owns any OpTpl and HandleTpl.

References result, and vec.

Member Function Documentation

◆ addOp()

bool ghidra::ConstructTpl::addOp ( OpTpl *  ot)

Add an operation to the end of the sequence.

The added OpTpl can be a normal operation, which will be executed directly, or it can be a directive, like a build or delayslot, which may ultimately decode to multiple operations. Additionally, an OpTpl can represent a label, used to resolve internal p-code branches.

Parameters
otis the OpTpl to add
Returns
true if the operation was successfully added and did not violate a compile time rules

References DELAY_SLOT, delayslot, ghidra::OpTpl::getIn(), ghidra::VarnodeTpl::getOffset(), ghidra::OpTpl::getOpcode(), ghidra::ConstTpl::getReal(), LABELBUILD, numlabels, and vec.

Referenced by addOpList().

◆ addOpList()

bool ghidra::ConstructTpl::addOpList ( const vector< OpTpl * > &  oplist)

Add a list of operations to the end of the sequence.

Parameters
oplistis the list of operations to add
Returns
true if all operations were successfully added

References addOp().

◆ buildOnly()

bool ghidra::ConstructTpl::buildOnly ( void  ) const

Check if all operations are build directives.

Returns
true if every operation is a build directive

References BUILD, ghidra::OpTpl::getOpcode(), and vec.

◆ changeHandleIndex()

void ghidra::ConstructTpl::changeHandleIndex ( const vector< int4 > &  handmap)

Remap handle indices for all operations.

Each OpTpl operation is remapped using the given array of handle indices

Parameters
handmapis the given array of new handle indices

References BUILD, ghidra::HandleTpl::changeHandleIndex(), ghidra::OpTpl::changeHandleIndex(), ghidra::OpTpl::getIn(), ghidra::VarnodeTpl::getOffset(), ghidra::OpTpl::getOpcode(), ghidra::ConstTpl::getReal(), result, ghidra::VarnodeTpl::setOffset(), and vec.

◆ decode()

int4 ghidra::ConstructTpl::decode ( Decoder &  decoder)

Decode a semantic sequence from a stream.

Parameters
decoderis the stream to decode from
Returns
the Constructor section id associated with the sequence

References ghidra::Decoder::closeElement(), ghidra::HandleTpl::decode(), ghidra::OpTpl::decode(), delayslot, ghidra::Decoder::getNextAttributeId(), numlabels, ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), ghidra::Decoder::readSignedInteger(), result, and vec.

◆ deleteOps()

void ghidra::ConstructTpl::deleteOps ( const vector< int4 > &  indices)

Delete the given set of operations.

Parameters
indicesis an array of the indices indicating the positions of the OpTpl to be deleted

References vec.

Referenced by ghidra::ConsistencyChecker::applyOptimization().

◆ encode()

void ghidra::ConstructTpl::encode ( Encoder &  encoder,
int4  sectionid 
) const

Encode details of this semantic sequence to an output stream.

Parameters
encoderis the output stream
sectionidis the id of the specific Constructor section to associate with this sequence

References ghidra::Encoder::closeElement(), delayslot, ghidra::HandleTpl::encode(), encode(), numlabels, ghidra::Encoder::openElement(), result, vec, and ghidra::Encoder::writeSignedInteger().

Referenced by encode(), ghidra::InjectPayloadSleigh::printTemplate(), and ghidra::ExecutablePcodeSleigh::printTemplate().

◆ fillinBuild()

int4 ghidra::ConstructTpl::fillinBuild ( vector< int4 > &  check,
AddrSpace *  const_space 
)

Make sure there is a build directive for all sub-constructors.

For any sub-constructor that does not already one, a new build directive is added to the front of the operation sequence.

Parameters
checkis an array of integers, initialized to 0, used to mark sub-constructors with a directive.
const_spaceis the constant address space
Returns
0 upon success, 1 if there is a duplicate build, 2 if there is a build for a non-subtable

References ghidra::OpTpl::addInput(), BUILD, ghidra::OpTpl::getIn(), ghidra::VarnodeTpl::getOffset(), ghidra::OpTpl::getOpcode(), ghidra::ConstTpl::getReal(), ghidra::ConstTpl::real, and vec.

Referenced by ghidra::SleighCompile::finalizeSections().

◆ setInput()

void ghidra::ConstructTpl::setInput ( VarnodeTpl *  vn,
int4  index,
int4  slot 
)

Set the VarnodeTpl input for a particular OpTpl in the sequence.

For use with optimization routines.

Parameters
vnis the new input
indexis the position of the operation within the sequence
slotis the input slot to replace with the new input

References ghidra::OpTpl::getIn(), ghidra::OpTpl::setInput(), and vec.

Referenced by ghidra::ConsistencyChecker::applyOptimization().

◆ setOutput()

void ghidra::ConstructTpl::setOutput ( VarnodeTpl *  vn,
int4  index 
)

Set the VarnodeTpl output for a particular OpTpl in the sequence.

For use with optimization routines.

Parameters
vnis the new output
indexis the position of the operation within the sequence

References ghidra::OpTpl::getOut(), ghidra::OpTpl::setOutput(), and vec.

Referenced by ghidra::ConsistencyChecker::applyOptimization().


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