Author: akhaldi
Date: Tue Jul 20 19:20:37 2010
New Revision: 48143
URL:
http://svn.reactos.org/svn/reactos?rev=48143&view=rev
Log:
[MINGW-W64]
- Wrap MSVC intrinsics onto GCC builtins.
- Mark 'cookie' as an __UNUSED_PARAM.
- Tighten up _WIN64 conditioning.
Modified:
trunk/reactos/lib/3rdparty/mingw/gs_support.c
Modified: trunk/reactos/lib/3rdparty/mingw/gs_support.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/mingw/gs_supp…
==============================================================================
--- trunk/reactos/lib/3rdparty/mingw/gs_support.c [iso-8859-1] (original)
+++ trunk/reactos/lib/3rdparty/mingw/gs_support.c [iso-8859-1] Tue Jul 20 19:20:37 2010
@@ -88,19 +88,25 @@
__security_cookie_complement = ~cookie;
}
+
+#if defined(__GNUC__) /* wrap msvc intrinsics onto gcc builtins */
+#undef _ReturnAddress
+#undef _AddressOfReturnAddress
+#define _ReturnAddress() __builtin_return_address(0)
+#define _AddressOfReturnAddress() __builtin_frame_address (0)
+#endif /* __GNUC__ */
+
__declspec(noreturn) void __cdecl __report_gsfailure (ULONGLONG);
__declspec(noreturn) void __cdecl
__report_gsfailure (ULONGLONG StackCookie)
{
- volatile UINT_PTR cookie[2];
+ volatile UINT_PTR __UNUSED_PARAM(cookie[2]);
#ifdef _WIN64
ULONG64 controlPC, imgBase, establisherFrame;
PRUNTIME_FUNCTION fctEntry;
PVOID hndData;
-#endif
-#ifdef _WIN64
RtlCaptureContext (&GS_ContextRecord);
controlPC = GS_ContextRecord.Rip;
fctEntry = RtlLookupFunctionEntry (controlPC, &imgBase, NULL);
@@ -110,25 +116,15 @@
&GS_ContextRecord, &hndData, &establisherFrame, NULL);
}
else
-#endif
+#endif /* _WIN64 */
{
-#ifdef __GNUC__
-#ifdef _WIN64
- GS_ContextRecord.Rip = (ULONGLONG) __builtin_return_address (0);
- GS_ContextRecord.Rsp = (ULONGLONG) __builtin_frame_address (0) + 8;
-#else
- GS_ContextRecord.Eip = (DWORD) __builtin_return_address (0);
- GS_ContextRecord.Esp = (DWORD) __builtin_frame_address (0) + 4;
-#endif
-#else
#ifdef _WIN64
GS_ContextRecord.Rip = (ULONGLONG) _ReturnAddress();
- GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress();
+ GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress() + 8;
#else
GS_ContextRecord.Eip = (DWORD) _ReturnAddress();
- GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress();
-#endif
-#endif
+ GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress() + 4;
+#endif /* _WIN64 */
}
#ifdef _WIN64
@@ -137,7 +133,7 @@
#else
GS_ExceptionRecord.ExceptionAddress = (PVOID) GS_ContextRecord.Eip;
GS_ContextRecord.Ecx = StackCookie;
-#endif
+#endif /* _WIN64 */
GS_ExceptionRecord.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN;
GS_ExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
cookie[0] = __security_cookie;
@@ -147,3 +143,4 @@
TerminateProcess (GetCurrentProcess (), STATUS_STACK_BUFFER_OVERRUN);
abort();
}
+