GP-2601 Adjustments to setting up callspecs

This commit is contained in:
caheckman 2022-09-26 17:23:48 -04:00
parent a64afa37a7
commit e45be5da7d
10 changed files with 120 additions and 35 deletions

View file

@ -125,6 +125,7 @@ void IfaceDecompCapability::registerCommands(IfaceStatus *status)
status->registerCom(new IfcCallGraphList(),"callgraph","list");
status->registerCom(new IfcCallFixup(),"fixup","call");
status->registerCom(new IfcCallOtherFixup(),"fixup","callother");
status->registerCom(new IfcFixupApply(),"fixup","apply");
status->registerCom(new IfcVolatile(),"volatile");
status->registerCom(new IfcReadonly(),"readonly");
status->registerCom(new IfcPointerSetting(),"pointer","setting");
@ -2883,6 +2884,43 @@ void IfcCallOtherFixup::execute(istream &s)
*status->optr << "Successfully registered callotherfixup" << endl;
}
/// \class IfcFixupApply
/// \brief Apply a call-fixup to a particular function: `fixup apply <fixup> <function>`
///
/// The call-fixup and function are named from the command-line. If they both exist,
/// the fixup is set on the function's prototype.
void IfcFixupApply::execute(istream &s)
{
if (dcp->conf == (Architecture *)0)
throw IfaceExecutionError("No load image present");
string fixupName,funcName;
s >> ws;
if (s.eof())
throw IfaceParseError("Missing fixup name");
s >> fixupName >> ws;
if (s.eof())
throw IfaceParseError("Missing function name");
s >> funcName;
int4 injectid = dcp->conf->pcodeinjectlib->getPayloadId(InjectPayload::CALLFIXUP_TYPE, fixupName);
if (injectid < 0)
throw IfaceExecutionError("Unknown fixup: " + fixupName);
string basename;
Scope *funcscope = dcp->conf->symboltab->resolveScopeFromSymbolName(funcName,"::",basename,(Scope *)0);
if (funcscope == (Scope *)0)
throw IfaceExecutionError("Bad namespace: "+funcName);
Funcdata *fd = funcscope->queryFunction( basename ); // Is function already in database
if (fd == (Funcdata *)0)
throw IfaceExecutionError("Unknown function name: "+funcName);
fd->getFuncProto().setInjectId(injectid);
*status->optr << "Successfully applied callfixup" << endl;
}
/// \class IfcVolatile
/// \brief Mark a memory range as volatile: `volatile <address+size>`
///