winecrt0: Provide our own setjmp/longjmp functions for exception handling.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-06-18 10:17:43 +02:00
parent d401837994
commit 61680b4449
13 changed files with 236 additions and 216 deletions

View File

@ -1286,7 +1286,7 @@
@ cdecl _seterrormode(long)
@ cdecl -arch=i386,x86_64,arm,arm64 -norelay _setjmp(ptr) MSVCRT__setjmp
@ cdecl -arch=i386 -norelay _setjmp3(ptr long) MSVCRT__setjmp3
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) MSVCRT__setjmpex
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) __wine_setjmpex
@ cdecl _setmaxstdio(long) MSVCRT__setmaxstdio
@ cdecl _setmbcp(long)
@ cdecl _setmode(long long) MSVCRT__setmode

View File

@ -1643,7 +1643,7 @@
@ cdecl _seterrormode(long)
@ cdecl -arch=i386,x86_64,arm,arm64 -norelay _setjmp(ptr) MSVCRT__setjmp
@ cdecl -arch=i386 -norelay _setjmp3(ptr long) MSVCRT__setjmp3
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) MSVCRT__setjmpex
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) __wine_setjmpex
@ cdecl _setmaxstdio(long) MSVCRT__setmaxstdio
@ cdecl _setmbcp(long)
@ cdecl _setmode(long long) MSVCRT__setmode

View File

@ -1654,7 +1654,7 @@
@ cdecl _seterrormode(long)
@ cdecl -arch=i386,x86_64,arm,arm64 -norelay _setjmp(ptr) MSVCRT__setjmp
@ cdecl -arch=i386 -norelay _setjmp3(ptr long) MSVCRT__setjmp3
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) MSVCRT__setjmpex
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) __wine_setjmpex
@ cdecl _setmaxstdio(long) MSVCRT__setmaxstdio
@ cdecl _setmbcp(long)
@ cdecl _setmode(long long) MSVCRT__setmode

View File

@ -966,7 +966,7 @@
@ cdecl _seterrormode(long)
@ cdecl -arch=i386,x86_64,arm,arm64 -norelay _setjmp(ptr) MSVCRT__setjmp
@ cdecl -arch=i386 -norelay _setjmp3(ptr long) MSVCRT__setjmp3
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) MSVCRT__setjmpex
@ cdecl -arch=x86_64,arm -norelay _setjmpex(ptr ptr) __wine_setjmpex
@ cdecl _setmaxstdio(long) MSVCRT__setmaxstdio
@ cdecl _setmbcp(long)
@ cdecl _setmode(long long) MSVCRT__setmode

View File

