mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Adjustments to STORE casting
This commit is contained in:
parent
9a3ab38631
commit
a700c52275
1 changed files with 29 additions and 9 deletions
|
@ -427,17 +427,37 @@ TypeOpStore::TypeOpStore(TypeFactory *t) : TypeOp(t,CPUI_STORE,"store")
|
|||
Datatype *TypeOpStore::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
||||
|
||||
{
|
||||
if (slot!=1) return (Datatype *)0;
|
||||
Datatype *reqtype = op->getIn(2)->getHigh()->getType(); // Cast storage pointer to match what's being stored
|
||||
Datatype *curtype = op->getIn(1)->getHigh()->getType();
|
||||
if (slot==0) return (Datatype *)0;
|
||||
const Varnode *pointerVn = op->getIn(1);
|
||||
Datatype *pointerType = pointerVn->getHigh()->getType();
|
||||
Datatype *valueType = op->getIn(2)->getHigh()->getType();
|
||||
AddrSpace *spc = Address::getSpaceFromConst(op->getIn(0)->getAddr());
|
||||
if (curtype->getMetatype() == TYPE_PTR)
|
||||
curtype = ((TypePointer *)curtype)->getPtrTo();
|
||||
int4 destSize;
|
||||
if (pointerType->getMetatype() == TYPE_PTR) {
|
||||
pointerType = ((TypePointer *)pointerType)->getPtrTo();
|
||||
destSize = pointerType->getSize();
|
||||
}
|
||||
else
|
||||
return tlst->getTypePointer(op->getIn(1)->getSize(),reqtype,spc->getWordSize());
|
||||
reqtype = castStrategy->castStandard(reqtype,curtype,false,true);
|
||||
if (reqtype == (Datatype *)0) return reqtype;
|
||||
return tlst->getTypePointer(op->getIn(1)->getSize(),reqtype,spc->getWordSize());
|
||||
destSize = -1;
|
||||
if (destSize != valueType->getSize()) {
|
||||
if (slot == 1)
|
||||
return tlst->getTypePointer(pointerVn->getSize(),valueType,spc->getWordSize());
|
||||
else
|
||||
return (Datatype *)0;
|
||||
}
|
||||
if (slot == 1) {
|
||||
if (pointerVn->isWritten() && pointerVn->getDef()->code() == CPUI_CAST) {
|
||||
if (pointerVn->isImplied() && pointerVn->loneDescend() == op) {
|
||||
// CAST is already in place, test if it is casting to the right type
|
||||
Datatype *newType = tlst->getTypePointer(pointerVn->getSize(), valueType, spc->getWordSize());
|
||||
if (pointerVn->getHigh()->getType() != newType)
|
||||
return newType;
|
||||
}
|
||||
}
|
||||
return (Datatype *)0;
|
||||
}
|
||||
// If we reach here, cast the value, not the pointer
|
||||
return castStrategy->castStandard(pointerType,valueType,false,true);
|
||||
}
|
||||
|
||||
void TypeOpStore::printRaw(ostream &s,const PcodeOp *op)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue