diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 9ce571f3355f8cfbf7f88d153c92e6e30c48cc53..250077eaf34ab6436c73ed6a6deaa9ebdc468f23 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -1809,24 +1809,8 @@ void SMPFunction::FindAllAllocsAndDeallocs(void) { #if SMP_DEBUG_CONTROLFLOW SMP_msg("Returned from MDIsFrameAllocInstr()\n"); #endif - this->LocalVarsAllocInstr = addr; FoundAllocInstr = true; if (DebugFlag) SMP_msg("Found alloc: %s\n", CurrInst->GetDisasm()); - // As soon as we have found the local vars allocation, - // we can try to fix incorrect sets of UseFP by IDA. - // NOTE: We might want to extend this in the future to - // handle functions that have no locals. **!!** -#if 0 - bool FixedUseFP = MDFixUseFP(); -#if SMP_DEBUG_FRAMEFIXUP - if (FixedUseFP) { - SMP_msg("Fixed UseFP in %s\n", this->GetFuncName()); - } -#endif -#endif - if (this->UsesFramePointer()) { // now that MDFixUseFP() has validated this flag ... - this->FindFramePointerDelta(); // find stack delta that is saved in frame pointer in function prologue - } } else if (FoundAllocInstr) { // We can now start searching for the DeallocInstr. @@ -1920,9 +1904,6 @@ void SMPFunction::FindAllAllocsAndDeallocs(void) { } #endif #endif - if (this->UsesFramePointer()) { // now that MDFixUseFP() has validated this flag ... - this->FindFramePointerDelta(); // find stack delta that is saved in frame pointer in function prologue - } } // end if (LocalVarsSize > 0) ... else ... if (!FoundAllocInstr && (0 < this->LocalVarsSize) && this->IsLeaf()) { @@ -1938,7 +1919,6 @@ void SMPFunction::FindAllAllocsAndDeallocs(void) { #endif #endif if (this->UsesFramePointer()) { // now that MDFixUseFP() has validated this flag ... - this->FindFramePointerDelta(); // find stack delta that is saved in frame pointer in function prologue if (0 != this->FramePointerStackDelta) { SMP_msg("INFO: Found FramePointerStackDelta of %ld in frameless leaf function %s\n", (long) this->FramePointerStackDelta, this->GetFuncName()); @@ -2145,7 +2125,7 @@ bool SMPFunction::MDFixFrameInfo(void) { } } } - else if (CurrInstr->MDIsFrameAllocInstr()) { + else if (CurrInstr->MDIsFrameAllocInstr() && (!CurrInstr->HasAllocaRTL())) { if (DebugFlag) SMP_msg("libc_csu_init allocinstr: %s\n", CurrInstr->GetDisasm()); // Get the size being allocated. set<DefOrUse, LessDefUse>::iterator CurrUse; @@ -2165,7 +2145,8 @@ bool SMPFunction::MDFixFrameInfo(void) { } // end for all uses } // end if (push) .. elsif frame allocating instr else if (CurrInstr->HasStackPointerDEF() && (DEFAULT == CurrInstr->GetDataFlowType())) { - // Handle all other possible changes to stack pointer register from non-control-flow instructions + // Handle all other possible changes to stack pointer register from non-control-flow instructions. + // This includes the alloca() inlined call pattern (sub esp,reg) which is assigned a default size. if (CurrInstr->MDIsLeaveInstr() && (STARS_BADADDR != this->LocalVarsAllocInstr)) { SMP_msg("ERROR: MDFixFrameInfo() found LEAVE opcode at %llx before finding a frame allocation.\n", (unsigned long long) CurrInstr->GetAddr()); diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index bfdd07da06b6feeb8f02de4571023f5185c460ac..86ddab8b3fdfbf7887a0200a2093be9810d1f293 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -2856,8 +2856,6 @@ int SMPInstr::operator<=(const SMPInstr &rhs) const { // Is this instruction one that allocates space on the // stack for the local variables? bool SMPInstr::MDIsFrameAllocInstr(void) { - if (this->IsAllocaCall()) - return true; // The frame allocating instruction should look like: // sub esp,48 or add esp,-64 etc. @@ -2880,7 +2878,6 @@ bool SMPInstr::MDIsFrameAllocInstr(void) { // a positive immediate value. We will throw in, free of // charge, a subtraction of a register, which is how alloca() // usually allocates stack space. - // PHASE ORDERING: Should we use the Operands[] instead of the USE list? **!!** set<DefOrUse, LessDefUse>::iterator CurrUse; for (CurrUse = this->GetFirstUse(); CurrUse != this->GetLastUse(); ++CurrUse) { if (CurrUse->GetOp()->IsImmedOp()) {