Merge remote-tracking branch 'origin/GT-3267_StoredConstantPtrs'

This commit is contained in:
Ryan Kurtz 2019-10-28 15:48:30 -04:00
commit 068cac3657
2 changed files with 11 additions and 5 deletions

View File

@ -824,10 +824,12 @@ int4 ActionShadowVar::apply(Funcdata &data)
/// \param spc is the address space being pointed to /// \param spc is the address space being pointed to
/// \param vn is the given Varnode /// \param vn is the given Varnode
/// \param op is the lone descendant of the Varnode /// \param op is the lone descendant of the Varnode
/// \param slot is the slot index of the Varnode
/// \param rampoint will hold the Address of the resolved symbol /// \param rampoint will hold the Address of the resolved symbol
/// \param data is the function being analyzed /// \param data is the function being analyzed
/// \return the recovered symbol or NULL /// \return the recovered symbol or NULL
SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op,Address &rampoint,uintb &fullEncoding,Funcdata &data) SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op,int4 slot,
Address &rampoint,uintb &fullEncoding,Funcdata &data)
{ {
bool needexacthit; bool needexacthit;
@ -849,7 +851,7 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
// A constant parameter or return value could be a pointer // A constant parameter or return value could be a pointer
if (!glb->infer_pointers) if (!glb->infer_pointers)
return (SymbolEntry *)0; return (SymbolEntry *)0;
if (op->getSlot(vn)==0) if (slot==0)
return (SymbolEntry *)0; return (SymbolEntry *)0;
break; break;
case CPUI_COPY: case CPUI_COPY:
@ -862,7 +864,6 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
case CPUI_INT_ADD: case CPUI_INT_ADD:
outvn = op->getOut(); outvn = op->getOut();
if (outvn->getType()->getMetatype()==TYPE_PTR) { if (outvn->getType()->getMetatype()==TYPE_PTR) {
int4 slot = op->getSlot(vn);
// Is there another pointer base in this expression // Is there another pointer base in this expression
if (op->getIn(1-slot)->getType()->getMetatype()==TYPE_PTR) if (op->getIn(1-slot)->getType()->getMetatype()==TYPE_PTR)
return (SymbolEntry *)0; // If so, we are not a pointer return (SymbolEntry *)0; // If so, we are not a pointer
@ -872,6 +873,10 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
else if (!glb->infer_pointers) else if (!glb->infer_pointers)
return (SymbolEntry *)0; return (SymbolEntry *)0;
break; break;
case CPUI_STORE:
if (slot != 2)
return (SymbolEntry *)0;
break;
default: default:
return (SymbolEntry *)0; return (SymbolEntry *)0;
} }
@ -944,7 +949,7 @@ int4 ActionConstantPtr::apply(Funcdata &data)
continue; continue;
Address rampoint; Address rampoint;
uintb fullEncoding; uintb fullEncoding;
entry = isPointer(rspc,vn,op,rampoint,fullEncoding,data); entry = isPointer(rspc,vn,op,slot,rampoint,fullEncoding,data);
vn->setPtrCheck(); // Set check flag AFTER searching for symbol vn->setPtrCheck(); // Set check flag AFTER searching for symbol
if (entry != (SymbolEntry *)0) { if (entry != (SymbolEntry *)0) {
data.spacebaseConstant(op,slot,entry,rampoint,fullEncoding,vn->getSize()); data.spacebaseConstant(op,slot,entry,rampoint,fullEncoding,vn->getSize());

View File

@ -162,7 +162,8 @@ public:
/// \brief Check for constants, with pointer type, that correspond to global symbols /// \brief Check for constants, with pointer type, that correspond to global symbols
class ActionConstantPtr : public Action { class ActionConstantPtr : public Action {
int4 localcount; ///< Number of passes made for this function int4 localcount; ///< Number of passes made for this function
static SymbolEntry *isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op,Address &rampoint,uintb &fullEncoding,Funcdata &data); static SymbolEntry *isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op,int4 slot,
Address &rampoint,uintb &fullEncoding,Funcdata &data);
public: public:
ActionConstantPtr(const string &g) : Action(0,"constantptr",g) {} ///< Constructor ActionConstantPtr(const string &g) : Action(0,"constantptr",g) {} ///< Constructor
virtual void reset(Funcdata &data) { localcount = 0; } virtual void reset(Funcdata &data) { localcount = 0; }