adjustments to resolveConstant

This commit is contained in:
caheckman 2019-08-19 10:19:36 -04:00
parent 612c0d6f3e
commit 4edff2b9f0
10 changed files with 51 additions and 20 deletions

View file

@ -333,7 +333,7 @@ void Funcdata::spacebaseConstant(PcodeOp *op,int4 slot,SymbolEntry *entry,const
outvn = outvn2;
opInsertBefore(extraop,op);
}
if (sz != origsize) { // There is a change in size from address -> varnode
if (sz < origsize) { // The new constant is smaller than the original varnode, so we extend it
PcodeOp *zextop = newOp(1,op->getAddr());
Varnode *outvn2 = newUniqueOut(origsize,zextop);
opSetOpcode(zextop,CPUI_INT_ZEXT); // Create an extension to get back to original varnode size
@ -341,6 +341,15 @@ void Funcdata::spacebaseConstant(PcodeOp *op,int4 slot,SymbolEntry *entry,const
opInsertBefore(zextop,op);
outvn = outvn2;
}
else if (origsize < sz) { // The new constant is bigger than the original varnode, truncate it
PcodeOp *subOp = newOp(2,op->getAddr());
Varnode *outvn3 = newUniqueOut(origsize,subOp);
opSetOpcode(subOp,CPUI_SUBPIECE);
opSetInput(subOp,outvn,0);
opSetInput(subOp,newConstant(4, 0), 1); // Take least significant piece
opInsertBefore(subOp,op);
outvn = outvn3;
}
opSetInput(op,outvn,slot);
}