subvariableflow modifications

This commit is contained in:
caheckman 2019-10-22 14:08:57 -04:00
parent b0609a1cb3
commit 216725f4cd

View file

@ -367,7 +367,7 @@ bool SubvariableFlow::traceForward(ReplaceVarnode *rvn)
break; break;
} }
// Is the small variable getting zero padded into something that is fully consumed // Is the small variable getting zero padded into something that is fully consumed
if ((!aggressive)&&(calc_mask(outvn->getSize()) == outvn->getConsume())) { if ((!aggressive)&&((outvn->getConsume() & rvn->mask) != outvn->getConsume())) {
addSuggestedPatch(rvn,op,-1); addSuggestedPatch(rvn,op,-1);
hcount += 1; // Dealt with this descendant hcount += 1; // Dealt with this descendant
break; break;
@ -1310,18 +1310,25 @@ void SubvariableFlow::doReplacement(void)
// where all the remaining bits are zero // where all the remaining bits are zero
int4 sa = (*piter).slot; int4 sa = (*piter).slot;
vector<Varnode *> invec; vector<Varnode *> invec;
Varnode *inVn = getReplaceVarnode((*piter).in1);
int4 outSize = pullop->getOut()->getSize();
if (sa == 0) { if (sa == 0) {
invec.push_back( getReplaceVarnode((*piter).in1) ); invec.push_back( inVn );
fd->opSetOpcode( pullop, CPUI_INT_ZEXT ); OpCode opc = (inVn->getSize() == outSize) ? CPUI_COPY : CPUI_INT_ZEXT;
fd->opSetOpcode( pullop, opc );
fd->opSetAllInput(pullop,invec); fd->opSetAllInput(pullop,invec);
} }
else { else {
PcodeOp *zextop = fd->newOp(1,pullop->getAddr()); if (inVn->getSize() != outSize) {
fd->opSetOpcode( zextop, CPUI_INT_ZEXT ); PcodeOp *zextop = fd->newOp(1,pullop->getAddr());
Varnode *zextout = fd->newUniqueOut(pullop->getOut()->getSize(),zextop); fd->opSetOpcode( zextop, CPUI_INT_ZEXT );
fd->opSetInput(zextop,getReplaceVarnode((*piter).in1),0); Varnode *zextout = fd->newUniqueOut(outSize,zextop);
fd->opInsertBefore(zextop,pullop); fd->opSetInput(zextop,inVn,0);
invec.push_back(zextout); fd->opInsertBefore(zextop,pullop);
invec.push_back(zextout);
}
else
invec.push_back(inVn);
invec.push_back(fd->newConstant(4,sa)); invec.push_back(fd->newConstant(4,sa));
fd->opSetAllInput(pullop,invec); fd->opSetAllInput(pullop,invec);
fd->opSetOpcode( pullop, CPUI_INT_LEFT); fd->opSetOpcode( pullop, CPUI_INT_LEFT);