/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
__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);
&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
#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;
TerminateProcess (GetCurrentProcess (), STATUS_STACK_BUFFER_OVERRUN);
abort();
}
+