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

A (partially) resolved Varnode in a SLEIGH specification. More...

#include <semantics.hh>

Public Member Functions

 VarnodeTpl (int4 hand, bool zerosize)
 Construct a handle. More...
 
 VarnodeTpl (void)
 Construct an uninitialized VarnodeTpl.
 
 VarnodeTpl (const ConstTpl &sp, const ConstTpl &off, const ConstTpl &sz)
 Construct directly from ConstTpl. More...
 
 VarnodeTpl (const VarnodeTpl &vn)
 Copy constructor. More...
 
const ConstTpl & getSpace (void) const
 Get the address space.
 
const ConstTpl & getOffset (void) const
 Get the offset.
 
const ConstTpl & getSize (void) const
 Get the size.
 
bool isDynamic (const ParserWalker &walker) const
 Return true if this is a dynamically computed handle. More...
 
int4 transfer (const vector< HandleTpl * > &params)
 Copy a computed HandleTpl into this from the given array. More...
 
bool isZeroSize (void) const
 Return true if this currently has a size of zero.
 
bool operator== (const VarnodeTpl &op2) const
 Test if two VarnodeTpl are equal. More...
 
bool operator!= (const VarnodeTpl &op2) const
 Test if two VarnodeTpl are not equal. More...
 
bool operator< (const VarnodeTpl &op2) const
 Order two VarnodeTpl. More...
 
void setOffset (uintb constVal)
 Set the offset piece to a literal constant.
 
void setRelative (uintb constVal)
 Set the offset piece to a relative branch offset.
 
void setSize (const ConstTpl &sz)
 Set the size piece.
 
bool isUnnamed (void) const
 Return true if this is an unnamed temporary register.
 
void setUnnamed (bool val)
 Mark this as an unnamed temporary register.
 
bool isLocalTemp (void) const
 Return true if this is a temporary register.
 
bool isRelative (void) const
 Return true if this is a relative branch offset.
 
void changeHandleIndex (const vector< int4 > &handmap)
 Remap any handle indices for this. More...
 
bool adjustTruncation (int4 sz, bool isbigendian)
 Adjust truncation given final size of the Varnode. More...
 
void encode (Encoder &encoder) const
 Encode this VarnodeTpl to an output stream. More...
 
void decode (Decoder &decoder)
 Decode this VarnodeTpl from a stream. More...
 

Private Attributes

ConstTpl space
 Address space associated with this variable.
 
ConstTpl offset
 Offset into the address space.
 
ConstTpl size
 Number of bytes in this variable.
 
bool unnamed_flag
 Set to true if this is an unnamed temporary register.
 

Friends

class OpTpl
 
class HandleTpl
 

Detailed Description

A (partially) resolved Varnode in a SLEIGH specification.

Variable symbols in SLEIGH are represented using this object. It encodes the address space, offset, and size associated with the variable. In the context of a specific instruction, this is translated into a Varnode object.

Constructor & Destructor Documentation

◆ VarnodeTpl() [1/3]

ghidra::VarnodeTpl::VarnodeTpl ( int4  hand,
bool  zerosize 
)

Construct a handle.

Parameters
handis the index of the sub-constructor computing the handle value
zerosizeis true if the size of this should be disassociated from the computed handle and forced to zero

References ghidra::ConstTpl::real, size, and unnamed_flag.

◆ VarnodeTpl() [2/3]

ghidra::VarnodeTpl::VarnodeTpl ( const ConstTpl &  sp,
const ConstTpl &  off,
const ConstTpl &  sz 
)

Construct directly from ConstTpl.

Parameters
sprepresents the address space
offrepresents the offset into the address space
szrepresents the number of bytes

References unnamed_flag.

◆ VarnodeTpl() [3/3]

ghidra::VarnodeTpl::VarnodeTpl ( const VarnodeTpl &  vn)

Copy constructor.

Parameters
vnis the VarnodeTpl to copy

References unnamed_flag.

Member Function Documentation

◆ adjustTruncation()

bool ghidra::VarnodeTpl::adjustTruncation ( int4  sz,
bool  isbigendian 
)

Adjust truncation given final size of the Varnode.

