mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-2627 TypePartialStruct
This commit is contained in:
parent
cc35d57933
commit
2591c17f22
15 changed files with 636 additions and 433 deletions
|
@ -1685,6 +1685,44 @@ int4 RuleAndPiece::applyOp(PcodeOp *op,Funcdata &data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// \class RuleAndZext
|
||||
/// \brief Convert INT_AND to INT_ZEXT where appropriate: `sext(X) & 0xffff => zext(X)`
|
||||
///
|
||||
/// Similarly `concat(Y,X) & 0xffff => zext(X)`
|
||||
void RuleAndZext::getOpList(vector<uint4> &oplist) const
|
||||
|
||||
{
|
||||
oplist.push_back(CPUI_INT_AND);
|
||||
}
|
||||
|
||||
int4 RuleAndZext::applyOp(PcodeOp *op,Funcdata &data)
|
||||
|
||||
{
|
||||
Varnode *cvn1 = op->getIn(1);
|
||||
if (!cvn1->isConstant()) return 0;
|
||||
if (!op->getIn(0)->isWritten()) return 0;
|
||||
PcodeOp *otherop = op->getIn(0)->getDef();
|
||||
OpCode opc = otherop->code();
|
||||
Varnode *rootvn;
|
||||
if (opc == CPUI_INT_SEXT)
|
||||
rootvn = otherop->getIn(0);
|
||||
else if (opc == CPUI_PIECE)
|
||||
rootvn = otherop->getIn(1);
|
||||
else
|
||||
return 0;
|
||||
uintb mask = calc_mask(rootvn->getSize());
|
||||
if (mask != cvn1->getOffset())
|
||||
return 0;
|
||||
if (rootvn->isFree())
|
||||
return 0;
|
||||
if (rootvn->getSize() > sizeof(uintb)) // FIXME: Should be arbitrary precision
|
||||
return 0;
|
||||
data.opSetOpcode(op, CPUI_INT_ZEXT);
|
||||
data.opRemoveInput(op, 1);
|
||||
data.opSetInput(op, rootvn, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// \class RuleAndCompare
|
||||
/// \brief Simplify INT_ZEXT and SUBPIECE in masked comparison: `zext(V) & c == 0 => V & (c & mask) == 0`
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue