From b41566fb31b257d04f6044b01d996f71d2859493 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 7 Feb 2024 11:52:30 +0100 Subject: [PATCH] ntdll: Fix stack layout for ARM syscalls. --- dlls/ntdll/unix/signal_arm.c | 9 +++++---- include/wine/asm.h | 23 ++++------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c index 9ca0569bd62..0f6f81d2ee1 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c @@ -1052,7 +1052,10 @@ NTSTATUS call_user_apc_dispatcher( CONTEXT *context, ULONG_PTR arg1, ULONG_PTR a */ void call_raise_user_exception_dispatcher(void) { - arm_thread_data()->syscall_frame->pc = (DWORD)pKiRaiseUserExceptionDispatcher; + struct syscall_frame *frame = arm_thread_data()->syscall_frame; + + frame->sp += 16; + frame->pc = (DWORD)pKiRaiseUserExceptionDispatcher; } @@ -1608,8 +1611,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "ldr r1, [r2, #0x1d8]\n\t" /* arm_thread_data()->syscall_frame */ "add r0, r1, #0x10\n\t" "stm r0, {r4-r12,lr}\n\t" - "add r0, sp, #0x10\n\t" - "str r0, [r1, #0x38]\n\t" + "str sp, [r1, #0x38]\n\t" "str r3, [r1, #0x3c]\n\t" "mrs r0, CPSR\n\t" "bfi r0, lr, #5, #1\n\t" /* set thumb bit */ @@ -1682,7 +1684,6 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "5:\tmovw r0, #0x000d\n\t" /* STATUS_INVALID_PARAMETER */ "movt r0, #0xc000\n\t" - "add sp, sp, #0x10\n\t" "b " __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_return") "\n\t" ".globl " __ASM_NAME("__wine_syscall_dispatcher_return") "\n" __ASM_NAME("__wine_syscall_dispatcher_return") ":\n\t" diff --git a/include/wine/asm.h b/include/wine/asm.h index 0fa2dfcd1b7..908c7d7d19a 100644 --- a/include/wine/asm.h +++ b/include/wine/asm.h @@ -268,34 +268,19 @@ # define __ASM_SYSCALL_FUNC(id,name,args) \ __ASM_GLOBAL_FUNC( name, \ "push {r0-r3}\n\t" \ + ".seh_save_regs {r0-r3}\n\t" \ + ".seh_endprologue\n\t" \ "movw ip, #(" #id ")\n\t" \ "mov r3, lr\n\t" \ "bl " __ASM_NAME("__wine_syscall") "\n\t" \ + "add sp, #16\n\t" \ "bx lr" ) -# ifndef __PIC__ -# define DEFINE_SYSCALL_HELPER32() \ +# define DEFINE_SYSCALL_HELPER32() \ __ASM_GLOBAL_FUNC( __wine_syscall, \ "movw r0, :lower16:" __ASM_NAME("__wine_syscall_dispatcher") "\n\t" \ "movt r0, :upper16:" __ASM_NAME("__wine_syscall_dispatcher") "\n\t" \ "ldr r0, [r0]\n\t" \ "bx r0" ) -# elif defined __thumb__ -# define DEFINE_SYSCALL_HELPER32() \ - __ASM_GLOBAL_FUNC( __wine_syscall, \ - "ldr r0, 2f\n" \ - "1:\tadd r0, pc\n\t" \ - "ldr r0, [r0]\n\t" \ - "bx r0\n" \ - "2:\t.long " __ASM_NAME("__wine_syscall_dispatcher") "-1b-4" ) -# else -# define DEFINE_SYSCALL_HELPER32() \ - __ASM_GLOBAL_FUNC( __wine_syscall, \ - "ldr r0, 2f\n" \ - "1:\tadd r0, pc\n\t" \ - "ldr r0, [r0]\n\t" \ - "bx r0\n" \ - "2:\t.long " __ASM_NAME("__wine_syscall_dispatcher") "-1b-8" ) -# endif #endif #endif /* __WINE_WINE_ASM_H */