decompiler 1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ghidra::AssignAction Class Referenceabstract

An action that assigns an Address to a function prototype parameter. More...

#include <modelrules.hh>

Inheritance diagram for ghidra::AssignAction:
ghidra::ConsumeAs ghidra::ConsumeExtra ghidra::ConsumeRemaining ghidra::ConvertToPointer ghidra::ExtraStack ghidra::GotoStack ghidra::HiddenReturnAssign ghidra::MultiMemberAssign ghidra::MultiSlotAssign ghidra::MultiSlotDualAssign

Public Types

enum  {
  success , fail , no_assignment , hiddenret_ptrparam ,
  hiddenret_specialreg , hiddenret_specialreg_void
}
 

Public Member Functions

 AssignAction (const ParamListStandard *res)
 Constructor.
 
bool canAffectFillinOutput (void) const
 Return true if fillinOutputMap is active.
 
virtual AssignActionclone (const ParamListStandard *newResource) const =0
 Make a copy of this action.
 
virtual uint4 assignAddress (Datatype *dt, const PrototypePieces &proto, int4 pos, TypeFactory &tlist, vector< int4 > &status, ParameterPieces &res) const =0
 Assign an address and other meta-data for a specific parameter or for return storage in context.
 
virtual bool fillinOutputMap (ParamActive *active) const
 Test if this action could produce return value storage matching the given set of trials.
 
virtual void decode (Decoder &decoder)=0
 Configure any details of how this action should behave from the stream.
 

Static Public Member Functions

static AssignActiondecodeAction (Decoder &decoder, const ParamListStandard *res)
 Read the next model rule action element from the stream.
 
static AssignActiondecodePrecondition (Decoder &decoder, const ParamListStandard *res)
 Read the next model rule precondition element from the stream.
 
static AssignActiondecodeSideeffect (Decoder &decoder, const ParamListStandard *res)
 Read the next model rule sideeffect element from the stream.
 
static void justifyPieces (vector< VarnodeData > &pieces, int4 offset, bool isBigEndian, bool consumeMostSig, bool justifyRight)
 Truncate a tiling by a given number of bytes.
 

Protected Attributes

const ParamListStandardresource
 Resources to which this action applies.
 
bool fillinOutputActive
 If true, fillinOutputMap is active.
 

Detailed Description

An action that assigns an Address to a function prototype parameter.

A request for the address of either return storage or an input parameter is made through the assignAddress() method, which is given full information about the function prototype. Details about how the action performs is configured through the decode() method.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
success 

Data-type is fully assigned.

fail 

Action could not be applied.

no_assignment 

Do not assign storage for this parameter.

hiddenret_ptrparam 

Hidden return pointer as first input parameter.

hiddenret_specialreg 

Hidden return pointer in dedicated input register.

hiddenret_specialreg_void 

Hidden return pointer, but no normal return.

Member Function Documentation

◆ assignAddress()

virtual uint4 ghidra::AssignAction::assignAddress ( Datatype dt,
const PrototypePieces proto,
int4  pos,
TypeFactory tlist,
vector< int4 > &  status,
ParameterPieces res 
) const
pure virtual

Assign an address and other meta-data for a specific parameter or for return storage in context.

The Address is assigned based on the data-type of the parameter, available register resources, and other details of the function prototype. Consumed resources are marked. This method returns a response code:

  • success - indicating the Address was successfully assigned
  • fail - if the Address could not be assigned
  • hiddenret_ptrparam - if an additional hidden return parameter is required
Parameters
dtis the data-type of the parameter or return value
protois the high-level description of the function prototype
posis the position of the parameter (pos>=0) or return storage (pos=-1)
tlistis a data-type factory for (possibly) transforming the data-type
statusis the resource consumption array
reswill hold the resulting description of the parameter
Returns
the response code

Implemented in ghidra::GotoStack, ghidra::ConvertToPointer, ghidra::MultiSlotAssign, ghidra::MultiMemberAssign, ghidra::MultiSlotDualAssign, ghidra::ConsumeAs, ghidra::HiddenReturnAssign, ghidra::ConsumeExtra, ghidra::ExtraStack, and ghidra::ConsumeRemaining.

Referenced by ghidra::ModelRule::assignAddress().

◆ clone()

virtual AssignAction * ghidra::AssignAction::clone ( const ParamListStandard newResource) const
pure virtual

Make a copy of this action.

