mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 01:57:23 +00:00
ntdll: Use the system setjmp/longjmp for exceptions in Unix libs.
This commit is contained in:
parent
b87bd5e9b0
commit
658a0665d4
6 changed files with 11 additions and 179 deletions
|
@ -1220,7 +1220,7 @@ static BOOL handle_syscall_fault( ucontext_t *context, EXCEPTION_RECORD *rec )
|
|||
TRACE( "returning to handler\n" );
|
||||
REGn_sig(0, context) = (DWORD)ntdll_get_thread_data()->jmp_buf;
|
||||
REGn_sig(1, context) = 1;
|
||||
PC_sig(context) = (DWORD)__wine_longjmp;
|
||||
PC_sig(context) = (DWORD)longjmp;
|
||||
ntdll_get_thread_data()->jmp_buf = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -1722,40 +1722,4 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher,
|
|||
"ldm r8, {r4-r12,pc}\n\t"
|
||||
"1:\tb " __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_return") )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_setjmpex
|
||||
*/
|
||||
__ASM_GLOBAL_FUNC( __wine_setjmpex,
|
||||
__ASM_EHABI(".cantunwind\n\t")
|
||||
"stm r0, {r1,r4-r11}\n" /* jmp_buf->Frame,R4..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 */
|
||||
"add r0, r0, #0x30\n\t"
|
||||
"vstm r0, {d8-d15}\n\t" /* jmp_buf->D[0..7] */
|
||||
#endif
|
||||
"mov r0, #0\n\t"
|
||||
"bx lr" )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_longjmp
|
||||
*/
|
||||
__ASM_GLOBAL_FUNC( __wine_longjmp,
|
||||
__ASM_EHABI(".cantunwind\n\t")
|
||||
"ldm r0, {r3-r11}\n\t" /* jmp_buf->Frame,R4..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"
|
||||
"add r0, r0, #0x30\n\t"
|
||||
"vldm r0, {d8-d15}\n\t" /* jmp_buf->D[0..7] */
|
||||
#endif
|
||||
"mov r0, r1\n\t" /* retval */
|
||||
"bx r2" )
|
||||
|
||||
#endif /* __arm__ */
|
||||
|
|
|
@ -999,7 +999,7 @@ static BOOL handle_syscall_fault( ucontext_t *context, EXCEPTION_RECORD *rec )
|
|||
TRACE( "returning to handler\n" );
|
||||
REGn_sig(0, context) = (ULONG_PTR)ntdll_get_thread_data()->jmp_buf;
|
||||
REGn_sig(1, context) = 1;
|
||||
PC_sig(context) = (ULONG_PTR)__wine_longjmp;
|
||||
PC_sig(context) = (ULONG_PTR)longjmp;
|
||||
ntdll_get_thread_data()->jmp_buf = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -1643,53 +1643,4 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher,
|
|||
"mov sp, x16\n\t"
|
||||
"ret x17" )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_setjmpex
|
||||
*/
|
||||
__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" )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_longjmp
|
||||
*/
|
||||
__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" )
|
||||
|
||||
#endif /* __aarch64__ */
|
||||
|
|
|
@ -1834,13 +1834,13 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, void *stack_ptr,
|
|||
if (ntdll_get_thread_data()->jmp_buf)
|
||||
{
|
||||
TRACE( "returning to handler\n" );
|
||||
/* push stack frame for calling __wine_longjmp */
|
||||
/* push stack frame for calling longjmp */
|
||||
stack = stack_ptr;
|
||||
*(--stack) = 1;
|
||||
*(--stack) = (DWORD)ntdll_get_thread_data()->jmp_buf;
|
||||
*(--stack) = 0xdeadbabe; /* return address */
|
||||
ESP_sig(sigcontext) = (DWORD)stack;
|
||||
EIP_sig(sigcontext) = (DWORD)__wine_longjmp;
|
||||
EIP_sig(sigcontext) = (DWORD)longjmp;
|
||||
ntdll_get_thread_data()->jmp_buf = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -2809,35 +2809,4 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher,
|
|||
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
||||
"ret" )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_setjmpex
|
||||
*/
|
||||
__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" )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_longjmp
|
||||
*/
|
||||
__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 */ )
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
|
|
@ -1865,7 +1865,7 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, EXCEPTION_RECORD *rec,
|
|||
TRACE_(seh)( "returning to handler\n" );
|
||||
RDI_sig(sigcontext) = (ULONG_PTR)ntdll_get_thread_data()->jmp_buf;
|
||||
RSI_sig(sigcontext) = 1;
|
||||
RIP_sig(sigcontext) = (ULONG_PTR)__wine_longjmp;
|
||||
RIP_sig(sigcontext) = (ULONG_PTR)longjmp;
|
||||
ntdll_get_thread_data()->jmp_buf = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -2941,43 +2941,4 @@ asm( ".data\n\t"
|
|||
".quad " __ASM_LOCAL_LABEL("__wine_unix_call_dispatcher_prolog_end") "\n\t"
|
||||
".text\n\t" );
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_setjmpex
|
||||
*/
|
||||
__ASM_GLOBAL_FUNC( __wine_setjmpex,
|
||||
"movq %rsi,(%rdi)\n\t" /* jmp_buf->Frame */
|
||||
"movq %rbx,0x8(%rdi)\n\t" /* jmp_buf->Rbx */
|
||||
"leaq 0x8(%rsp),%rax\n\t"
|
||||
"movq %rax,0x10(%rdi)\n\t" /* jmp_buf->Rsp */
|
||||
"movq %rbp,0x18(%rdi)\n\t" /* jmp_buf->Rbp */
|
||||
"movq %r12,0x30(%rdi)\n\t" /* jmp_buf->R12 */
|
||||
"movq %r13,0x38(%rdi)\n\t" /* jmp_buf->R13 */
|
||||
"movq %r14,0x40(%rdi)\n\t" /* jmp_buf->R14 */
|
||||
"movq %r15,0x48(%rdi)\n\t" /* jmp_buf->R15 */
|
||||
"movq (%rsp),%rax\n\t"
|
||||
"movq %rax,0x50(%rdi)\n\t" /* jmp_buf->Rip */
|
||||
"stmxcsr 0x58(%rdi)\n\t" /* jmp_buf->MxCsr */
|
||||
"fnstcw 0x5c(%rdi)\n\t" /* jmp_buf->FpCsr */
|
||||
"xorq %rax,%rax\n\t"
|
||||
"retq" )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* __wine_longjmp
|
||||
*/
|
||||
__ASM_GLOBAL_FUNC( __wine_longjmp,
|
||||
"movq %rsi,%rax\n\t" /* retval */
|
||||
"movq 0x8(%rdi),%rbx\n\t" /* jmp_buf->Rbx */
|
||||
"movq 0x18(%rdi),%rbp\n\t" /* jmp_buf->Rbp */
|
||||
"movq 0x30(%rdi),%r12\n\t" /* jmp_buf->R12 */
|
||||
"movq 0x38(%rdi),%r13\n\t" /* jmp_buf->R13 */
|
||||
"movq 0x40(%rdi),%r14\n\t" /* jmp_buf->R14 */
|
||||
"movq 0x48(%rdi),%r15\n\t" /* jmp_buf->R15 */
|
||||
"ldmxcsr 0x58(%rdi)\n\t" /* jmp_buf->MxCsr */
|
||||
"fnclex\n\t"
|
||||
"fldcw 0x5c(%rdi)\n\t" /* jmp_buf->FpCsr */
|
||||
"movq 0x50(%rdi),%rdx\n\t" /* jmp_buf->Rip */
|
||||
"movq 0x10(%rdi),%rsp\n\t" /* jmp_buf->Rsp */
|
||||
"jmp *%rdx" )
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -1781,7 +1781,7 @@ NTSTATUS get_thread_context( HANDLE handle, void *context, BOOL *self, USHORT ma
|
|||
/***********************************************************************
|
||||
* ntdll_set_exception_jmp_buf
|
||||
*/
|
||||
void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp )
|
||||
void ntdll_set_exception_jmp_buf( jmp_buf jmp )
|
||||
{
|
||||
assert( !jmp || !ntdll_get_thread_data()->jmp_buf );
|
||||
ntdll_get_thread_data()->jmp_buf = jmp;
|
||||
|
|
|
@ -42,25 +42,12 @@ NTSYSAPI int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n );
|
|||
|
||||
/* exception handling */
|
||||
|
||||
#ifdef __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
|
||||
#include <setjmp.h>
|
||||
|
||||
NTSYSAPI int __attribute__ ((__nothrow__,__returns_twice__)) __wine_setjmpex( __wine_jmp_buf *buf,
|
||||
EXCEPTION_REGISTRATION_RECORD *frame );
|
||||
NTSYSAPI void DECLSPEC_NORETURN __wine_longjmp( __wine_jmp_buf *buf, int retval );
|
||||
NTSYSAPI void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp );
|
||||
NTSYSAPI void ntdll_set_exception_jmp_buf( jmp_buf jmp );
|
||||
|
||||
#define __TRY \
|
||||
do { __wine_jmp_buf __jmp; \
|
||||
do { jmp_buf __jmp; \
|
||||
int __first = 1; \
|
||||
for (;;) if (!__first) \
|
||||
{ \
|
||||
|
@ -71,14 +58,14 @@ NTSYSAPI void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp );
|
|||
ntdll_set_exception_jmp_buf( NULL ); \
|
||||
break; \
|
||||
} else { \
|
||||
if (__wine_setjmpex( &__jmp, NULL )) { \
|
||||
if (setjmp( __jmp )) { \
|
||||
do {
|
||||
|
||||
#define __ENDTRY \
|
||||
} while (0); \
|
||||
break; \
|
||||
} \
|
||||
ntdll_set_exception_jmp_buf( &__jmp ); \
|
||||
ntdll_set_exception_jmp_buf( __jmp ); \
|
||||
__first = 0; \
|
||||
} \
|
||||
} while (0);
|
||||
|
|
Loading…
Reference in a new issue