@@ -193,11 +193,12 @@ public Symbol setGPSymbol(Program program, Address toAddr) {
193193 try {
194194 String symname = "_gp_" + index ++;
195195 // check if it already exists
196- Symbol existingSymbol = SymbolUtilities .getLabelOrFunctionSymbol (program , symname ,
197- err -> { /* ignore multiple symbols, if even one exists we need to skip if it has a different address */ } );
196+ Symbol existingSymbol =
197+ SymbolUtilities .getLabelOrFunctionSymbol (program , symname , err -> {
198+ /* ignore multiple symbols, if even one exists we need to skip if it has a different address */ });
198199 if (existingSymbol != null ) {
199200 if (existingSymbol .getAddress ().equals (toAddr )) {
200- return existingSymbol ;
201+ return existingSymbol ;
201202 }
202203 continue ; // can't use this one, look for the next free gp_<x> symbol
203204 }
@@ -223,14 +224,16 @@ public AddressSetView flowConstants(final Program program, Address flowStart,
223224
224225 final AddressSet coveredSet = new AddressSet ();
225226
227+ Address currentGPAssumptionValue = gp_assumption_value ;
228+
226229 if (func != null ) {
227230 flowStart = func .getEntryPoint ();
228- if (gp_assumption_value != null ) {
231+ if (currentGPAssumptionValue != null ) {
229232 ProgramContext programContext = program .getProgramContext ();
230233 RegisterValue gpVal = programContext .getRegisterValue (gp , flowStart );
231234 if (gpVal == null || !gpVal .hasValue ()) {
232- gpVal =
233- new RegisterValue ( gp , BigInteger .valueOf (gp_assumption_value .getOffset ()));
235+ gpVal = new RegisterValue ( gp ,
236+ BigInteger .valueOf (currentGPAssumptionValue .getOffset ()));
234237 try {
235238 program .getProgramContext ().setRegisterValue (func .getEntryPoint (),
236239 func .getEntryPoint (), gpVal );
@@ -245,6 +248,7 @@ public AddressSetView flowConstants(final Program program, Address flowStart,
245248 // follow all flows building up context
246249 // use context to fill out addresses on certain instructions
247250 ContextEvaluator eval = new ConstantPropagationContextEvaluator (trustWriteMemOption ) {
251+ private Address localGPAssumptionValue = currentGPAssumptionValue ;
248252
249253 private boolean mustStopNow = false ; // if something discovered in processing, mustStop flag
250254
@@ -297,8 +301,8 @@ public boolean evaluateContext(VarnodeContext context, Instruction instr) {
297301 if (registerValue != null ) {
298302 BigInteger value = registerValue .getUnsignedValue ();
299303 long unsignedValue = value .longValue ();
300- if (gp_assumption_value == null ||
301- !(unsignedValue == gp_assumption_value .getOffset ())) {
304+ if (localGPAssumptionValue == null ||
305+ !(unsignedValue == localGPAssumptionValue .getOffset ())) {
302306 synchronized (gp ) {
303307 Address gpRefAddr =
304308 instr .getMinAddress ().getNewAddress (unsignedValue );
@@ -317,18 +321,18 @@ public boolean evaluateContext(VarnodeContext context, Instruction instr) {
317321 instr .getMinAddress ().getAddressSpace ().getBaseSpaceID (),
318322 unsignedValue , 1 , RefType .DATA , PcodeOp .UNIMPLEMENTED , true ,
319323 monitor );
320- if (gp_assumption_value == null ) {
324+ if (localGPAssumptionValue == null ) {
321325 program .getBookmarkManager ().setBookmark (
322326 lastSetInstr .getMinAddress (), BookmarkType .WARNING ,
323327 "GP Global Register Set" ,
324328 "Global GP Register is set here." );
325329 }
326- if (gp_assumption_value != null &&
327- !gp_assumption_value .equals (gpRefAddr )) {
328- gp_assumption_value = null ;
330+ if (localGPAssumptionValue != null &&
331+ !localGPAssumptionValue .equals (gpRefAddr )) {
332+ localGPAssumptionValue = gp_assumption_value = null ;
329333 }
330334 else {
331- gp_assumption_value = gpRefAddr ;
335+ localGPAssumptionValue = gp_assumption_value = gpRefAddr ;
332336 }
333337 }
334338 }
@@ -400,10 +404,11 @@ public boolean evaluateReference(VarnodeContext context, Instruction instr, int
400404 // if it is assumed to be set to the same value, it can lead
401405 // to incorrect re-use of the value (non-returning functions)
402406 context .clearRegister (reg );
403-
407+
404408 // need to add the reference here, register operand will no longer have a value
405- instr .addOperandReference (0 , addr , refType , SourceType .ANALYSIS );
406-
409+ instr .addOperandReference (0 , addr , refType ,
410+ SourceType .ANALYSIS );
411+
407412 // set the register value on the target address
408413 ProgramContext progContext = program .getProgramContext ();
409414 if (progContext .getValue (reg , addr , false ) == null ) {
0 commit comments