Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
The segmented address operator. More...
#include <userop.hh>
Public Member Functions | |
SegmentOp (const string &nm, Architecture *g, int4 ind) | |
Constructor. | |
AddrSpace * | getSpace (void) const |
Get the address space being pointed to. | |
bool | hasFarPointerSupport (void) const |
Return true, if this op supports far pointers. | |
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 VarnodeData & | getResolve (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. | |
virtual uintb | execute (const vector< uintb > &input) const |
Compute the output value of this operation, given constant inputs. | |
virtual void | decode (Decoder &decoder) |
Restore the detailed description from a stream element. | |
![]() | |
TermPatternOp (const string &nm, Architecture *g, uint4 tp, int4 ind) | |
Constructor. | |
![]() | |
UserPcodeOp (const string &nm, Architecture *g, uint4 tp, int4 ind) | |
Construct from name and index. | |
const string & | getName (void) const |
Get the low-level name of the p-code op. | |
uint4 | getType (void) const |
Get the encoded class type. | |
int4 | getIndex (void) const |
Get the constant id of the op. | |
uint4 | getDisplay (void) const |
Get display type (0=functional) | |
virtual | ~UserPcodeOp (void) |
Destructor. | |
virtual string | getOperatorName (const PcodeOp *op) const |
Get the symbol representing this operation in decompiled code. | |
virtual Datatype * | getOutputLocal (const PcodeOp *op) const |
Return the output data-type of the user-op if specified. | |
virtual Datatype * | getInputLocal (const PcodeOp *op, int4 slot) const |
Return the input data-type to the user-op in the given slot. | |
virtual int4 | extractAnnotationSize (const Varnode *vn, const PcodeOp *op) |
Assign a size to an annotation input to this userop. | |
Private Attributes | |
AddrSpace * | spc |
The physical address space into which a segmented pointer points. | |
int4 | injectId |
Id of InjectPayload that emulates this operation. | |
int4 | baseinsize |
The size in bytes of the base or segment value. | |
int4 | innerinsize |
The size in bytes of the near pointer value. | |
bool | supportsfarpointer |
Is true if the joined pair base:near acts as a far pointer. | |
VarnodeData | constresolve |
How to resolve constant near pointers. | |
Additional Inherited Members | |
![]() | |
enum | userop_flags { annotation_assignment = 1 , no_operator = 2 , display_string = 4 } |
Enumeration of different boolean properties that can be assigned to a CALLOTHER. More... | |
enum | userop_type { unspecialized = 1 , injected = 2 , volatile_read = 3 , volatile_write = 4 , segment = 5 , jumpassist = 6 , string_data = 7 , datatype = 8 } |
User-op class encoded as an enum. More... | |
![]() | |
static const uint4 | BUILTIN_STRINGDATA = 0x10000000 |
Built-in id for the InternalStringOp. | |
static const uint4 | BUILTIN_VOLATILE_READ = 0x10000001 |
Built-in id for VolatileReadOp. | |
static const uint4 | BUILTIN_VOLATILE_WRITE = 0x10000002 |
Built-in id for VolatileWriteOp. | |
static const uint4 | BUILTIN_MEMCPY = 0x10000003 |
Built-in id for memcpy. | |
static const uint4 | BUILTIN_STRNCPY = 0x10000004 |
Built-in id for strcpy. | |
static const uint4 | BUILTIN_WCSNCPY = 0x10000005 |
Built-in id for wcsncpy. | |
![]() | |
string | name |
Low-level name of p-code operator. | |
Architecture * | glb |
Architecture owning the user defined op. | |
uint4 | type |
Encoded class type (userop_type) | |
int4 | useropindex |
Index passed in the CALLOTHER op. | |
uint4 | flags |
Boolean attributes of the CALLOTHER. | |
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().
ghidra::SegmentOp::SegmentOp | ( | const string & | nm, |
Architecture * | g, | ||
int4 | ind | ||
) |
nm | is the low-level name of the segment operation |
g | is the owning Architecture for this instance of the segment operation |
ind | is the constant id identifying the specific CALLOTHER variant |
References constresolve, and ghidra::VarnodeData::space.
|
virtual |
Restore the detailed description from a stream element.
The details of how a user defined operation behaves are parsed from the element.
decoder | is the stream decoder |
Implements ghidra::UserPcodeOp.
References baseinsize, ghidra::Decoder::closeElement(), constresolve, ghidra::Address::decode(), ghidra::PcodeInjectLibrary::decodeInject(), ghidra::InjectPayload::EXECUTABLEPCODE_TYPE, ghidra::UserPcodeOp::getIndex(), ghidra::InjectPayload::getInput(), ghidra::Decoder::getNextAttributeId(), ghidra::Address::getOffset(), ghidra::UserOpManage::getOp(), ghidra::PcodeInjectLibrary::getPayload(), ghidra::InjectParameter::getSize(), ghidra::Address::getSpace(), ghidra::UserPcodeOp::glb, injectId, innerinsize, ghidra::UserPcodeOp::name, ghidra::VarnodeData::offset, ghidra::Decoder::openElement(), ghidra::Architecture::pcodeinjectlib, ghidra::Decoder::peekElement(), ghidra::Decoder::readSpace(), ghidra::Decoder::readString(), ghidra::VarnodeData::size, ghidra::InjectPayload::sizeInput(), ghidra::InjectPayload::sizeOutput(), ghidra::VarnodeData::space, spc, supportsfarpointer, ghidra::UserPcodeOp::useropindex, and ghidra::Architecture::userops.
Referenced by ghidra::UserOpManage::decodeSegmentOp().
|
virtual |
Compute the output value of this operation, given constant inputs.
input | is the ordered list of constant inputs |
Implements ghidra::TermPatternOp.
References ghidra::ExecutablePcode::evaluate(), ghidra::PcodeInjectLibrary::getPayload(), ghidra::UserPcodeOp::glb, injectId, and ghidra::Architecture::pcodeinjectlib.
Referenced by ghidra::RuleSegment::applyOp(), ghidra::EmulatePcodeOp::executeSegmentOp(), and ghidra::SegmentedResolver::resolve().
|
inlinevirtual |
Get the number of input Varnodes expected.
Implements ghidra::TermPatternOp.
References baseinsize.
Referenced by ghidra::ActionSegmentize::apply().
|
virtual |
Gather the formal input Varnode objects given the root PcodeOp.
data | is the function being analyzed |
op | is the root operation |
bindlist | will hold the ordered list of input Varnodes |
Implements ghidra::TermPatternOp.
References baseinsize, ghidra::PcodeOp::code(), ghidra::CPUI_CALLOTHER, ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), innerinsize, ghidra::Varnode::isConstant(), ghidra::Funcdata::newConstant(), ghidra::PcodeOp::numInput(), and ghidra::UserPcodeOp::useropindex.
Referenced by ghidra::ActionSegmentize::apply().