@@ -1071,9 +1071,8 @@ bool ActionConstantPtr::checkCopy(PcodeOp *op,Funcdata &data)
10711071// / \param fullEncoding will hold the full pointer encoding being passed back
10721072// / \param data is the function being analyzed
10731073// / \return the recovered symbol or NULL
1074- SymbolEntry *ActionConstantPtr::isPointer (AddrSpace *spc,Varnode *vn,PcodeOp *op,int4 slot,
1075- Address &rampoint,uintb &fullEncoding,Funcdata &data)
1076-
1074+ MapEntry *ActionConstantPtr::isPointer (AddrSpace *spc,Varnode *vn,PcodeOp *op,int4 slot,
1075+ Address &rampoint,uintb &fullEncoding,Funcdata &data)
10771076{
10781077 bool needexacthit;
10791078 vn->setSymbolCheck (Varnode::symcheck_complete);
@@ -1084,7 +1083,7 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
10841083 needexacthit = false ;
10851084 }
10861085 else {
1087- if (vn->isTypeLock ()) return (SymbolEntry *)0 ; // Locked as NOT a pointer
1086+ if (vn->isTypeLock ()) return (MapEntry *)0 ; // Locked as NOT a pointer
10881087 needexacthit = true ;
10891088 // Check if the constant is involved in a potential pointer expression
10901089 // as the base
@@ -1093,22 +1092,22 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
10931092 case CPUI_CALLIND :
10941093 {
10951094 if (slot==0 )
1096- return (SymbolEntry *)0 ;
1095+ return (MapEntry *)0 ;
10971096 // A constant parameter could be a pointer
10981097 FuncCallSpecs *fc = data.getCallSpecs (op);
10991098 if (fc != (FuncCallSpecs *)0 && fc->isInputLocked () && fc->numParams () > slot-1 ) {
11001099 type_metatype meta = fc->getParam (slot-1 )->getType ()->getMetatype ();
11011100 if (meta != TYPE_PTR && meta != TYPE_UNKNOWN ) {
1102- return (SymbolEntry *)0 ; // Definitely not passing a pointer
1101+ return (MapEntry *)0 ; // Definitely not passing a pointer
11031102 }
11041103 }
11051104 else if (!glb->infer_pointers )
1106- return (SymbolEntry *)0 ;
1105+ return (MapEntry *)0 ;
11071106 break ;
11081107 }
11091108 case CPUI_COPY :
11101109 if (!checkCopy (op, data))
1111- return (SymbolEntry *)0 ;
1110+ return (MapEntry *)0 ;
11121111 break ;
11131112 case CPUI_PIECE :
11141113 // Pointers get concatenated in structures
@@ -1118,43 +1117,43 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
11181117 case CPUI_INT_LESSEQUAL :
11191118 // A comparison with a constant could be a pointer
11201119 if (!glb->infer_pointers )
1121- return (SymbolEntry *)0 ;
1120+ return (MapEntry *)0 ;
11221121 break ;
11231122 case CPUI_INT_ADD :
11241123 outvn = op->getOut ();
11251124 if (outvn->getTypeDefFacing ()->getMetatype ()==TYPE_PTR ) {
11261125 // Is there another pointer base in this expression
11271126 if (op->getIn (1 -slot)->getTypeReadFacing (op)->getMetatype ()==TYPE_PTR )
1128- return (SymbolEntry *)0 ; // If so, we are not a pointer
1127+ return (MapEntry *)0 ; // If so, we are not a pointer
11291128 // FIXME: need to fully explore additive tree
11301129 needexacthit = false ;
11311130 }
11321131 else if (!glb->infer_pointers )
1133- return (SymbolEntry *)0 ;
1132+ return (MapEntry *)0 ;
11341133 break ;
11351134 case CPUI_STORE :
11361135 if (slot != 2 )
1137- return (SymbolEntry *)0 ;
1136+ return (MapEntry *)0 ;
11381137 break ;
11391138 default :
1140- return (SymbolEntry *)0 ;
1139+ return (MapEntry *)0 ;
11411140 }
11421141 // Make sure the constant is in the expected range for a pointer
11431142 if (spc->getPointerLowerBound () > vn->getOffset ())
1144- return (SymbolEntry *)0 ;
1143+ return (MapEntry *)0 ;
11451144 if (spc->getPointerUpperBound () < vn->getOffset ())
1146- return (SymbolEntry *)0 ;
1145+ return (MapEntry *)0 ;
11471146 // Check if the constant looks like a single bit or mask
11481147 if (bit_transitions (vn->getOffset (),vn->getSize ()) < 3 )
1149- return (SymbolEntry *)0 ;
1148+ return (MapEntry *)0 ;
11501149 rampoint = glb->resolveConstant (spc,vn->getOffset (),vn->getSize (),op->getAddr (),fullEncoding);
11511150 }
11521151
1153- if (rampoint.isInvalid ()) return (SymbolEntry *)0 ;
1152+ if (rampoint.isInvalid ()) return (MapEntry *)0 ;
11541153 // Since we are looking for a global address
11551154 // Assume it is address tied and use empty usepoint
1156- SymbolEntry *entry = data.getScopeLocal ()->getParent ()->queryContainer (rampoint,1 ,Address ());
1157- if (entry != (SymbolEntry *)0 ) {
1155+ MapEntry *entry = data.getScopeLocal ()->getParent ()->queryContainer (rampoint,1 ,Address ());
1156+ if (entry != (MapEntry *)0 ) {
11581157 Datatype *ptrType = entry->getSymbol ()->getType ();
11591158 if (ptrType->getMetatype () == TYPE_ARRAY ) {
11601159 Datatype *ct = ((TypeArray *)ptrType)->getBase ();
@@ -1165,7 +1164,7 @@ SymbolEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op
11651164 }
11661165 if (needexacthit && entry->getAddr () != rampoint) {
11671166 vn->setSymbolCheck (Varnode::symcheck_incomplete); // May need to retest if we later discover vn is a pointer
1168- return (SymbolEntry *)0 ;
1167+ return (MapEntry *)0 ;
11691168 }
11701169 }
11711170 return entry;
@@ -1183,7 +1182,7 @@ int4 ActionConstantPtr::apply(Funcdata &data)
11831182 VarnodeLocSet::const_iterator begiter,enditer;
11841183 Architecture *glb = data.getArch ();
11851184 AddrSpace *cspc = glb->getConstantSpace ();
1186- SymbolEntry *entry;
1185+ MapEntry *entry;
11871186 Varnode *vn;
11881187
11891188 begiter = data.beginLoc (cspc);
@@ -1214,7 +1213,7 @@ int4 ActionConstantPtr::apply(Funcdata &data)
12141213 Address rampoint;
12151214 uintb fullEncoding;
12161215 entry = isPointer (rspc,vn,op,slot,rampoint,fullEncoding,data);
1217- if (entry != (SymbolEntry *)0 ) {
1216+ if (entry != (MapEntry *)0 ) {
12181217 data.spacebaseConstant (op,slot,entry,rampoint,fullEncoding,vn->getSize ());
12191218 if ((opc == CPUI_INT_ADD )&&(slot==1 ))
12201219 data.opSwapInput (op,0 ,1 );
@@ -5066,12 +5065,12 @@ int4 ActionDynamicMapping::apply(Funcdata &data)
50665065
50675066{
50685067 ScopeLocal *localmap = data.getScopeLocal ();
5069- list<SymbolEntry >::iterator iter,enditer;
5068+ list<DynamicEntry * >::iterator iter,enditer;
50705069 iter = localmap->beginDynamic ();
50715070 enditer = localmap->endDynamic ();
50725071 DynamicHash dhash;
50735072 while (iter != enditer) {
5074- SymbolEntry *entry = &( *iter) ;
5073+ DynamicEntry *entry = *iter;
50755074 ++iter;
50765075 if (data.attemptDynamicMapping (entry,dhash))
50775076 count += 1 ;
@@ -5083,12 +5082,12 @@ int4 ActionDynamicSymbols::apply(Funcdata &data)
50835082
50845083{
50855084 ScopeLocal *localmap = data.getScopeLocal ();
5086- list<SymbolEntry >::iterator iter,enditer;
5085+ list<DynamicEntry * >::iterator iter,enditer;
50875086 iter = localmap->beginDynamic ();
50885087 enditer = localmap->endDynamic ();
50895088 DynamicHash dhash;
50905089 while (iter != enditer) {
5091- SymbolEntry *entry = &( *iter) ;
5090+ DynamicEntry *entry = *iter;
50925091 ++iter;
50935092 if (data.attemptDynamicMappingLate (entry, dhash))
50945093 count += 1 ;
@@ -5233,7 +5232,9 @@ void ActionInferTypes::buildLocaltypes(Funcdata &data)
52335232 bool needsBlock = false ;
52345233 SymbolEntry *entry = vn->getSymbolEntry ();
52355234 if (entry != (SymbolEntry *)0 && !vn->isTypeLock () && entry->getSymbol ()->isTypeLocked ()) {
5236- int4 curOff = (vn->getAddr ().getOffset () - entry->getAddr ().getOffset ()) + entry->getOffset ();
5235+ int4 curOff = entry->getOffset ();
5236+ if (!entry->isDynamic ())
5237+ curOff += (vn->getAddr ().getOffset () - ((MapEntry *)entry)->getAddr ().getOffset ());
52375238 ct = typegrp->getExactPiece (entry->getSymbol ()->getType (), curOff, vn->getSize ());
52385239 if (ct == (Datatype *)0 || ct->getMetatype () == TYPE_UNKNOWN ) // If we can't resolve, or resolve to UNKNOWN
52395240 ct = vn->getLocalType (needsBlock); // Let data-type float, even though parent symbol is type-locked
0 commit comments