Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
Manager/container for description objects (UserPcodeOp) of user defined p-code ops. More...
#include <userop.hh>
Public Member Functions | |
UserOpManage (void) | |
Construct an empty manager. | |
~UserOpManage (void) | |
Destructor. | |
void | initialize (Architecture *g) |
Initialize description objects for all user defined ops. | |
int4 | numSegmentOps (void) const |
Number of segment operations supported. | |
UserPcodeOp * | getOp (uint4 i) const |
Retrieve a user-op description object by index. | |
UserPcodeOp * | getOp (const string &nm) const |
Retrieve description by name. | |
UserPcodeOp * | registerBuiltin (uint4 i) |
Make sure an active record exists for the given built-in op. | |
SegmentOp * | getSegmentOp (int4 i) const |
void | decodeSegmentOp (Decoder &decoder, Architecture *glb) |
Parse a <segmentop> element. | |
void | decodeVolatile (Decoder &decoder, Architecture *glb) |
Parse a <volatile> element. | |
void | decodeCallOtherFixup (Decoder &decoder, Architecture *glb) |
Parse a <callotherfixup> element. | |
void | decodeJumpAssist (Decoder &decoder, Architecture *glb) |
Parse a <jumpassist> element. | |
void | manualCallOtherFixup (const string &useropname, const string &outname, const vector< string > &inname, const string &snippet, Architecture *glb) |
Manually install an InjectedUserOp given just names of the user defined op and the p-code snippet. | |
Private Member Functions | |
void | registerOp (UserPcodeOp *op) |
Insert a new UserPcodeOp description object in the map(s) | |
Private Attributes | |
Architecture * | glb |
Architecture this manager is associated with. | |
vector< UserPcodeOp * > | useroplist |
Description objects indexed by CALLOTHER constant id. | |
map< uint4, UserPcodeOp * > | builtinmap |
Map from builtin ids to description objects. | |
map< string, UserPcodeOp * > | useropmap |
A map from the name of the user defined operation to a description object. | |
vector< SegmentOp * > | segmentop |
Segment operations supported by this Architecture. | |
Manager/container for description objects (UserPcodeOp) of user defined p-code ops.
The description objects are referenced by the CALLOTHER constant id, (or by name during initialization). During initialize(), every user defined p-code op presented by the Architecture is assigned a default UnspecializedPcodeOp description. Further processing of the .cspec or .pspec may reassign a more specialized description object by parsing specific tags using on of this class's parse* methods.
void ghidra::UserOpManage::decodeCallOtherFixup | ( | Decoder & | decoder, |
Architecture * | glb | ||
) |
Parse a <callotherfixup> element.
Create an InjectedUserOp description object based on the element and register it with this manager.
decoder | is the stream decoder |
glb | is the owning Architecture |
References ghidra::InjectedUserOp::decode(), glb, and registerOp().
Referenced by ghidra::Architecture::parseCompilerConfig().
void ghidra::UserOpManage::decodeJumpAssist | ( | Decoder & | decoder, |
Architecture * | glb | ||
) |
Parse a <jumpassist> element.
Create a JumpAssistOp description object based on the element and register it with this manager.
decoder | is the stream decoder |
glb | is the owning Architecture |
References ghidra::JumpAssistOp::decode(), glb, and registerOp().
Referenced by ghidra::Architecture::parseProcessorConfig().
void ghidra::UserOpManage::decodeSegmentOp | ( | Decoder & | decoder, |
Architecture * | glb | ||
) |
Parse a <segmentop> element.
Create a SegmentOp description object based on the element and register it with this manager.
decoder | is the stream decoder |
glb | is the owning Architecture |
References ghidra::SegmentOp::decode(), glb, registerOp(), and useroplist.
Referenced by ghidra::Architecture::parseCompilerConfig(), and ghidra::Architecture::parseProcessorConfig().
void ghidra::UserOpManage::decodeVolatile | ( | Decoder & | decoder, |
Architecture * | glb | ||
) |
Parse a <volatile> element.
Create either a VolatileReadOp or VolatileWriteOp description object based on the element and register it with this manager.
decoder | is the stream decoder |
glb | is the owning Architecture |
References ghidra::UserPcodeOp::BUILTIN_VOLATILE_READ, ghidra::UserPcodeOp::BUILTIN_VOLATILE_WRITE, builtinmap, ghidra::Decoder::getNextAttributeId(), glb, and ghidra::Decoder::readString().
Referenced by ghidra::Architecture::decodeVolatile().
UserPcodeOp * ghidra::UserOpManage::getOp | ( | const string & | nm | ) | const |
Retrieve description by name.
nm | is the low-level operation name |
References useropmap.
UserPcodeOp * ghidra::UserOpManage::getOp | ( | uint4 | i | ) | const |
Retrieve a user-op description object by index.
Retrieve a user-op description object by index
i | is the index |
References builtinmap, and useroplist.
Referenced by ghidra::InjectedUserOp::decode(), ghidra::SegmentOp::decode(), ghidra::JumpAssistOp::decode(), ghidra::Funcdata::earlyJumpTableFail(), ghidra::TypeOpCallother::getInputLocal(), ghidra::TypeOpCallother::getOperatorName(), ghidra::TypeOpCallother::getOutputLocal(), ghidra::FlowInfo::injectUserOp(), manualCallOtherFixup(), ghidra::PrintC::opCallother(), ghidra::PrintC::pushAnnotation(), ghidra::JumpAssisted::recoverModel(), and ghidra::FlowInfo::xrefControlFlow().
|
inline |
Retrieve a segment-op description object by index
i | is the index |
References segmentop.
Referenced by ghidra::ActionSegmentize::apply(), ghidra::RuleSegment::applyOp(), ghidra::Funcdata::createStackRef(), ghidra::EmulatePcodeOp::executeSegmentOp(), ghidra::Architecture::getSegmentOp(), and ghidra::Architecture::initializeSegments().
void ghidra::UserOpManage::initialize | ( | Architecture * | g | ) |
Initialize description objects for all user defined ops.
Every user defined p-code op is initially assigned an UnspecializedPcodeOp description, which may get overridden later.
g | is the Architecture from which to draw user defined operations |
References ghidra::Translate::getUserOpNames(), glb, registerOp(), and ghidra::Architecture::translate.
Referenced by ghidra::Architecture::restoreFromSpec().
void ghidra::UserOpManage::manualCallOtherFixup | ( | const string & | useropname, |
const string & | outname, | ||
const vector< string > & | inname, | ||
const string & | snippet, | ||
Architecture * | glb | ||
) |
Manually install an InjectedUserOp given just names of the user defined op and the p-code snippet.
An alternate way to attach a call-fixup to user defined p-code ops, without using XML. The p-code to inject is presented as a raw string to be handed to the p-code parser.
useropname | is the name of the user defined op |
outname | is the name of the output variable in the snippet |
inname | is the list of input variable names in the snippet |
snippet | is the raw p-code source snippet |
glb | is the owning Architecture |
References ghidra::UserPcodeOp::getIndex(), getOp(), glb, ghidra::PcodeInjectLibrary::manualCallOtherFixup(), ghidra::Architecture::pcodeinjectlib, and registerOp().
UserPcodeOp * ghidra::UserOpManage::registerBuiltin | ( | uint4 | i | ) |
Make sure an active record exists for the given built-in op.
Retrieve a built-in user-op given its id. If user-op record does not already exist, instantiate a default form of the record.
i | is the index associated |
References ghidra::UserPcodeOp::BUILTIN_MEMCPY, ghidra::UserPcodeOp::BUILTIN_STRINGDATA, ghidra::UserPcodeOp::BUILTIN_STRNCPY, ghidra::UserPcodeOp::BUILTIN_VOLATILE_READ, ghidra::UserPcodeOp::BUILTIN_VOLATILE_WRITE, ghidra::UserPcodeOp::BUILTIN_WCSNCPY, builtinmap, ghidra::TypeFactory::getBase(), ghidra::AddrSpaceManager::getDefaultDataSpace(), ghidra::TypeFactory::getSizeOfChar(), ghidra::TypeFactory::getSizeOfPointer(), ghidra::TypeFactory::getSizeOfWChar(), ghidra::TypeFactory::getTypeChar(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypeVoid(), ghidra::AddrSpace::getWordSize(), glb, ghidra::TYPE_INT, and ghidra::Architecture::types.
Referenced by ghidra::StringSequence::buildStringCopy(), ghidra::HeapSequence::buildStringCopy(), ghidra::Funcdata::getInternalString(), and ghidra::Funcdata::replaceVolatile().
|
private |
Insert a new UserPcodeOp description object in the map(s)
Add the description to the mapping by index and the mapping by name. Make same basic sanity checks for conflicting values and duplicate operations and throw an exception if there's a problem.
op | is the new description object |
References ghidra::AddrSpace::getIndex(), ghidra::UserPcodeOp::getIndex(), ghidra::UserPcodeOp::getName(), ghidra::SegmentOp::getSpace(), segmentop, useroplist, and useropmap.
Referenced by decodeCallOtherFixup(), decodeJumpAssist(), decodeSegmentOp(), initialize(), and manualCallOtherFixup().