@ -134,65 +134,7 @@ unsigned int CDECL __CxxQueryExceptionSize(void)
*/
__ASM_GLOBAL_FUNC(MSVCRT__setjmp,
"mov r1, #0\n\t" /* frame */
"b " __ASM_NAME("MSVCRT__setjmpex"));
/*******************************************************************
* _setjmpex (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC(MSVCRT__setjmpex,
"str r1, [r0]\n\t" /* jmp_buf->Frame */
"str r4, [r0, #0x4]\n\t" /* jmp_buf->R4 */
"str r5, [r0, #0x8]\n\t" /* jmp_buf->R5 */
"str r6, [r0, #0xc]\n\t" /* jmp_buf->R6 */
"str r7, [r0, #0x10]\n\t" /* jmp_buf->R7 */
"str r8, [r0, #0x14]\n\t" /* jmp_buf->R8 */
"str r9, [r0, #0x18]\n\t" /* jmp_buf->R9 */
"str r10, [r0, #0x1c]\n\t" /* jmp_buf->R10 */
"str r11, [r0, #0x20]\n\t" /* jmp_buf->R11 */
"str sp, [r0, #0x24]\n\t" /* jmp_buf->Sp */
"str lr, [r0, #0x28]\n\t" /* jmp_buf->Pc */
#ifndef __SOFTFP__
"vmrs r2, fpscr\n\t"
"str r2, [r0, #0x2c]\n\t" /* jmp_buf->Fpscr */
"vstr d8, [r0, #0x30]\n\t" /* jmp_buf->D[0] */
"vstr d9, [r0, #0x38]\n\t" /* jmp_buf->D[1] */
"vstr d10, [r0, #0x40]\n\t" /* jmp_buf->D[2] */
"vstr d11, [r0, #0x48]\n\t" /* jmp_buf->D[3] */
"vstr d12, [r0, #0x50]\n\t" /* jmp_buf->D[4] */
"vstr d13, [r0, #0x58]\n\t" /* jmp_buf->D[5] */
"vstr d14, [r0, #0x60]\n\t" /* jmp_buf->D[6] */
"vstr d15, [r0, #0x68]\n\t" /* jmp_buf->D[7] */
#endif
"mov r0, #0\n\t"
"bx lr");
extern void DECLSPEC_NORETURN CDECL longjmp_set_regs(struct MSVCRT___JUMP_BUFFER *jmp, int retval);
__ASM_GLOBAL_FUNC(longjmp_set_regs,
"ldr r4, [r0, #0x4]\n\t" /* jmp_buf->R4 */
"ldr r5, [r0, #0x8]\n\t" /* jmp_buf->R5 */
"ldr r6, [r0, #0xc]\n\t" /* jmp_buf->R6 */
"ldr r7, [r0, #0x10]\n\t" /* jmp_buf->R7 */
"ldr r8, [r0, #0x14]\n\t" /* jmp_buf->R8 */
"ldr r9, [r0, #0x18]\n\t" /* jmp_buf->R9 */
"ldr r10, [r0, #0x1c]\n\t" /* jmp_buf->R10 */
"ldr r11, [r0, #0x20]\n\t" /* jmp_buf->R11 */
"ldr sp, [r0, #0x24]\n\t" /* jmp_buf->Sp */
"ldr r2, [r0, #0x28]\n\t" /* jmp_buf->Pc */
#ifndef __SOFTFP__
"ldr r3, [r0, #0x2c]\n\t" /* jmp_buf->Fpscr */
"vmsr fpscr, r3\n\t"
"vldr d8, [r0, #0x30]\n\t" /* jmp_buf->D[0] */
"vldr d9, [r0, #0x38]\n\t" /* jmp_buf->D[1] */
"vldr d10, [r0, #0x40]\n\t" /* jmp_buf->D[2] */
"vldr d11, [r0, #0x48]\n\t" /* jmp_buf->D[3] */
"vldr d12, [r0, #0x50]\n\t" /* jmp_buf->D[4] */
"vldr d13, [r0, #0x58]\n\t" /* jmp_buf->D[5] */
"vldr d14, [r0, #0x60]\n\t" /* jmp_buf->D[6] */
"vldr d15, [r0, #0x68]\n\t" /* jmp_buf->D[7] */
#endif
"mov r0, r1\n\t" /* retval */
"bx r2");
"b " __ASM_NAME("__wine_setjmpex"));
/*******************************************************************
* longjmp (MSVCRT.@)
@ -212,7 +154,7 @@ void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
RtlUnwind((void *)jmp->Frame, (void *)jmp->Pc, &rec, IntToPtr(retval));
}
longjmp_set_regs(jmp, retval);
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
/*********************************************************************

View File

@ -135,53 +135,7 @@ unsigned int CDECL __CxxQueryExceptionSize(void)
*/
__ASM_GLOBAL_FUNC(MSVCRT__setjmp,
"mov x1, #0\n\t" /* frame */
"b " __ASM_NAME("MSVCRT__setjmpex"));
/*******************************************************************
* _setjmpex (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC(MSVCRT__setjmpex,
"str x1, [x0]\n\t" /* jmp_buf->Frame */
"stp x19, x20, [x0, #0x10]\n\t" /* jmp_buf->X19, X20 */
"stp x21, x22, [x0, #0x20]\n\t" /* jmp_buf->X21, X22 */
"stp x23, x24, [x0, #0x30]\n\t" /* jmp_buf->X23, X24 */
"stp x25, x26, [x0, #0x40]\n\t" /* jmp_buf->X25, X26 */
"stp x27, x28, [x0, #0x50]\n\t" /* jmp_buf->X27, X28 */
"stp x29, x30, [x0, #0x60]\n\t" /* jmp_buf->Fp, Lr */
"mov x2, sp\n\t"
"str x2, [x0, #0x70]\n\t" /* jmp_buf->Sp */
"mrs x2, fpcr\n\t"
"str w2, [x0, #0x78]\n\t" /* jmp_buf->Fpcr */
"mrs x2, fpsr\n\t"
"str w2, [x0, #0x7c]\n\t" /* jmp_buf->Fpsr */
"stp d8, d9, [x0, #0x80]\n\t" /* jmp_buf->D[0-1] */
"stp d10, d11, [x0, #0x90]\n\t" /* jmp_buf->D[2-3] */
"stp d12, d13, [x0, #0xa0]\n\t" /* jmp_buf->D[4-5] */
"stp d14, d15, [x0, #0xb0]\n\t" /* jmp_buf->D[6-7] */
"mov x0, #0\n\t"
"ret");
extern void DECLSPEC_NORETURN CDECL longjmp_set_regs(struct MSVCRT___JUMP_BUFFER *jmp, int retval);
__ASM_GLOBAL_FUNC(longjmp_set_regs,
"ldp x19, x20, [x0, #0x10]\n\t" /* jmp_buf->X19, X20 */
"ldp x21, x22, [x0, #0x20]\n\t" /* jmp_buf->X21, X22 */
"ldp x23, x24, [x0, #0x30]\n\t" /* jmp_buf->X23, X24 */
"ldp x25, x26, [x0, #0x40]\n\t" /* jmp_buf->X25, X26 */
"ldp x27, x28, [x0, #0x50]\n\t" /* jmp_buf->X27, X28 */
"ldp x29, x30, [x0, #0x60]\n\t" /* jmp_buf->Fp, Lr */
"ldr x2, [x0, #0x70]\n\t" /* jmp_buf->Sp */
"mov sp, x2\n\t"
"ldr w2, [x0, #0x78]\n\t" /* jmp_buf->Fpcr */
"msr fpcr, x2\n\t"
"ldr w2, [x0, #0x7c]\n\t" /* jmp_buf->Fpsr */
"msr fpsr, x2\n\t"
"ldp d8, d9, [x0, #0x80]\n\t" /* jmp_buf->D[0-1] */
"ldp d10, d11, [x0, #0x90]\n\t" /* jmp_buf->D[2-3] */
"ldp d12, d13, [x0, #0xa0]\n\t" /* jmp_buf->D[4-5] */
"ldp d14, d15, [x0, #0xb0]\n\t" /* jmp_buf->D[6-7] */
"mov x0, x1\n\t" /* retval */
"ret");
"b " __ASM_NAME("__wine_setjmpex"));
/*******************************************************************
* longjmp (MSVCRT.@)
@ -201,7 +155,7 @@ void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
RtlUnwind((void *)jmp->Frame, (void *)jmp->Lr, &rec, IntToPtr(retval));
}
longjmp_set_regs(jmp, retval);
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
/*********************************************************************

View File

@ -1023,25 +1023,6 @@ typedef void (__stdcall *MSVCRT_unwind_function)(const struct MSVCRT___JUMP_BUFF
"movl %eax,20(%ecx)\n\t" /* jmp_buf.Eip */ \
"jmp " __ASM_NAME("__regs_") # name )
/* restore the registers from the jmp buf upon longjmp */
extern void DECLSPEC_NORETURN longjmp_set_regs( struct MSVCRT___JUMP_BUFFER *jmp, int retval );
__ASM_GLOBAL_FUNC( longjmp_set_regs,
"movl 4(%esp),%ecx\n\t" /* jmp_buf */
"movl 8(%esp),%eax\n\t" /* retval */
"movl 0(%ecx),%ebp\n\t" /* jmp_buf.Ebp */
"movl 4(%ecx),%ebx\n\t" /* jmp_buf.Ebx */
"movl 8(%ecx),%edi\n\t" /* jmp_buf.Edi */
"movl 12(%ecx),%esi\n\t" /* jmp_buf.Esi */
"movl 16(%ecx),%esp\n\t" /* jmp_buf.Esp */
"addl $4,%esp\n\t" /* get rid of return address */
"jmp *20(%ecx)\n\t" /* jmp_buf.Eip */ )
/*
* The signatures of the setjmp/longjmp functions do not match that
* declared in the setjmp header so they don't follow the regular naming
* convention to avoid conflicts.
*/
/*******************************************************************
* _setjmp (MSVCRT.@)
*/
@ -1126,7 +1107,7 @@ void CDECL MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
if (!retval)
retval = 1;
longjmp_set_regs( jmp, retval );
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
/*********************************************************************

View File

@ -700,63 +700,7 @@ unsigned int CDECL __CxxQueryExceptionSize(void)
* _setjmp (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC( MSVCRT__setjmp,
"jmp " __ASM_NAME("MSVCRT__setjmpex") );
/*******************************************************************
* _setjmpex (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC( MSVCRT__setjmpex,
"movq %rdx,(%rcx)\n\t" /* jmp_buf->Frame */
"movq %rbx,0x8(%rcx)\n\t" /* jmp_buf->Rbx */
"leaq 0x8(%rsp),%rax\n\t"
"movq %rax,0x10(%rcx)\n\t" /* jmp_buf->Rsp */
"movq %rbp,0x18(%rcx)\n\t" /* jmp_buf->Rbp */
"movq %rsi,0x20(%rcx)\n\t" /* jmp_buf->Rsi */
"movq %rdi,0x28(%rcx)\n\t" /* jmp_buf->Rdi */
"movq %r12,0x30(%rcx)\n\t" /* jmp_buf->R12 */
"movq %r13,0x38(%rcx)\n\t" /* jmp_buf->R13 */
"movq %r14,0x40(%rcx)\n\t" /* jmp_buf->R14 */
"movq %r15,0x48(%rcx)\n\t" /* jmp_buf->R15 */
"movq (%rsp),%rax\n\t"
"movq %rax,0x50(%rcx)\n\t" /* jmp_buf->Rip */
"movdqa %xmm6,0x60(%rcx)\n\t" /* jmp_buf->Xmm6 */
"movdqa %xmm7,0x70(%rcx)\n\t" /* jmp_buf->Xmm7 */
"movdqa %xmm8,0x80(%rcx)\n\t" /* jmp_buf->Xmm8 */
"movdqa %xmm9,0x90(%rcx)\n\t" /* jmp_buf->Xmm9 */
"movdqa %xmm10,0xa0(%rcx)\n\t" /* jmp_buf->Xmm10 */
"movdqa %xmm11,0xb0(%rcx)\n\t" /* jmp_buf->Xmm11 */
"movdqa %xmm12,0xc0(%rcx)\n\t" /* jmp_buf->Xmm12 */
"movdqa %xmm13,0xd0(%rcx)\n\t" /* jmp_buf->Xmm13 */
"movdqa %xmm14,0xe0(%rcx)\n\t" /* jmp_buf->Xmm14 */
"movdqa %xmm15,0xf0(%rcx)\n\t" /* jmp_buf->Xmm15 */
"xorq %rax,%rax\n\t"
"retq" );
extern void DECLSPEC_NORETURN CDECL longjmp_set_regs( struct MSVCRT___JUMP_BUFFER *jmp, int retval );
__ASM_GLOBAL_FUNC( longjmp_set_regs,
"movq %rdx,%rax\n\t" /* retval */
"movq 0x8(%rcx),%rbx\n\t" /* jmp_buf->Rbx */
"movq 0x18(%rcx),%rbp\n\t" /* jmp_buf->Rbp */
"movq 0x20(%rcx),%rsi\n\t" /* jmp_buf->Rsi */
"movq 0x28(%rcx),%rdi\n\t" /* jmp_buf->Rdi */
"movq 0x30(%rcx),%r12\n\t" /* jmp_buf->R12 */
"movq 0x38(%rcx),%r13\n\t" /* jmp_buf->R13 */
"movq 0x40(%rcx),%r14\n\t" /* jmp_buf->R14 */
"movq 0x48(%rcx),%r15\n\t" /* jmp_buf->R15 */
"movdqa 0x60(%rcx),%xmm6\n\t" /* jmp_buf->Xmm6 */
"movdqa 0x70(%rcx),%xmm7\n\t" /* jmp_buf->Xmm7 */
"movdqa 0x80(%rcx),%xmm8\n\t" /* jmp_buf->Xmm8 */
"movdqa 0x90(%rcx),%xmm9\n\t" /* jmp_buf->Xmm9 */
"movdqa 0xa0(%rcx),%xmm10\n\t" /* jmp_buf->Xmm10 */
"movdqa 0xb0(%rcx),%xmm11\n\t" /* jmp_buf->Xmm11 */
"movdqa 0xc0(%rcx),%xmm12\n\t" /* jmp_buf->Xmm12 */
"movdqa 0xd0(%rcx),%xmm13\n\t" /* jmp_buf->Xmm13 */
"movdqa 0xe0(%rcx),%xmm14\n\t" /* jmp_buf->Xmm14 */
"movdqa 0xf0(%rcx),%xmm15\n\t" /* jmp_buf->Xmm15 */
"movq 0x50(%rcx),%rdx\n\t" /* jmp_buf->Rip */
"movq 0x10(%rcx),%rsp\n\t" /* jmp_buf->Rsp */
"jmp *%rdx" );
"jmp " __ASM_NAME("__wine_setjmpex") );
/*******************************************************************
* longjmp (MSVCRT.@)
@ -776,7 +720,7 @@ void __cdecl MSVCRT_longjmp( struct MSVCRT___JUMP_BUFFER *jmp, int retval )
rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
RtlUnwind( (void *)jmp->Frame, (void *)jmp->Rip, &rec, IntToPtr(retval) );
}
longjmp_set_regs( jmp, retval );
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
/*******************************************************************

View File

@ -902,7 +902,7 @@
@ cdecl _seterrormode(long)
@ cdecl -arch=i386,x86_64,arm,arm64 -norelay _setjmp(ptr) MSVCRT__setjmp
@ cdecl -arch=i386 -norelay _setjmp3(ptr long) MSVCRT__setjmp3
@ cdecl -arch=x86_64,arm,arm64 -norelay _setjmpex(ptr ptr) MSVCRT__setjmpex
@ cdecl -arch=x86_64,arm,arm64 -norelay _setjmpex(ptr ptr) __wine_setjmpex
@ cdecl _setmaxstdio(long) MSVCRT__setmaxstdio
@ cdecl _setmbcp(long)
@ cdecl _setmode(long long) MSVCRT__setmode

View File

@ -94,7 +94,7 @@
@ cdecl __initialize_lconv_for_unsigned_char() __lconv_init
@ stub __intrinsic_abnormal_termination
@ cdecl -arch=i386,x86_64,arm,arm64 -norelay __intrinsic_setjmp(ptr) MSVCRT__setjmp
@ cdecl -arch=x86_64,arm64 -norelay __intrinsic_setjmpex(ptr ptr) MSVCRT__setjmpex
@ cdecl -arch=x86_64,arm64 -norelay __intrinsic_setjmpex(ptr ptr) __wine_setjmpex
@ cdecl __isascii(long) MSVCRT___isascii
@ cdecl __iscsym(long) MSVCRT___iscsym
@ cdecl __iscsymf(long) MSVCRT___iscsymf

View File

@ -25,6 +25,29 @@
#if defined(__GNUC__) && defined(__i386__)
__ASM_GLOBAL_FUNC( __wine_setjmpex,
"movl 4(%esp),%ecx\n\t" /* jmp_buf */
"movl %ebp,0(%ecx)\n\t" /* jmp_buf.Ebp */
"movl %ebx,4(%ecx)\n\t" /* jmp_buf.Ebx */
"movl %edi,8(%ecx)\n\t" /* jmp_buf.Edi */
"movl %esi,12(%ecx)\n\t" /* jmp_buf.Esi */
"movl %esp,16(%ecx)\n\t" /* jmp_buf.Esp */
"movl 0(%esp),%eax\n\t"
"movl %eax,20(%ecx)\n\t" /* jmp_buf.Eip */
"xorl %eax,%eax\n\t"
"ret" )
__ASM_GLOBAL_FUNC( __wine_longjmp,
"movl 4(%esp),%ecx\n\t" /* jmp_buf */
"movl 8(%esp),%eax\n\t" /* retval */
"movl 0(%ecx),%ebp\n\t" /* jmp_buf.Ebp */
"movl 4(%ecx),%ebx\n\t" /* jmp_buf.Ebx */
"movl 8(%ecx),%edi\n\t" /* jmp_buf.Edi */
"movl 12(%ecx),%esi\n\t" /* jmp_buf.Esi */
"movl 16(%ecx),%esp\n\t" /* jmp_buf.Esp */
"addl $4,%esp\n\t" /* get rid of return address */
"jmp *20(%ecx)\n\t" /* jmp_buf.Eip */ )
__ASM_GLOBAL_FUNC( __wine_rtl_unwind,
"pushl %ebp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
@ -41,6 +64,57 @@ __ASM_GLOBAL_FUNC( __wine_rtl_unwind,
#elif defined(__GNUC__) && defined(__x86_64__)
__ASM_GLOBAL_FUNC( __wine_setjmpex,
"movq %rdx,(%rcx)\n\t" /* jmp_buf->Frame */
"movq %rbx,0x8(%rcx)\n\t" /* jmp_buf->Rbx */
"leaq 0x8(%rsp),%rax\n\t"
"movq %rax,0x10(%rcx)\n\t" /* jmp_buf->Rsp */
"movq %rbp,0x18(%rcx)\n\t" /* jmp_buf->Rbp */
"movq %rsi,0x20(%rcx)\n\t" /* jmp_buf->Rsi */
"movq %rdi,0x28(%rcx)\n\t" /* jmp_buf->Rdi */
"movq %r12,0x30(%rcx)\n\t" /* jmp_buf->R12 */
"movq %r13,0x38(%rcx)\n\t" /* jmp_buf->R13 */
"movq %r14,0x40(%rcx)\n\t" /* jmp_buf->R14 */
"movq %r15,0x48(%rcx)\n\t" /* jmp_buf->R15 */
"movq (%rsp),%rax\n\t"
"movq %rax,0x50(%rcx)\n\t" /* jmp_buf->Rip */
"movdqa %xmm6,0x60(%rcx)\n\t" /* jmp_buf->Xmm6 */
"movdqa %xmm7,0x70(%rcx)\n\t" /* jmp_buf->Xmm7 */
"movdqa %xmm8,0x80(%rcx)\n\t" /* jmp_buf->Xmm8 */
"movdqa %xmm9,0x90(%rcx)\n\t" /* jmp_buf->Xmm9 */
"movdqa %xmm10,0xa0(%rcx)\n\t" /* jmp_buf->Xmm10 */
"movdqa %xmm11,0xb0(%rcx)\n\t" /* jmp_buf->Xmm11 */
"movdqa %xmm12,0xc0(%rcx)\n\t" /* jmp_buf->Xmm12 */
"movdqa %xmm13,0xd0(%rcx)\n\t" /* jmp_buf->Xmm13 */
"movdqa %xmm14,0xe0(%rcx)\n\t" /* jmp_buf->Xmm14 */
"movdqa %xmm15,0xf0(%rcx)\n\t" /* jmp_buf->Xmm15 */
"xorq %rax,%rax\n\t"
"retq" )
__ASM_GLOBAL_FUNC( __wine_longjmp,
"movq %rdx,%rax\n\t" /* retval */
"movq 0x8(%rcx),%rbx\n\t" /* jmp_buf->Rbx */
"movq 0x18(%rcx),%rbp\n\t" /* jmp_buf->Rbp */
"movq 0x20(%rcx),%rsi\n\t" /* jmp_buf->Rsi */
"movq 0x28(%rcx),%rdi\n\t" /* jmp_buf->Rdi */
"movq 0x30(%rcx),%r12\n\t" /* jmp_buf->R12 */
"movq 0x38(%rcx),%r13\n\t" /* jmp_buf->R13 */
"movq 0x40(%rcx),%r14\n\t" /* jmp_buf->R14 */
"movq 0x48(%rcx),%r15\n\t" /* jmp_buf->R15 */
"movdqa 0x60(%rcx),%xmm6\n\t" /* jmp_buf->Xmm6 */
"movdqa 0x70(%rcx),%xmm7\n\t" /* jmp_buf->Xmm7 */
"movdqa 0x80(%rcx),%xmm8\n\t" /* jmp_buf->Xmm8 */
"movdqa 0x90(%rcx),%xmm9\n\t" /* jmp_buf->Xmm9 */
"movdqa 0xa0(%rcx),%xmm10\n\t" /* jmp_buf->Xmm10 */
"movdqa 0xb0(%rcx),%xmm11\n\t" /* jmp_buf->Xmm11 */
"movdqa 0xc0(%rcx),%xmm12\n\t" /* jmp_buf->Xmm12 */
"movdqa 0xd0(%rcx),%xmm13\n\t" /* jmp_buf->Xmm13 */
"movdqa 0xe0(%rcx),%xmm14\n\t" /* jmp_buf->Xmm14 */
"movdqa 0xf0(%rcx),%xmm15\n\t" /* jmp_buf->Xmm15 */
"movq 0x50(%rcx),%rdx\n\t" /* jmp_buf->Rip */
"movq 0x10(%rcx),%rsp\n\t" /* jmp_buf->Rsp */
"jmp *%rdx" )
__ASM_GLOBAL_FUNC( __wine_rtl_unwind,
"pushq %rbp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
@ -56,8 +130,130 @@ __ASM_GLOBAL_FUNC( __wine_rtl_unwind,
/* we need an extra call to make sure the stack is correctly aligned */
"callq *%rax" )
#elif defined(__GNUC__) && defined(__arm__)
__ASM_GLOBAL_FUNC( __wine_setjmpex,
"str r1, [r0]\n\t" /* jmp_buf->Frame */
"str r4, [r0, #0x4]\n\t" /* jmp_buf->R4 */
"str r5, [r0, #0x8]\n\t" /* jmp_buf->R5 */
"str r6, [r0, #0xc]\n\t" /* jmp_buf->R6 */
"str r7, [r0, #0x10]\n\t" /* jmp_buf->R7 */
"str r8, [r0, #0x14]\n\t" /* jmp_buf->R8 */
"str r9, [r0, #0x18]\n\t" /* jmp_buf->R9 */
"str r10, [r0, #0x1c]\n\t" /* jmp_buf->R10 */
"str r11, [r0, #0x20]\n\t" /* jmp_buf->R11 */
"str sp, [r0, #0x24]\n\t" /* jmp_buf->Sp */
"str lr, [r0, #0x28]\n\t" /* jmp_buf->Pc */
#ifndef __SOFTFP__
"vmrs r2, fpscr\n\t"
"str r2, [r0, #0x2c]\n\t" /* jmp_buf->Fpscr */
"vstr d8, [r0, #0x30]\n\t" /* jmp_buf->D[0] */
"vstr d9, [r0, #0x38]\n\t" /* jmp_buf->D[1] */
"vstr d10, [r0, #0x40]\n\t" /* jmp_buf->D[2] */
"vstr d11, [r0, #0x48]\n\t" /* jmp_buf->D[3] */
"vstr d12, [r0, #0x50]\n\t" /* jmp_buf->D[4] */
"vstr d13, [r0, #0x58]\n\t" /* jmp_buf->D[5] */
"vstr d14, [r0, #0x60]\n\t" /* jmp_buf->D[6] */
"vstr d15, [r0, #0x68]\n\t" /* jmp_buf->D[7] */
#endif
"mov r0, #0\n\t"
"bx lr" )
__ASM_GLOBAL_FUNC( __wine_longjmp,
"ldr r4, [r0, #0x4]\n\t" /* jmp_buf->R4 */
"ldr r5, [r0, #0x8]\n\t" /* jmp_buf->R5 */
"ldr r6, [r0, #0xc]\n\t" /* jmp_buf->R6 */
"ldr r7, [r0, #0x10]\n\t" /* jmp_buf->R7 */
"ldr r8, [r0, #0x14]\n\t" /* jmp_buf->R8 */
"ldr r9, [r0, #0x18]\n\t" /* jmp_buf->R9 */
"ldr r10, [r0, #0x1c]\n\t" /* jmp_buf->R10 */
"ldr r11, [r0, #0x20]\n\t" /* jmp_buf->R11 */
"ldr sp, [r0, #0x24]\n\t" /* jmp_buf->Sp */
"ldr r2, [r0, #0x28]\n\t" /* jmp_buf->Pc */
#ifndef __SOFTFP__
"ldr r3, [r0, #0x2c]\n\t" /* jmp_buf->Fpscr */
"vmsr fpscr, r3\n\t"
"vldr d8, [r0, #0x30]\n\t" /* jmp_buf->D[0] */
"vldr d9, [r0, #0x38]\n\t" /* jmp_buf->D[1] */
"vldr d10, [r0, #0x40]\n\t" /* jmp_buf->D[2] */
"vldr d11, [r0, #0x48]\n\t" /* jmp_buf->D[3] */
"vldr d12, [r0, #0x50]\n\t" /* jmp_buf->D[4] */
"vldr d13, [r0, #0x58]\n\t" /* jmp_buf->D[5] */
"vldr d14, [r0, #0x60]\n\t" /* jmp_buf->D[6] */
"vldr d15, [r0, #0x68]\n\t" /* jmp_buf->D[7] */
#endif
"mov r0, r1\n\t" /* retval */
"bx r2" )
void __cdecl __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record,
void (*target)(void) )
{
RtlUnwind( frame, target, record, 0 );
for (;;) target();
}
#elif defined(__GNUC__) && defined(__aarch64__)
__ASM_GLOBAL_FUNC( __wine_setjmpex,
"str x1, [x0]\n\t" /* jmp_buf->Frame */
"stp x19, x20, [x0, #0x10]\n\t" /* jmp_buf->X19, X20 */
"stp x21, x22, [x0, #0x20]\n\t" /* jmp_buf->X21, X22 */
"stp x23, x24, [x0, #0x30]\n\t" /* jmp_buf->X23, X24 */
"stp x25, x26, [x0, #0x40]\n\t" /* jmp_buf->X25, X26 */
"stp x27, x28, [x0, #0x50]\n\t" /* jmp_buf->X27, X28 */
"stp x29, x30, [x0, #0x60]\n\t" /* jmp_buf->Fp, Lr */
"mov x2, sp\n\t"
"str x2, [x0, #0x70]\n\t" /* jmp_buf->Sp */
"mrs x2, fpcr\n\t"
"str w2, [x0, #0x78]\n\t" /* jmp_buf->Fpcr */
"mrs x2, fpsr\n\t"
"str w2, [x0, #0x7c]\n\t" /* jmp_buf->Fpsr */
"stp d8, d9, [x0, #0x80]\n\t" /* jmp_buf->D[0-1] */
"stp d10, d11, [x0, #0x90]\n\t" /* jmp_buf->D[2-3] */
"stp d12, d13, [x0, #0xa0]\n\t" /* jmp_buf->D[4-5] */
"stp d14, d15, [x0, #0xb0]\n\t" /* jmp_buf->D[6-7] */
"mov x0, #0\n\t"
"ret" )
__ASM_GLOBAL_FUNC( __wine_longjmp,
"ldp x19, x20, [x0, #0x10]\n\t" /* jmp_buf->X19, X20 */
"ldp x21, x22, [x0, #0x20]\n\t" /* jmp_buf->X21, X22 */
"ldp x23, x24, [x0, #0x30]\n\t" /* jmp_buf->X23, X24 */
"ldp x25, x26, [x0, #0x40]\n\t" /* jmp_buf->X25, X26 */
"ldp x27, x28, [x0, #0x50]\n\t" /* jmp_buf->X27, X28 */
"ldp x29, x30, [x0, #0x60]\n\t" /* jmp_buf->Fp, Lr */
"ldr x2, [x0, #0x70]\n\t" /* jmp_buf->Sp */
"mov sp, x2\n\t"
"ldr w2, [x0, #0x78]\n\t" /* jmp_buf->Fpcr */
"msr fpcr, x2\n\t"
"ldr w2, [x0, #0x7c]\n\t" /* jmp_buf->Fpsr */
"msr fpsr, x2\n\t"
"ldp d8, d9, [x0, #0x80]\n\t" /* jmp_buf->D[0-1] */
"ldp d10, d11, [x0, #0x90]\n\t" /* jmp_buf->D[2-3] */
"ldp d12, d13, [x0, #0xa0]\n\t" /* jmp_buf->D[4-5] */
"ldp d14, d15, [x0, #0xb0]\n\t" /* jmp_buf->D[6-7] */
"mov x0, x1\n\t" /* retval */
"ret" )
void __cdecl __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record,
void (*target)(void) )
{
RtlUnwind( frame, target, record, 0 );
for (;;) target();
}
#else
int __cdecl __wine_setjmpex( __wine_jmp_buf *buf, EXCEPTION_REGISTRATION_RECORD *frame )
{
return setjmp( buf );
}
void __cdecl __wine_longjmp( __wine_jmp_buf *buf, int retval )
{
for (;;) longjmp( buf, retval );
}
void __cdecl __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record,
void (*target)(void) )
{
@ -71,7 +267,7 @@ static void DECLSPEC_NORETURN unwind_target(void)
{
__WINE_FRAME *wine_frame = (__WINE_FRAME *)__wine_get_frame();
__wine_pop_frame( &wine_frame->frame );
for (;;) wine_frame->longjmp( wine_frame->jmp, 1 );
for (;;) __wine_longjmp( &wine_frame->jmp, 1 );
}
static void DECLSPEC_NORETURN unwind_frame( EXCEPTION_RECORD *record,

View File

@ -92,17 +92,25 @@ extern "C" {
#else /* USE_COMPILER_EXCEPTIONS */
#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WINE_SETJMP_H)
#define sigjmp_buf jmp_buf
static inline void siglongjmp( sigjmp_buf buf, int val ) { longjmp( buf, val ); }
# ifdef _WIN64
int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) _setjmpex(jmp_buf,void*);
# define sigsetjmp(buf,sigs) _setjmpex(buf,CONTAINING_RECORD(buf,__WINE_FRAME,jmp))
# else
# define sigsetjmp(buf,sigs) setjmp(buf)
# endif
/* jmp_buf definition that should be compatible with the one in msvcrt/setjmp.h */
#if defined(__MINGW32__) || defined(__WINE_SETJMP_H)
typedef _JUMP_BUFFER __wine_jmp_buf;
#elif defined(__i386__)
typedef struct { int reg[16]; } __wine_jmp_buf;
#elif defined(__x86_64__)
typedef struct { DECLSPEC_ALIGN(16) struct { unsigned __int64 Part[2]; } reg[16]; } __wine_jmp_buf;
#elif defined(__arm__)
typedef struct { int reg[28]; } __wine_jmp_buf;
#elif defined(__aarch64__)
typedef struct { __int64 reg[24]; } __wine_jmp_buf;
#else
typedef struct { int reg; } __wine_jmp_buf;
#endif
extern int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) __wine_setjmpex( __wine_jmp_buf *buf,
EXCEPTION_REGISTRATION_RECORD *frame ) DECLSPEC_HIDDEN;
extern void __cdecl __wine_longjmp( __wine_jmp_buf *buf, int retval ) DECLSPEC_HIDDEN DECLSPEC_NORETURN;
extern void __cdecl __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record,
void (*target)(void) ) DECLSPEC_HIDDEN DECLSPEC_NORETURN;
extern DWORD __cdecl __wine_exception_handler( EXCEPTION_RECORD *record,
@ -144,8 +152,7 @@ extern DWORD __cdecl __wine_finally_ctx_handler( EXCEPTION_RECORD *record,
} else { \
__f.frame.Handler = __wine_exception_handler; \
__f.u.filter = (func); \
__f.longjmp = siglongjmp; \
if (sigsetjmp( __f.jmp, 0 )) { \
if (__wine_setjmpex( &__f.jmp, &__f.frame )) { \
const __WINE_FRAME * const __eptr __attribute__((unused)) = &__f; \
do {
@ -157,8 +164,7 @@ extern DWORD __cdecl __wine_finally_ctx_handler( EXCEPTION_RECORD *record,
__f.frame.Handler = __wine_exception_ctx_handler; \
__f.u.filter_ctx = (func); \
__f.ctx = context; \
__f.longjmp = siglongjmp; \
if (sigsetjmp( __f.jmp, 0 )) { \
if (__wine_setjmpex( &__f.jmp, &__f.frame )) { \
const __WINE_FRAME * const __eptr __attribute__((unused)) = &__f; \
do {
@ -169,20 +175,18 @@ extern DWORD __cdecl __wine_finally_ctx_handler( EXCEPTION_RECORD *record,
break; \
} else { \
__f.frame.Handler = __wine_exception_handler_page_fault; \
__f.longjmp = siglongjmp; \
if (sigsetjmp( __f.jmp, 0 )) { \
if (__wine_setjmpex( &__f.jmp, &__f.frame )) { \
const __WINE_FRAME * const __eptr __attribute__((unused)) = &__f; \
do {
/* convenience handler for all exception */
/* convenience handler for all exceptions */
#define __EXCEPT_ALL \
} while(0); \
__wine_pop_frame( &__f.frame ); \
break; \
} else { \
__f.frame.Handler = __wine_exception_handler_all; \
__f.longjmp = siglongjmp; \
if (sigsetjmp( __f.jmp, 0 )) { \
if (__wine_setjmpex( &__f.jmp, &__f.frame )) { \
const __WINE_FRAME * const __eptr __attribute__((unused)) = &__f; \
do {
@ -245,8 +249,7 @@ typedef struct __tagWINE_FRAME
__WINE_FINALLY_CTX finally_func_ctx;
} u;
void *ctx;
sigjmp_buf jmp;
void (*longjmp)(sigjmp_buf,int);
__wine_jmp_buf jmp;
/* hack to make GetExceptionCode() work in handler */
DWORD ExceptionCode;
const struct __tagWINE_FRAME *ExceptionRecord;

View File

@ -5041,7 +5041,7 @@ void write_exceptions( FILE *file )
fprintf( file, " EXCEPTION_REGISTRATION_RECORD frame; \\\n");
fprintf( file, " __filter_func filter; \\\n");
fprintf( file, " __finally_func finally; \\\n");
fprintf( file, " sigjmp_buf jmp; \\\n");
fprintf( file, " __wine_jmp_buf jmp; \\\n");
fprintf( file, " DWORD code; \\\n");
fprintf( file, " unsigned char abnormal_termination; \\\n");
fprintf( file, " unsigned char filter_level; \\\n");
@ -5061,7 +5061,7 @@ void write_exceptions( FILE *file )
fprintf( file, " __wine_pop_frame( &exc_frame->frame );\n");
fprintf( file, " }\n");
fprintf( file, " exc_frame->filter_level = 0;\n");
fprintf( file, " siglongjmp( exc_frame->jmp, 1 );\n");
fprintf( file, " __wine_longjmp( &exc_frame->jmp, 1 );\n");
fprintf( file, "}\n");
fprintf( file, "\n");
fprintf( file, "static DWORD __cdecl __widl_exception_handler( EXCEPTION_RECORD *record,\n");
@ -5087,7 +5087,7 @@ void write_exceptions( FILE *file )
fprintf( file, "}\n");
fprintf( file, "\n");
fprintf( file, "#define RpcTryExcept \\\n");
fprintf( file, " if (!sigsetjmp( __frame->jmp, 0 )) \\\n");
fprintf( file, " if (!__wine_setjmpex( &__frame->jmp, &__frame->frame )) \\\n");
fprintf( file, " { \\\n");
fprintf( file, " if (!__frame->finally_level) \\\n" );
fprintf( file, " __wine_push_frame( &__frame->frame ); \\\n");