From 3e8e2866acf266e08f5dadb29ff8d9ac7c016ccd Mon Sep 17 00:00:00 2001 From: MiroKaku <50670906+MiroKaku@users.noreply.github.com> Date: Thu, 21 Jul 2022 12:33:54 +0800 Subject: [PATCH] fix: BufferOverflowFastFailK.lib conflict --- src/crt/i386/chandler4.cpp | 1 + src/crt/i386/trnsctrl.cpp | 1 + src/crt/vcruntime/gs_cookie.cpp | 5 ++--- src/crt/vcruntime/gs_support.cpp | 5 ++++- src/crt/vcruntime/x86_exception_filter.cpp | 4 ++-- src/ucrt/misc/errno.cpp | 8 ++++---- src/ucrt/misc/invalid_parameter.cpp | 18 +++++++++--------- src/ucrt/misc/terminate.cpp | 5 +---- src/ucrt/startup/abort.cpp | 2 +- 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/crt/i386/chandler4.cpp b/src/crt/i386/chandler4.cpp index 6a7ee3f..563c325 100644 --- a/src/crt/i386/chandler4.cpp +++ b/src/crt/i386/chandler4.cpp @@ -298,6 +298,7 @@ ValidateLocalCookies( #if defined(_M_IX86) && !defined(CRTDLL) && !defined(_M_HYBRID) // Filter incorrect x86 floating point exceptions, unless linkopt that provides an empty filter is available. #pragma comment(linker, "/alternatename:__filter_x86_sse2_floating_point_exception=__filter_x86_sse2_floating_point_exception_default") +#pragma comment(linker, "/alternatename:__filter_x86_sse2_floating_point_exception_default=__UCXXRT__filter_x86_sse2_floating_point_exception_default") #endif DECLSPEC_GUARD_SUPPRESS diff --git a/src/crt/i386/trnsctrl.cpp b/src/crt/i386/trnsctrl.cpp index 23b12d4..768c8b5 100644 --- a/src/crt/i386/trnsctrl.cpp +++ b/src/crt/i386/trnsctrl.cpp @@ -509,6 +509,7 @@ BEGIN_PRAGMA_OPTIMIZE_DISABLE("g", DOLPH:3322, "Uninvestigated issue from Visual #if defined(_M_IX86) && !defined(CRTDLL) && !defined(_M_HYBRID) // Filter incorrect x86 floating point exceptions, unless linkopt that provides an empty filter is available. #pragma comment(linker, "/alternatename:__filter_x86_sse2_floating_point_exception=__filter_x86_sse2_floating_point_exception_default") +#pragma comment(linker, "/alternatename:__filter_x86_sse2_floating_point_exception_default=__UCXXRT__filter_x86_sse2_floating_point_exception_default") #endif __declspec(guard(ignore)) BOOL _CallSETranslator( diff --git a/src/crt/vcruntime/gs_cookie.cpp b/src/crt/vcruntime/gs_cookie.cpp index bc4337b..c6c836c 100644 --- a/src/crt/vcruntime/gs_cookie.cpp +++ b/src/crt/vcruntime/gs_cookie.cpp @@ -39,8 +39,7 @@ _CRT_BEGIN_C_HEADER * initialize the cookie to the final value. */ -//UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE; -// -//UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE); +DECLSPEC_SELECTANY UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE; +DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE); _CRT_END_C_HEADER diff --git a/src/crt/vcruntime/gs_support.cpp b/src/crt/vcruntime/gs_support.cpp index d45cbec..12ee6cb 100644 --- a/src/crt/vcruntime/gs_support.cpp +++ b/src/crt/vcruntime/gs_support.cpp @@ -9,6 +9,7 @@ * *******************************************************************************/ +#include #if defined (_M_IX86) && defined (_CRTBLD) && defined (_DEBUG) /* @@ -158,7 +159,9 @@ static UINT_PTR __get_entropy(void) * *******************************************************************************/ -void __cdecl __security_init_cookie(void) +_VCRT_DECLARE_ALTERNATE_NAME(__security_init_cookie, _UCXXRT___security_init_cookie); + +void __cdecl _UCXXRT___security_init_cookie(void) { UINT_PTR cookie; diff --git a/src/crt/vcruntime/x86_exception_filter.cpp b/src/crt/vcruntime/x86_exception_filter.cpp index c25b5b0..19c0861 100644 --- a/src/crt/vcruntime/x86_exception_filter.cpp +++ b/src/crt/vcruntime/x86_exception_filter.cpp @@ -16,7 +16,7 @@ #if defined(_M_IX86) -extern "C" long __CRTDECL _filter_x86_sse2_floating_point_exception_default(long const exception_code) +extern "C" long __CRTDECL _UCXXRT__filter_x86_sse2_floating_point_exception_default(long const exception_code) { // If we're using SSE2 instructions on x86, the OS exception trap does not correctly // return accurate floating point exception codes. @@ -29,7 +29,7 @@ extern "C" long __CRTDECL _filter_x86_sse2_floating_point_exception_default(long if ( exception_code != STATUS_FLOAT_MULTIPLE_FAULTS && exception_code != STATUS_FLOAT_MULTIPLE_TRAPS) { return exception_code; - } + } // _mm_getcsr() (SSE2 fp status register 'mxcsr') format: // Excpt Mask Excpt Set diff --git a/src/ucrt/misc/errno.cpp b/src/ucrt/misc/errno.cpp index 2e041df..6998471 100644 --- a/src/ucrt/misc/errno.cpp +++ b/src/ucrt/misc/errno.cpp @@ -88,13 +88,13 @@ int __cdecl __acrt_errno_from_os_error(long const oserrno) } // These safely set and get the value of the calling thread's errno -errno_t __cdecl _set_errno_default(_In_ int const value) +errno_t __cdecl _UCXXRT__set_errno(_In_ int const value) { errno = value; return 0; } -errno_t __cdecl _get_errno_default(_Out_ int* const result) +errno_t __cdecl _UCXXRT__get_errno(_Out_ int* const result) { _VALIDATE_RETURN_NOERRNO(result != nullptr, EINVAL); @@ -103,8 +103,8 @@ errno_t __cdecl _get_errno_default(_Out_ int* const result) return 0; } -_VCRT_DECLARE_ALTERNATE_NAME(_set_errno, _set_errno_default); -_VCRT_DECLARE_ALTERNATE_NAME(_get_errno, _get_errno_default); +_VCRT_DECLARE_ALTERNATE_NAME(_set_errno, _UCXXRT__set_errno); +_VCRT_DECLARE_ALTERNATE_NAME(_get_errno, _UCXXRT__get_errno); // These safely set and get the value of the calling thread's doserrno errno_t __cdecl _set_doserrno(_In_ unsigned long const value) diff --git a/src/ucrt/misc/invalid_parameter.cpp b/src/ucrt/misc/invalid_parameter.cpp index 14b3a22..d363a96 100644 --- a/src/ucrt/misc/invalid_parameter.cpp +++ b/src/ucrt/misc/invalid_parameter.cpp @@ -9,12 +9,12 @@ #include -_VCRT_DECLARE_ALTERNATE_NAME(_invoke_watson, _invoke_watson_default); +_VCRT_DECLARE_ALTERNATE_NAME(_invoke_watson, _UCXXRT__invoke_watson); #ifdef _DEBUG -_VCRT_DECLARE_ALTERNATE_NAME(_invalid_parameter, _invalid_parameter_default); +_VCRT_DECLARE_ALTERNATE_NAME(_invalid_parameter, _UCXXRT__invalid_parameter); #endif -_VCRT_DECLARE_ALTERNATE_NAME(_invalid_parameter_noinfo, _invalid_parameter_noinfo_default); -_VCRT_DECLARE_ALTERNATE_NAME(_invalid_parameter_noinfo_noreturn, _invalid_parameter_noinfo_noreturn_default); +_VCRT_DECLARE_ALTERNATE_NAME(_invalid_parameter_noinfo, _UCXXRT__invalid_parameter_noinfo); +_VCRT_DECLARE_ALTERNATE_NAME(_invalid_parameter_noinfo_noreturn, _UCXXRT__invalid_parameter_noinfo_noreturn); static _invalid_parameter_handler __acrt_invalid_parameter_handler; @@ -32,7 +32,7 @@ extern "C" void __cdecl __acrt_initialize_invalid_parameter_handler(void* const // //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -extern "C" void __cdecl _invalid_parameter_internal( +extern "C" static void __cdecl _invalid_parameter_internal( wchar_t const* const expression, wchar_t const* const function_name, wchar_t const* const file_name, @@ -57,7 +57,7 @@ extern "C" void __cdecl _invalid_parameter_internal( _invoke_watson(expression, function_name, file_name, line_number, reserved); } -extern "C" void __cdecl _invalid_parameter_default( +extern "C" void __cdecl _UCXXRT__invalid_parameter( wchar_t const* const expression, wchar_t const* const function_name, wchar_t const* const file_name, @@ -68,7 +68,7 @@ extern "C" void __cdecl _invalid_parameter_default( return _invalid_parameter_internal(expression, function_name, file_name, line_number, reserved); } -extern "C" void __cdecl _invalid_parameter_noinfo_default() +extern "C" void __cdecl _UCXXRT__invalid_parameter_noinfo() { _invalid_parameter_internal(nullptr, nullptr, nullptr, 0, 0); } @@ -76,7 +76,7 @@ extern "C" void __cdecl _invalid_parameter_noinfo_default() // This is used by inline code in the C++ Standard Library and the SafeInt // library. Because it is __declspec(noreturn), the compiler can better // optimize use of the invalid parameter handler for inline code. -extern "C" __declspec(noreturn) void __cdecl _invalid_parameter_noinfo_noreturn_default() +extern "C" __declspec(noreturn) void __cdecl _UCXXRT__invalid_parameter_noinfo_noreturn() { _invalid_parameter_internal(nullptr, nullptr, nullptr, 0, 0); _invoke_watson(nullptr, nullptr, nullptr, 0, 0); @@ -89,7 +89,7 @@ extern "C" __declspec(noreturn) void __cdecl _invalid_parameter_noinfo_noreturn_ // //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -extern "C" __declspec(noreturn) void __cdecl _invoke_watson_default( +extern "C" __declspec(noreturn) void __cdecl _UCXXRT__invoke_watson( wchar_t const* const expression, wchar_t const* const function_name, wchar_t const* const file_name, diff --git a/src/ucrt/misc/terminate.cpp b/src/ucrt/misc/terminate.cpp index ea690a4..c24d5c7 100644 --- a/src/ucrt/misc/terminate.cpp +++ b/src/ucrt/misc/terminate.cpp @@ -12,10 +12,7 @@ // fix: abort not implemented after 19043 // alternatename: https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024 - -extern "C" void __cdecl _abort_default(); -_VCRT_DECLARE_ALTERNATE_NAME(abort, _abort_default); - +_VCRT_DECLARE_ALTERNATE_NAME(abort, _UCXXRT__abort); static terminate_handler __cdecl get_terminate_or_default( __acrt_ptd const* const ptd diff --git a/src/ucrt/startup/abort.cpp b/src/ucrt/startup/abort.cpp index 4c77ada..1b37488 100644 --- a/src/ucrt/startup/abort.cpp +++ b/src/ucrt/startup/abort.cpp @@ -42,7 +42,7 @@ extern "C" unsigned int __abort_behavior = _INIT_ABORT_BEHAVIOR; * *******************************************************************************/ -extern "C" void __cdecl _abort_default() +extern "C" void __cdecl _UCXXRT__abort() { #ifdef _DEBUG if (__abort_behavior & _WRITE_ABORT_MSG)