[x86/Linux] Get Frame Pointer from CallerSp (#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 #8980.

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

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
     {