Parameters
newResourceis the new resource object that will own the clone
Returns
the newly allocated copy

Implemented in ghidra::GotoStack, ghidra::ConvertToPointer, ghidra::MultiSlotAssign, ghidra::MultiMemberAssign, ghidra::MultiSlotDualAssign, ghidra::ConsumeAs, ghidra::HiddenReturnAssign, ghidra::ConsumeExtra, ghidra::ExtraStack, and ghidra::ConsumeRemaining.

Referenced by ghidra::ModelRule::ModelRule(), and ghidra::ModelRule::ModelRule().

◆ decode()

virtual void ghidra::AssignAction::decode ( Decoder decoder)
pure virtual

Configure any details of how this action should behave from the stream.

Parameters
decoderis the given stream decoder

Implemented in ghidra::GotoStack, ghidra::ConvertToPointer, ghidra::MultiSlotAssign, ghidra::MultiMemberAssign, ghidra::MultiSlotDualAssign, ghidra::ConsumeAs, ghidra::HiddenReturnAssign, ghidra::ConsumeExtra, ghidra::ExtraStack, and ghidra::ConsumeRemaining.

Referenced by decodeAction(), decodePrecondition(), and decodeSideeffect().

◆ decodeAction()

AssignAction * ghidra::AssignAction::decodeAction ( Decoder decoder,
const ParamListStandard res 
)
static

Read the next model rule action element from the stream.

Allocate the action object corresponding to the element and configure it. If the next element is not an action, throw an exception.

Parameters
decoderis the stream decoder
resis the resource set for the new action
Returns
the new action

References decode(), hiddenret_specialreg, ghidra::ParamListStandard::isBigEndian(), ghidra::Decoder::peekElement(), and ghidra::TYPECLASS_GENERAL.

Referenced by ghidra::ModelRule::decode().

◆ decodePrecondition()

AssignAction * ghidra::AssignAction::decodePrecondition ( Decoder decoder,
const ParamListStandard res 
)
static

Read the next model rule precondition element from the stream.

Allocate the precondition object corresponding to the element and configure it. If the next element is not a precondition, return null.

Parameters
decoderis the stream decoder
resis the resource set for the new precondition
Returns
the new precondition, or null if no more preconditions are in the stream

References decode(), and ghidra::Decoder::peekElement().

Referenced by ghidra::ModelRule::decode().

◆ decodeSideeffect()

AssignAction * ghidra::AssignAction::decodeSideeffect ( Decoder decoder,
const ParamListStandard res 
)
static

Read the next model rule sideeffect element from the stream.

Allocate the sideeffect object corresponding to the element and configure it. If the next element is not a sideeffect, throw an exception.

Parameters
decoderis the stream decoder
resis the resource set for the new sideeffect
Returns
the new sideeffect

References decode(), and ghidra::Decoder::peekElement().

Referenced by ghidra::ModelRule::decode().

◆ fillinOutputMap()

bool ghidra::AssignAction::fillinOutputMap ( ParamActive active) const
virtual

Test if this action could produce return value storage matching the given set of trials.

If there is a return value data-type that could be assigned storage matching the trials by this action, return true. The trials have their matching ParamEntry and offset already set and are already sorted.

Parameters
activeis the given set of trials
Returns
true if the trials could form a valid return value

Reimplemented in ghidra::GotoStack, ghidra::MultiSlotAssign, ghidra::MultiMemberAssign, ghidra::MultiSlotDualAssign, and ghidra::ConsumeAs.

Referenced by ghidra::ModelRule::fillinOutputMap().

◆ justifyPieces()

void ghidra::AssignAction::justifyPieces ( vector< VarnodeData > &  pieces,
int4  offset,
bool  isBigEndian,
bool  consumeMostSig,
bool  justifyRight 
)
static

Truncate a tiling by a given number of bytes.

The extra bytes are considered padding and removed from one end of the tiling. The bytes removed depend on the endianness and how the data is justified within the tiling.

Parameters
piecesis the tiling of 2 or more Varnodes
offsetis the given number of bytes to truncate
isBigEndianis true for big endian architectures
consumeMostSigis true if the first tile in the list covers the most significant bytes
justifyRightis true if the data is right justified within the tiling

References ghidra::VarnodeData::offset, and ghidra::VarnodeData::size.

Referenced by ghidra::MultiSlotAssign::assignAddress(), and ghidra::MultiSlotDualAssign::assignAddress().


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