mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
PTRADD adjustments post ActionRestructureHigh
This commit is contained in:
parent
cfc1177ac1
commit
9a3ab38631
4 changed files with 50 additions and 21 deletions
|
@ -521,6 +521,42 @@ Varnode *Funcdata::opStackLoad(AddrSpace *spc,uintb off,uint4 sz,PcodeOp *op,Var
|
|||
return res;
|
||||
}
|
||||
|
||||
/// Convert the given CPUI_PTRADD into the equivalent CPUI_INT_ADD. This may involve inserting a
|
||||
/// CPUI_INT_MULT PcodeOp. If finalization is requested and a new PcodeOp is needed, the output
|
||||
/// Varnode is marked as \e implicit and has its data-type set
|
||||
/// \param op is the given PTRADD
|
||||
void Funcdata::opUndoPtradd(PcodeOp *op,bool finalize)
|
||||
|
||||
{
|
||||
Varnode *multVn = op->getIn(2);
|
||||
int4 multSize = multVn->getOffset(); // Size the PTRADD thinks we are pointing
|
||||
|
||||
opRemoveInput(op,2);
|
||||
opSetOpcode(op,CPUI_INT_ADD);
|
||||
if (multSize == 1) return; // If no multiplier, we are done
|
||||
Varnode *offVn = op->getIn(1);
|
||||
if (offVn->isConstant()) {
|
||||
uintb newVal = multSize * offVn->getOffset();
|
||||
newVal &= calc_mask(offVn->getSize());
|
||||
Varnode *newOffVn = newConstant(offVn->getSize(), newVal);
|
||||
if (finalize)
|
||||
newOffVn->updateType(offVn->getType(), false, false);
|
||||
opSetInput(op,newOffVn,1);
|
||||
return;
|
||||
}
|
||||
PcodeOp *multOp = newOp(2,op->getAddr());
|
||||
opSetOpcode(multOp,CPUI_INT_MULT);
|
||||
Varnode *addVn = newUniqueOut(offVn->getSize(),multOp);
|
||||
if (finalize) {
|
||||
addVn->updateType(multVn->getType(), false, false);
|
||||
addVn->setImplied();
|
||||
}
|
||||
opSetInput(multOp,offVn,0);
|
||||
opSetInput(multOp,multVn,1);
|
||||
opSetInput(op,addVn,1);
|
||||
opInsertBefore(multOp,op);
|
||||
}
|
||||
|
||||
/// Make a clone of the given PcodeOp, copying control-flow properties as well. The data-type
|
||||
/// is \e not cloned.
|
||||
/// \param op is the PcodeOp to clone
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue