From 3128c033947626ee425493a570e06794882868b7 Mon Sep 17 00:00:00 2001 From: clc5q <clc5q@git.zephyr-software.com> Date: Mon, 20 Jul 2015 15:11:24 +0000 Subject: [PATCH] Get rid of UseIDAStackPointerDeltas() calls; continue to simplify loops in AdvancedAnalysis(). Former-commit-id: f45999f2c502458ed87c73e2fb0fc4360cde3229 --- src/base/SMPFunction.cpp | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index c778b489..38fb4a6c 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -74,7 +74,7 @@ using namespace std; #define SMP_DEBUG_SWITCH_TABLE_INFO 0 #define SMP_OPTIMIZE_BLOCK_PROFILING 0 #define SMP_AUDIT_STACK_POINTER_DELTAS 0 -#define SMP_COMPARE_IDA_STARS_STACK_POINTER_DELTAS 1 +#define SMP_COMPARE_IDA_STARS_STACK_POINTER_DELTAS 0 #define STARS_AGGRESSIVE_SIGNEDNESS_PROPAGATION 1 #define STARS_BUILD_LOOP_BITSET 1 // Build bitset in this->FuncLoopsByBlock #define STARS_DEBUG_MEMORY_CORRUPTION 0 @@ -1116,8 +1116,9 @@ STARS_sval_t SMPFunction::ComputeGlobalStackAdjustment(void) { bool SMPFunction::UseIDAStackPointerDeltas(void) { list<SMPInstr *>::iterator InstIter; SMPInstr *CurrInst; + bool IDATraceFlag = false; #if SMP_COMPARE_IDA_STARS_STACK_POINTER_DELTAS - bool IDATraceFlag = (0 == strcmp("do_length", this->GetFuncName())); + IDATraceFlag = (0 == strcmp("do_length", this->GetFuncName())); #endif InstIter = this->Instrs.begin(); @@ -1148,15 +1149,18 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { bool StackPointerRestoreSeen = false; // Stack pointer restored; must become true if ConflictingValuesSeen bool ReturnSeen = false; bool IDAProSucceeded = this->AnalyzedSP; + bool DebugFlag = false; + bool TraceFlag = false; + bool IDATraceFlag = false; #if SMP_COMPARE_IDA_STARS_STACK_POINTER_DELTAS - bool DebugFlag = (0 == strcmp("__libc_csu_fini", this->GetFuncName())); - bool TraceFlag = (0 == strcmp("__libc_csu_fini", this->GetFuncName())); + DebugFlag = (0 == strcmp("__libc_csu_fini", this->GetFuncName())); + TraceFlag = (0 == strcmp("__libc_csu_fini", this->GetFuncName())); #endif if (!this->HasGoodRTLs()) { SMP_msg("INFO: Using IDA Pro stack pointer deltas for BADRTLS function %s .\n", this->GetFuncName()); - (void) this->UseIDAStackPointerDeltas(); + // (void) this->UseIDAStackPointerDeltas(); this->AnalyzedSP = false; return false; // leave it unsolved } @@ -1616,7 +1620,8 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { } } if (!this->AnalyzedSP) { - (void) this->UseIDAStackPointerDeltas(); + ; + // (void) this->UseIDAStackPointerDeltas(); } else { // Success, so try to find saved/restored register pairs so that we do not @@ -4061,6 +4066,7 @@ void SMPFunction::AdvancedAnalysis(void) { } for ( ; InstIter != this->Instrs.end(); ++InstIter) { CurrInst = (*InstIter); + STARS_ea_t InstAddr = CurrInst->GetAddr(); // for debugging breakpoints // We can finally search for stack loads now that UseFP has been fixed by // MDFixUseFP(). Otherwise, we would do this in SMPInstr::Analyze(), // but the UseFP flag is not ready that early. @@ -4070,29 +4076,14 @@ void SMPFunction::AdvancedAnalysis(void) { // This used to be called from within SMPInstr.Analyze(), but info such as UseFP // is not available that early. CurrInst->MDFixupDefUseLists(); - } -#endif - InstIter = this->Instrs.begin(); - if ((*InstIter)->IsMarkerInst()) { - ++InstIter; // skip marker inst - } - for ( ; InstIter != this->Instrs.end(); ++InstIter) { - CurrInst = (*InstIter); - STARS_ea_t InstAddr = CurrInst->GetAddr(); // for debugging breakpoints + if (CurrInst->HasGoodRTL()) CurrInst->SyncAllRTs(this->UsesFramePointer(), this->GetFramePtrStackDelta()); // Detect indirect memory references. CurrInst->AnalyzeIndirectRefs(this->UseFP); - -#if 0 - // Is the instruction a branch to a target outside the function? If - // so, this function has shared tail chunks. - if (CurrInst->IsBranchToFarChunk() && (!CurrInst->IsTailCall())) { - this->SharedChunks = true; - } + } #endif - } // end for all instructions // Audit the call instructions and call targets. // !!!!****!!!! NOTE: Not sure the address range checks in this code are valid -- GitLab