Paul Gofman : ntdll: Always align stack pointer in __wine_syscall_dispatcher on x64.
Alexandre Julliard
julliard at winehq.org
Tue Jul 14 16:23:38 CDT 2020
Module: wine
Branch: master
Commit: e9b3660e729929f4e09f403d526759d532df03e0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e9b3660e729929f4e09f403d526759d532df03e0
Author: Paul Gofman <pgofman at codeweavers.com>
Date: Tue Jul 14 19:06:36 2020 +0300
ntdll: Always align stack pointer in __wine_syscall_dispatcher on x64.
Syscall thunks break stack alignment for dispatcher. Regardless of that,
it is probably better not to assume aligned stack in syscall thunk entry.
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/winebuild/import.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index 97191ca89e..278de20522 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -1497,23 +1497,25 @@ void output_syscalls( DLLSPEC *spec )
* depends on us returning to it. Adjust the return address accordingly. */
output( "\tsubq $0xb,0x8(%%rbp)\n" );
output( "\tcmpq $%u,%%rax\n", count );
- output( "\tjae 3f\n" );
+ output( "\tjae 4f\n" );
output( "\tleaq .Lsyscall_args(%%rip),%%rcx\n" );
output( "\tmovzbl (%%rcx,%%rax),%%ecx\n" );
output( "\tsubq $0x20,%%rcx\n" );
- output( "\tjbe 1f\n" );
- output( "\tsubq %%rcx,%%rsp\n" );
+ output( "\tja 1f\n" );
+ output( "\tandq $~15,%%rsp\n\t" );
+ output( "\tjmp 2f\n" );
+ output( "1:\tsubq %%rcx,%%rsp\n" );
output( "\tshrq $3,%%rcx\n" );
output( "\tleaq 0x38(%%rbp),%%rsi\n" );
output( "\tandq $~15,%%rsp\n\t" );
output( "\tmovq %%rsp,%%rdi\n" );
output( "\tcld\n" );
output( "\trep; movsq\n" );
- output( "1:\tmovq %%r10,%%rcx\n" );
+ output( "2:\tmovq %%r10,%%rcx\n" );
output( "\tsubq $0x20,%%rsp\n" );
output( "\tleaq .Lsyscall_table(%%rip),%%r10\n" );
output( "\tcallq *(%%r10,%%rax,8)\n" );
- output( "2:\tleaq -0x10(%%rbp),%%rsp\n" );
+ output( "3:\tleaq -0x10(%%rbp),%%rsp\n" );
output( "\tpopq %%rdi\n" );
output_cfi( ".cfi_same_value %%rdi" );
output( "\tpopq %%rsi\n" );
@@ -1523,8 +1525,8 @@ void output_syscalls( DLLSPEC *spec )
output_cfi( ".cfi_adjust_cfa_offset -8" );
output_cfi( ".cfi_same_value %%rbp" );
output( "\tret\n" );
- output( "3:\tmovl $0x%x,%%eax\n", invalid_param );
- output( "\tjmp 2b\n" );
+ output( "4:\tmovl $0x%x,%%eax\n", invalid_param );
+ output( "\tjmp 3b\n" );
break;
case CPU_ARM:
output( "\tldr r1, 4f\n" );
More information about the wine-cvs
mailing list