The offset piece must be v_offset_plus, indicating this is truncated. Compute the final form of the truncation given the final size and endianness. Also check that the truncation is in bounds for the given final size.

Parameters
szis the final size of the Varnode in bytes
isbigendianis true if the address space is big endian.
Returns
true if the truncation is in bounds

References ghidra::ConstTpl::getHandleIndex(), ghidra::ConstTpl::getReal(), ghidra::ConstTpl::getType(), ghidra::ConstTpl::handle, offset, ghidra::ConstTpl::real, size, and ghidra::ConstTpl::v_offset_plus.

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

◆ changeHandleIndex()

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

Remap any handle indices for this.

This is used to help reorder sub-constructors. For each piece of this, if it is a handle, its index is translated by looking up a new value in the given array of indices.

Parameters
handmapis the given array of new handle indices

References ghidra::ConstTpl::changeHandleIndex(), offset, size, and space.

Referenced by ghidra::OpTpl::changeHandleIndex().

◆ decode()

void ghidra::VarnodeTpl::decode ( Decoder &  decoder)

Decode this VarnodeTpl from a stream.

Parameters
decoderis the input stream

References ghidra::Decoder::closeElement(), ghidra::ConstTpl::decode(), offset, ghidra::Decoder::openElement(), size, and space.

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

◆ encode()

void ghidra::VarnodeTpl::encode ( Encoder &  encoder) const

Encode this VarnodeTpl to an output stream.

Parameters
encoderis the output stream

References ghidra::Encoder::closeElement(), ghidra::ConstTpl::encode(), offset, ghidra::Encoder::openElement(), size, and space.

Referenced by ghidra::OpTpl::encode().

◆ isDynamic()

bool ghidra::VarnodeTpl::isDynamic ( const ParserWalker &  walker) const

Return true if this is a dynamically computed handle.

If the offset is computed by a sub-constructor using a p-code LOAD into a temporary register, then return true. If the sub-constructor does not use a LOAD, or this is not a handle, return false.

Parameters
walkeris the instruction context (used to look-up the specific sub-constructor)
Returns
true if this is a dynamic value computed by a sub-constructor

References ghidra::ParserWalker::getFixedHandle(), ghidra::ConstTpl::getHandleIndex(), ghidra::ConstTpl::getType(), ghidra::ConstTpl::handle, offset, and ghidra::FixedHandle::offset_space.

Referenced by ghidra::SleighBuilder::dump().

◆ operator!=()

bool ghidra::VarnodeTpl::operator!= ( const VarnodeTpl &  op2) const

Test if two VarnodeTpl are not equal.

Parameters
op2is the VarnodeTpl to compare with this
Returns
true if address space, offset, or size is not equal

◆ operator<()

bool ghidra::VarnodeTpl::operator< ( const VarnodeTpl &  op2) const

Order two VarnodeTpl.

Order by address space, then offset, then size

Parameters
op2is the VarnodeTpl to order with this
Returns
true if this should come before op2

References offset, size, and space.

◆ operator==()

bool ghidra::VarnodeTpl::operator== ( const VarnodeTpl &  op2) const

Test if two VarnodeTpl are equal.

Parameters
op2is the VarnodeTpl to compare with this
Returns
true if address space, offset, and size or all equal

References offset, size, and space.

◆ transfer()

int4 ghidra::VarnodeTpl::transfer ( const vector< HandleTpl * > &  params)

Copy a computed HandleTpl into this from the given array.

For any piece of this (address space,offset,size) that is a handle, copy the HandleTpl with matching index. If this needs an additional constant added to its final offset piece, return that constant.

Parameters
paramsis the given array of HandleTpl to match against
Returns
any additional constant that still needs to be added in, or -1 otherwise

References ghidra::ConstTpl::getHandleIndex(), ghidra::ConstTpl::getReal(), ghidra::ConstTpl::getSelect(), getSize(), ghidra::ConstTpl::getType(), ghidra::ConstTpl::handle, isLocalTemp(), ghidra::ConstTpl::isZero(), offset, size, space, ghidra::ConstTpl::transfer(), and ghidra::ConstTpl::v_offset_plus.

Referenced by ghidra::MacroBuilder::transferOp().


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