mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
convert splitVarnode to transferVarnodeProperties
This commit is contained in:
parent
873294d1d8
commit
bb0feb3d62
2 changed files with 12 additions and 24 deletions
|
@ -352,7 +352,7 @@ public:
|
||||||
bool onlyOpUse(const Varnode *invn,const PcodeOp *opmatch,const ParamTrial &trial) const;
|
bool onlyOpUse(const Varnode *invn,const PcodeOp *opmatch,const ParamTrial &trial) const;
|
||||||
bool ancestorOpUse(int4 maxlevel,const Varnode *invn,const PcodeOp *op,ParamTrial &trial) const;
|
bool ancestorOpUse(int4 maxlevel,const Varnode *invn,const PcodeOp *op,ParamTrial &trial) const;
|
||||||
bool syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes);
|
bool syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes);
|
||||||
void splitVarnode(Varnode *vn,int4 lowsize,Varnode *&vnlo,Varnode *& vnhi);
|
void transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset);
|
||||||
bool fillinReadOnly(Varnode *vn); ///< Replace the given Varnode with its (constant) value in the load image
|
bool fillinReadOnly(Varnode *vn); ///< Replace the given Varnode with its (constant) value in the load image
|
||||||
bool replaceVolatile(Varnode *vn); ///< Replace accesses of the given Varnode with \e volatile operations
|
bool replaceVolatile(Varnode *vn); ///< Replace accesses of the given Varnode with \e volatile operations
|
||||||
void markIndirectOnly(void); ///< Mark \e illegal \e input Varnodes used only in INDIRECTs
|
void markIndirectOnly(void); ///< Mark \e illegal \e input Varnodes used only in INDIRECTs
|
||||||
|
|
|
@ -479,34 +479,22 @@ void Funcdata::setHighLevel(void)
|
||||||
assignHigh(*iter);
|
assignHigh(*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Create two new Varnodes which split the given Varnode
|
/// \brief Copy properties from an existing Varnode to a new Varnode
|
||||||
///
|
///
|
||||||
/// Attributes are copied from the original into the split pieces if appropriate
|
/// The new Varnode is assumed to overlap the storage of the existing Varnode.
|
||||||
/// \param vn is the given Varnode
|
/// Properties like boolean flags and \e consume bits are copied as appropriate.
|
||||||
/// \param lowsize is the desired size in bytes of the least significant portion
|
/// \param vn is the existing Varnode
|
||||||
/// \param vnlo will hold the least significant portion
|
/// \param newVn is the new Varnode that has its properties set
|
||||||
/// \param vnhi will hold the most significant portion
|
/// \param lsbOffset is the significance offset of the new Varnode within the exising
|
||||||
void Funcdata::splitVarnode(Varnode *vn,int4 lowsize,Varnode *& vnlo,Varnode *& vnhi)
|
void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset)
|
||||||
|
|
||||||
{
|
{
|
||||||
int4 highsize = vn->getSize() - lowsize;
|
uintb newConsume = (vn->getConsume() >> 8*lsbOffset) & calc_mask(newVn->getSize());
|
||||||
Address addrhi = vn->getAddr();
|
|
||||||
Address addrlo = addrhi;
|
|
||||||
uintb consumehi = vn->getConsume() >> 8*lowsize;
|
|
||||||
uintb consumelo = vn->getConsume() & calc_mask(lowsize);
|
|
||||||
if (vn->getSpace()->isBigEndian())
|
|
||||||
addrlo = addrhi + highsize;
|
|
||||||
else
|
|
||||||
addrhi = addrhi + lowsize;
|
|
||||||
|
|
||||||
uint4 vnflags = vn->getFlags() & (Varnode::directwrite|Varnode::addrforce|Varnode::auto_live);
|
uint4 vnFlags = vn->getFlags() & (Varnode::directwrite|Varnode::addrforce|Varnode::auto_live);
|
||||||
vnhi = newVarnode(highsize,addrhi);
|
|
||||||
vnlo = newVarnode(lowsize,addrlo);
|
|
||||||
|
|
||||||
vnhi->setFlags(vnflags); // Preserve addrforce setting
|
newVn->setFlags(vnFlags); // Preserve addrforce setting
|
||||||
vnlo->setFlags(vnflags);
|
newVn->setConsume(newConsume);
|
||||||
vnhi->setConsume(consumehi);
|
|
||||||
vnlo->setConsume(consumelo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Treat the given Varnode as read-only, look up its value in LoadImage
|
/// Treat the given Varnode as read-only, look up its value in LoadImage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue