mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-5736 prevent constant propagation from making RETURN inputs constant
(Closes #8183)
This commit is contained in:
parent
e28df99d96
commit
fc4b780025
1 changed files with 14 additions and 2 deletions
|
@ -4332,8 +4332,20 @@ void ActionConditionalConst::propagateConstant(Varnode *varVn,Varnode *constVn,F
|
||||||
// ...unless COPY is into something more interesting
|
// ...unless COPY is into something more interesting
|
||||||
}
|
}
|
||||||
if (constBlock->dominates(op->getParent())) {
|
if (constBlock->dominates(op->getParent())) {
|
||||||
int4 slot = op->getSlot(varVn);
|
if (opc == CPUI_RETURN){
|
||||||
data.opSetInput(op,constVn,slot); // Replace ref with constant!
|
// CPUI_RETURN ops can't directly take constants
|
||||||
|
// as inputs
|
||||||
|
PcodeOp *copyBeforeRet = data.newOp(1, op->getAddr());
|
||||||
|
data.opSetOpcode(copyBeforeRet,CPUI_COPY);
|
||||||
|
data.opSetInput(copyBeforeRet,constVn,0);
|
||||||
|
data.newVarnodeOut(varVn->getSize(),varVn->getAddr(),copyBeforeRet);
|
||||||
|
data.opSetInput(op,copyBeforeRet->getOut(),1);
|
||||||
|
data.opInsertBefore(copyBeforeRet,op);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int4 slot = op->getSlot(varVn);
|
||||||
|
data.opSetInput(op,constVn,slot); // Replace ref with constant!
|
||||||
|
}
|
||||||
count += 1; // We made a change
|
count += 1; // We made a change
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue