[CPPRT][CRT][MSVCRT] Move __CxxFrameHandler3 to crt and export it on NT6

Previously it was in cpprt, which is a support library for C++, containing functions that are not exported by msvcrt. But since Vista __CxxFrameHandler3 is exported by msvcrt. Therefore move it to crt, and to satisfy pre-Vista configurations, also add it to msvcrtex.
This commit is contained in:
Timo Kreuzer 2020-09-24 07:49:16 +02:00
parent 310563aece
commit ce848e5c11
9 changed files with 58 additions and 22 deletions

View file

@ -241,7 +241,8 @@
@ cdecl -arch=i386 -norelay __CxxFrameHandler2(ptr ptr ptr ptr) __CxxFrameHandler
@ cdecl -version=0x600+ -arch=x86_64 -norelay __CxxFrameHandler2(ptr ptr ptr ptr) __CxxFrameHandler
@ cdecl -arch=arm -norelay __CxxFrameHandler3(ptr ptr ptr ptr)
#@ cdecl -version=0x600+ -arch=i386,x86_64 -norelay -private __CxxFrameHandler3(ptr ptr ptr ptr) # Commented out for now, as it causes linker errors
@ cdecl -version=0x600+ -arch=i386 -norelay __CxxFrameHandler3(ptr ptr ptr ptr)
@ cdecl -version=0x600+ -arch=x86_64 -norelay __CxxFrameHandler3(ptr ptr ptr ptr) __CxxFrameHandler
@ stdcall -arch=i386 __CxxLongjmpUnwind(ptr)
@ cdecl -arch=i386 __CxxQueryExceptionSize()
@ cdecl -arch=i386 __CxxRegisterExceptionObject()

View file

@ -11,7 +11,6 @@ list(APPEND SOURCE
if(ARCH STREQUAL "i386")
add_asm_files(cpprt_asm i386/cpprt.s)
list(APPEND SOURCE i386/framehandler.c)
elseif(ARCH STREQUAL "amd64")
add_asm_files(cpprt_asm amd64/cpprt.s)
elseif(ARCH STREQUAL "arm")

View file

@ -19,9 +19,6 @@ DEFINE_ALIAS ??_M@YAXPEAX_K1P6AX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@
; void __cdecl `eh vector destructor iterator'(void * __ptr64,unsigned __int64,int,void (__cdecl*)(void * __ptr64))
DEFINE_ALIAS ??_M@YAXPEAX_KHP6AX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YAXPEAX_KHP6AX0@Z@Z
; These are the same
DEFINE_ALIAS __CxxFrameHandler3, __CxxFrameHandler
; void __cdecl operator delete(void * __ptr64,struct std::nothrow_t const & __ptr64)
DEFINE_ALIAS ??3@YAXPEAXAEBUnothrow_t@std@@@Z, ??3@YAXPEAX@Z

View file

@ -7,23 +7,6 @@ EXTERN &orig : PROC
ALIAS <&alias> = <&orig>
ENDM
EXTERN _CxxHandleV8Frame@20 : PROC
PUBLIC ___CxxFrameHandler3
___CxxFrameHandler3:
push eax
push dword ptr [esp + 20]
push dword ptr [esp + 20]
push dword ptr [esp + 20]
push dword ptr [esp + 20]
call _CxxHandleV8Frame@20
ret
EXTERN ___CxxFrameHandler : PROC
PUBLIC _CallCxxFrameHandler
_CallCxxFrameHandler:
mov eax, dword ptr [esp + 20]
jmp ___CxxFrameHandler
; void __stdcall `eh vector constructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *),void (__thiscall*)(void *))
DEFINE_ALIAS ??_L@YGXPAXIHP6EX0@Z1@Z, ?MSVCRTEX_eh_vector_constructor_iterator@@YGXPAXIHP6EX0@Z1@Z

View file

@ -0,0 +1,15 @@
#include <asm.inc>
.code64
.align 4
MACRO(DEFINE_ALIAS, alias, orig)
EXTERN &orig : PROC
ALIAS <&alias> = <&orig>
ENDM
; These are the same
DEFINE_ALIAS __CxxFrameHandler3, __CxxFrameHandler
END

View file

@ -4,9 +4,13 @@ if(ARCH STREQUAL "i386")
except/i386/chkstk_asm.s
)
list(APPEND CRT_EXCEPT_ASM_SOURCE
except/i386/__CxxFrameHandler3.s
except/i386/chkesp.s
except/i386/prolog.s
)
list(APPEND CRT_EXCEPT_SOURCE
except/i386/CxxHandleV8Frame.c
)
if(MSVC)
list(APPEND CRT_EXCEPT_ASM_SOURCE
except/i386/cpp.s)

View file

@ -0,0 +1,26 @@
#include <asm.inc>
.code
.align 4
EXTERN _CxxHandleV8Frame@20 : PROC
PUBLIC ___CxxFrameHandler3
___CxxFrameHandler3:
push eax
push dword ptr [esp + 20]
push dword ptr [esp + 20]
push dword ptr [esp + 20]
push dword ptr [esp + 20]
call _CxxHandleV8Frame@20
ret
EXTERN ___CxxFrameHandler : PROC
PUBLIC _CallCxxFrameHandler
_CallCxxFrameHandler:
mov eax, dword ptr [esp + 20]
jmp ___CxxFrameHandler
END

View file

@ -36,9 +36,20 @@ if(ARCH STREQUAL "i386")
list(APPEND MSVCRTEX_SOURCE
math/i386/sqrtf.c)
endif()
if(MSVC AND DLL_EXPORT_VERSION LESS 0x600)
list(APPEND MSVCRTEX_ASM_SOURCE
except/i386/__CxxFrameHandler3.s)
list(APPEND MSVCRTEX_SOURCE
except/i386/CxxHandleV8Frame.c)
endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND MSVCRTEX_ASM_SOURCE
except/amd64/chkstk_ms.s)
if(MSVC AND DLL_EXPORT_VERSION LESS 0x600)
list(APPEND MSVCRTEX_ASM_SOURCE
except/amd64/__CxxFrameHandler3.s
)
endif()
elseif(ARCH STREQUAL "arm")
list(APPEND MSVCRTEX_SOURCE
math/arm/__rt_sdiv.c