Martin Storsjö : ntdll: Remove stack gap in syscalls on arm.

Alexandre Julliard julliard at winehq.org
Tue Nov 9 15:55:08 CST 2021


Module: wine
Branch: master
Commit: 77e90954357301cbb3242940556fa8b37677ae1a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=77e90954357301cbb3242940556fa8b37677ae1a

Author: Martin Storsjö <martin at martin.st>
Date:   Tue Nov  9 16:05:51 2021 +0200

ntdll: Remove stack gap in syscalls on arm.

Store the original stack pointer (on entry to the syscall dispatcher)
in syscall_frame; the stack pointer itself is incremented by
"pop {r0-r3}" right before calling the syscall itself.

This fixes unwinding from functions set up by syscalls, like
KiUserExceptionDispatcher.

Signed-off-by: Martin Storsjö <martin at martin.st>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/signal_arm.c | 4 +++-
 tools/winebuild/import.c     | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c
index 88718e938a8..1cc34a9218e 100644
--- a/dlls/ntdll/unix/signal_arm.c
+++ b/dlls/ntdll/unix/signal_arm.c
@@ -1041,7 +1041,8 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
                    "ldr r1, [r1, #0x1d8]\n\t"       /* arm_thread_data()->syscall_frame */
                    "add r0, r1, #0x10\n\t"
                    "stm r0, {r4-r12,lr}\n\t"
-                   "str sp, [r1, #0x38]\n\t"
+                   "add r2, sp, #0x10\n\t"
+                   "str r2, [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 */
@@ -1099,6 +1100,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
                    "ldm r8, {r4-r12,pc}\n"
                    "5:\tmovw r0, #0x000d\n\t" /* STATUS_INVALID_PARAMETER */
                    "movt r0, #0xc000\n\t"
+                   "add sp, sp, #0x10\n\t"
                    "b 4b\n"
                    __ASM_NAME("__wine_syscall_dispatcher_return") ":\n\t"
                    "mov r8, r0\n\t"
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index 104397716f1..7972fc7b1d9 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -1492,7 +1492,6 @@ void output_syscalls( DLLSPEC *spec )
             output( "\tmovw ip, #%u\n", id );
             output( "\tmov r3, lr\n" );
             output( "\tbl %s\n", asm_name("__wine_syscall") );
-            output( "\tadd sp, #16\n" );
             output( "\tbx lr\n" );
             break;
         case CPU_ARM64:




More information about the wine-cvs mailing list