[x86/Linux] Get Frame Pointer from CallerSp (dotnet/coreclr#9235)
authorJonghyun Park <parjong@gmail.com>
Wed, 1 Feb 2017 01:46:32 +0000 (10:46 +0900)
committerJan Vorlicek <janvorli@microsoft.com>
Wed, 1 Feb 2017 01:46:32 +0000 (02:46 +0100)
GetGSCookieAddress uses pEbp to get the current frame pointer, but pEbp
is not properly initialized as discussed in dotnet/coreclr#8980.

This commit revises GetGSCookieAddress to use CallerSp (as in other
architectures) to get Frame Pointer in order to fix dotnet/coreclr#8980.

Commit migrated from https://github.com/dotnet/coreclr/commit/6be2bed47d823b49603969c37a382f994da0b0ff

src/coreclr/src/vm/eetwain.cpp

index f7257f5..11a4590 100644 (file)
@@ -5465,7 +5465,15 @@ void * EECodeManager::GetGSCookieAddr(PREGDISPLAY     pContext,
     
     if  (info->ebpFrame)
     {
-        return PVOID(SIZE_T((DWORD(*pContext->pEbp) - info->gsCookieOffset)));
+        DWORD curEBP;
+
+#ifdef WIN64EXCEPTIONS
+        curEBP = GetCallerSp(pContext) - 2 * 4;
+#else
+        curEBP = *pContext->pEbp;
+#endif
+
+        return PVOID(SIZE_T(curEBP - info->gsCookieOffset));
     }
     else
     {