|
decompiler 1.0.0
|
A constant value encountered during SLEIGH parsing. More...
#include <semantics.hh>
Public Types | |
| enum | const_type { real =0 , handle =1 , j_start =2 , j_next =3 , j_next2 =4 , j_curspace =5 , j_curspace_size =6 , spaceid =7 , j_relative =8 , j_flowref =9 , j_flowref_size =10 , j_flowdest =11 , j_flowdest_size =12 } |
| Types of constant values encountered during SLEIGH parsing. More... | |
| enum | v_field { v_space =0 , v_offset =1 , v_size =2 , v_offset_plus =3 } |
| For a handle (a value calculated in a sub-constructor), we can sub-select which part of the value to use. More... | |
Public Member Functions | |
| ConstTpl (void) | |
| Construct a zero constant. | |
| ConstTpl (const ConstTpl &op2) | |
| Copy constructor. | |
| ConstTpl (const_type tp, uintb val) | |
| Constructor for real constants or relative offsets. More... | |
| ConstTpl (const_type tp) | |
| Constructor for special constants from context. More... | |
| ConstTpl (AddrSpace *sid) | |
| Constructor for a constant representing an address space. More... | |
| ConstTpl (const_type tp, int4 ht, v_field vf) | |
| Constructor for a handle constant. More... | |
| ConstTpl (const_type tp, int4 ht, v_field vf, uintb plus) | |
| Constructor for a handle offset plus a constant. More... | |
| bool | isConstSpace (void) const |
| Return true if this represents the constant address space. | |
| bool | isUniqueSpace (void) const |
| Return true if this represents the unique address space. | |
| bool | operator== (const ConstTpl &op2) const |
| Compare two constants for equality. More... | |
| bool | operator< (const ConstTpl &op2) const |
| Order two constants by type then value. More... | |
| uintb | getReal (void) const |
| Get the literal constant value associated with this. | |
| AddrSpace * | getSpace (void) const |
| Get the address space this is encoding. | |
| int4 | getHandleIndex (void) const |
| Get the index of the sub-constructor computing this. | |
| const_type | getType (void) const |
| Get the constant type. | |
| v_field | getSelect (void) const |
| Get the type of handle piece this is encoding. | |
| uintb | fix (const ParserWalker &walker) const |
| Get the final constant value of this in context. More... | |
| AddrSpace * | fixSpace (const ParserWalker &walker) const |
| Get the final address space this represents in context. | |
| void | transfer (const vector< HandleTpl * > ¶ms) |
| Copy a handle into this based on the handle_index. More... | |
| bool | isZero (void) const |
| Return true if this is a literal zero. | |
| void | changeHandleIndex (const vector< int4 > &handmap) |
| Remap the handle index for this. More... | |
| void | fillinSpace (FixedHandle &hand, const ParserWalker &walker) const |
| Fill in the address space of a FixedHandle, based on this. More... | |
| void | fillinOffset (FixedHandle &hand, const ParserWalker &walker) const |
| Fill in the offset of a FixedHandle, based on this. More... | |
| void | encode (Encoder &encoder) const |
| Encode this SLEIGH constant to an output stream. More... | |
| void | decode (Decoder &decoder) |
| Decode this SLEIGH constant from a stream. More... | |
Private Attributes | |
| const_type | type |
| The type of constant. | |
| union { | |
| AddrSpace * spaceid | |
| Id referring to a registered address space. | |
| int4 handle_index | |
| For a handle, the index of the specific sub-constructor passing back the value. | |
| } | value |
| Specialized values a ConstTpl can represent. | |
| uintb | value_real |
| An immediate constant value or other constant offset a ConstTpl represents. | |
| v_field | select |
| Assuming ConstTpl is a handle, the part of the handle to use as constant. | |
A constant value encountered during SLEIGH parsing.
Any offset, size, address space, or literal constant encountered during parsing that ultimately resolves to a constant value when disassembling or generating p-code for a specific instruction. The object holds details about how to calculate the final constant from the SLEIGH context for the instruction.
Types of constant values encountered during SLEIGH parsing.
| Enumerator | |
|---|---|
| real | A literal constant. |
| handle | Placeholder for a value passed back by a sub-constructor. |
| j_start | Address offset for the start of the current instruction. |
| j_next | Address offset for the start of the next instruction. |
| j_next2 | Address offset of the instruction immediately after the next instruction. |
| j_curspace | Address space containing the current instruction. |
| j_curspace_size | Number of bytes encoding the address of the current instruction. |
| spaceid | An address space (encoded as a constant) |
| j_relative | A relative p-code branch offset. |
| j_flowref | Address offset of any call reference at site of p-code injection. |
| j_flowref_size | Number of bytes encoding address of call reference. |
| j_flowdest | Address offset of call destination being injected. |
| j_flowdest_size | Number of bytes encoding address of call destination. |
For a handle (a value calculated in a sub-constructor), we can sub-select which part of the value to use.
| ghidra::ConstTpl::ConstTpl | ( | const_type | tp, |
| uintb | val | ||
| ) |
Constructor for real constants or relative offsets.
| tp | is constant type: either real or j_relative |
| val | is the constant value |
References select, type, v_space, value, and value_real.
| ghidra::ConstTpl::ConstTpl | ( | const_type | tp | ) |
Constructor for special constants from context.
| tp | is the specialized constant type: j_start, j_next, j_next2, j_flowdest, j_curspace, etc. |
References type.
| ghidra::ConstTpl::ConstTpl | ( | AddrSpace * | sid | ) |
| ghidra::ConstTpl::ConstTpl | ( | const_type | tp, |
| int4 | ht, | ||
| v_field | vf | ||
| ) |
Constructor for a handle constant.
| tp | is the constant type: must be handle |
| ht | is the index of the sub-constructor computing the handle value |
| vf | is the part (space, offset, or size) of the computed value to encode as the constant |
References handle, select, type, value, and value_real.
| ghidra::ConstTpl::ConstTpl | ( | const_type | tp, |
| int4 | ht, | ||
| v_field | vf, | ||
| uintb | plus | ||
| ) |
Constructor for a handle offset plus a constant.
| tp | is the constant type: must be handle |
| ht | is the index of the sub-constructor computing the handle value |
| vf | is the part of the computed value to encode: must be v_offset_plus |
| plus | is the additional constant value to add to the handle offset |
References handle, select, type, value, and value_real.
| void ghidra::ConstTpl::changeHandleIndex | ( | const vector< int4 > & | handmap | ) |
Remap the handle index for this.
This is used to help reorder sub-constructors. If this is a handle, its index is translated by looking up a new value in the given array of indices.
| handmap | is the given array of new handle indices |
References handle, type, and value.
Referenced by ghidra::VarnodeTpl::changeHandleIndex(), and ghidra::HandleTpl::changeHandleIndex().
| void ghidra::ConstTpl::decode | ( | Decoder & | decoder | ) |
Decode this SLEIGH constant from a stream.
| decoder | is the input stream |
References ghidra::Decoder::closeElement(), handle, j_curspace, j_curspace_size, j_flowdest, j_flowdest_size, j_flowref, j_flowref_size, j_next, j_next2, j_relative, j_start, ghidra::Decoder::openElement(), ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readSpace(), ghidra::Decoder::readUnsignedInteger(), real, select, spaceid, type, v_offset_plus, value, and value_real.
Referenced by ghidra::VarnodeTpl::decode(), and ghidra::HandleTpl::decode().
| void ghidra::ConstTpl::encode | ( | Encoder & | encoder | ) | const |
Encode this SLEIGH constant to an output stream.
| encoder | is the output stream |
References ghidra::Encoder::closeElement(), handle, j_curspace, j_curspace_size, j_flowdest, j_flowdest_size, j_flowref, j_flowref_size, j_next, j_next2, j_relative, j_start, ghidra::Encoder::openElement(), real, select, spaceid, type, v_offset_plus, value, value_real, ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeSpace(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by ghidra::VarnodeTpl::encode(), and ghidra::HandleTpl::encode().
| void ghidra::ConstTpl::fillinOffset | ( | FixedHandle & | hand, |
| const ParserWalker & | walker | ||
| ) | const |
Fill in the offset of a FixedHandle, based on this.
First, this is fixed, based on the current context. Then the final fixed value is copied into the FixedHandle. If this itself is a handle, the entire fixed handle is copied into the FixedHandle.
| hand | is the FixedHandle to copy into |
| walker | is the context to fix against |
References fix(), ghidra::ParserWalker::getFixedHandle(), handle, ghidra::FixedHandle::offset_offset, ghidra::FixedHandle::offset_size, ghidra::FixedHandle::offset_space, ghidra::FixedHandle::space, ghidra::FixedHandle::temp_offset, ghidra::FixedHandle::temp_space, type, value, and ghidra::AddrSpace::wrapOffset().
Referenced by ghidra::HandleTpl::fix().
| void ghidra::ConstTpl::fillinSpace | ( | FixedHandle & | hand, |
| const ParserWalker & | walker | ||
| ) | const |
Fill in the address space of a FixedHandle, based on this.
If this represents an address space, including if this is the address space piece of a handle, replace the address space portion of the FixedHandle with this.
| hand | is the FixedHandle to replace |
| walker | is the current context |
References ghidra::ParserWalker::getCurSpace(), ghidra::ParserWalker::getFixedHandle(), handle, j_curspace, select, ghidra::FixedHandle::space, spaceid, type, v_space, and value.
Referenced by ghidra::HandleTpl::fix().
| uintb ghidra::ConstTpl::fix | ( | const ParserWalker & | walker | ) | const |
Get the final constant value of this in context.
If this is a handle associated with a dynamically computed value, this method returns the properties of the temporary storage used to hold the computed value.
| walker | is the context for the parse of a single instruction |
References ghidra::ParserWalker::getAddr(), ghidra::Address::getAddrSize(), ghidra::AddrSpace::getAddrSize(), ghidra::ParserWalker::getConstSpace(), ghidra::ParserWalker::getCurSpace(), ghidra::ParserWalker::getDestAddr(), ghidra::ParserWalker::getFixedHandle(), ghidra::ParserWalker::getN2addr(), ghidra::ParserWalker::getNaddr(), ghidra::Address::getOffset(), ghidra::ParserWalker::getRefAddr(), handle, j_curspace, j_curspace_size, j_flowdest, j_flowdest_size, j_flowref, j_flowref_size, j_next, j_next2, j_relative, j_start, ghidra::FixedHandle::offset_offset, ghidra::FixedHandle::offset_space, real, select, ghidra::FixedHandle::size, ghidra::FixedHandle::space, spaceid, ghidra::FixedHandle::temp_offset, ghidra::FixedHandle::temp_space, type, v_offset, v_offset_plus, v_size, v_space, value, and value_real.
Referenced by ghidra::SleighBuilder::appendCrossBuild(), fillinOffset(), ghidra::HandleTpl::fix(), and ghidra::SleighBuilder::generateLocation().
| bool ghidra::ConstTpl::operator< | ( | const ConstTpl & | op2 | ) | const |
Order two constants by type then value.
| op2 | is the constant to compare with this |
References handle, handle_index, real, select, spaceid, type, value, and value_real.
| bool ghidra::ConstTpl::operator== | ( | const ConstTpl & | op2 | ) | const |
Compare two constants for equality.
The constants must be equal in both value and type.
| op2 | is the constant to compare with this |
References handle, handle_index, real, select, spaceid, type, value, and value_real.
| void ghidra::ConstTpl::transfer | ( | const vector< HandleTpl * > & | params | ) |
Copy a handle into this based on the handle_index.
If this is not a handle, do nothing. Otherwise, copy the details of the indexed HandleTpl into this. Copy the piece of the HandleTpl specified by select.
| params | is the array of HandleTpl |
References ghidra::HandleTpl::getPtrOffset(), ghidra::HandleTpl::getSize(), ghidra::HandleTpl::getSpace(), handle, real, select, type, v_offset, v_offset_plus, v_size, v_space, value, and value_real.
Referenced by ghidra::VarnodeTpl::transfer().