diff --git a/SMPFunction.cpp b/SMPFunction.cpp index 8fcca2f7acce3f0e20cd1c339f3b1aea04205739..164d4e0ccdc0c699d0d1401a05acd87927caa4b9 100644 --- a/SMPFunction.cpp +++ b/SMPFunction.cpp @@ -2852,6 +2852,7 @@ void SMPFunction::FindOutgoingArgsSize(void) { bool OutgoingArgsRegionFinished = false; bool IndexedOutgoingArgs = false; // Any indexed accesses to outgoing args? size_t FramePadSize = 0; + size_t AlignmentPadSize = 0; // bottom of frame, unused space below outargs for (size_t MapIndex = 0; MapIndex < this->StackFrameMap.size(); ++MapIndex) { // Some of the bottom of the stack frame might be below the local frame allocation. // These are pushes that happened after allocation, etc. We skip over these @@ -2875,6 +2876,14 @@ void SMPFunction::FindOutgoingArgsSize(void) { break; // No more padding region } } + else if ((this->OutgoingArgsSize == 0) && (!TempEntry.Read) && (!TempEntry.Written)) { + // We have not started accumulating outgoing args bytes, we have reached the + // AllocPointDelta, yet we find space that is neither written nor read. This + // empty space at the bottom of the stack frame could just be for stack alignment + // purposes, especially in the new x86-64 ABI, so it should not prevent us from + // finding outgoing args space above it. + ++AlignmentPadSize; + } else if (TempEntry.Read || TempEntry.EBPRelativeAccess || !TempEntry.Written || !TempEntry.ESPRelativeAccess) { OutgoingArgsRegionFinished = true; @@ -2903,6 +2912,11 @@ void SMPFunction::FindOutgoingArgsSize(void) { this->OutgoingArgsSize += FramePadSize; } + // Add in the alignment padding below the written outargs region. + if (this->OutgoingArgsSize > 0) { + this->OutgoingArgsSize += AlignmentPadSize; + } + #if 0 // Sometimes we encounter unused stack space above the outgoing args. Lump this space // in with the outgoing args. We detect this by noting when the outgoing args space