[PATCH 3/4] ntdll: Add CFI expressions for __wine_syscall_dispatcher.
Rémi Bernon
rbernon at codeweavers.com
Mon Feb 7 13:05:43 CST 2022
Making sure stack pointer points to previous syscall / exit frame before
entering a syscall, and restoring the PE frame information on return.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52213
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/ntdll/unix/signal_i386.c | 9 +++++++++
dlls/ntdll/unix/signal_x86_64.c | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c
index d98a3b1d4bb..2f6e2fd4153 100644
--- a/dlls/ntdll/unix/signal_i386.c
+++ b/dlls/ntdll/unix/signal_i386.c
@@ -2492,6 +2492,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
"movl %esi,0x30(%ecx)\n\t"
"movl %ebp,0x34(%ecx)\n\t"
"leal 0x34(%ecx),%ebp\n\t"
+ __ASM_CFI(".cfi_def_cfa %ebp,0\n\t")
+ __ASM_CFI(".cfi_rel_offset %eip,-0x2c\n\t")
+ __ASM_CFI(".cfi_rel_offset %esp,-0x28\n\t")
"leal 4(%esp),%esi\n\t" /* first argument */
"movl %eax,%ebx\n\t"
"shrl $8,%ebx\n\t"
@@ -2530,6 +2533,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
"3:\tfnsave 0x40(%ecx)\n\t"
"fwait\n"
"4:\tmovl %ecx,%esp\n\t"
+ __ASM_CFI(".cfi_def_cfa %ebp,0\n\t")
+ __ASM_CFI(".cfi_rel_offset %eip,0x34c\n\t") /* frame->unwind_rip */
+ __ASM_CFI(".cfi_rel_offset %esp,0x08\n\t") /* frame->prev_frame */
"movl 0x1c(%esp),%edx\n\t" /* frame->eax */
"andl $0xfff,%edx\n\t" /* syscall number */
"cmpl 8(%ebx),%edx\n\t" /* table->ServiceLimit */
@@ -2545,6 +2551,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
"rep; movsl\n\t"
"call *(%eax,%edx,4)\n\t"
"leal -0x34(%ebp),%esp\n"
+ __ASM_CFI(".cfi_def_cfa %ebp,0\n\t")
+ __ASM_CFI(".cfi_rel_offset %eip,-0x2c\n\t")
+ __ASM_CFI(".cfi_rel_offset %esp,-0x28\n\t")
"5:\tmovl 0(%esp),%ecx\n\t" /* frame->syscall_flags + (frame->restore_flags << 16) */
"testl $0x68 << 16,%ecx\n\t" /* CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS | CONTEXT_XSAVE */
"jz 3f\n\t"
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c
index f8cddd15569..ee2723cdb24 100644
--- a/dlls/ntdll/unix/signal_x86_64.c
+++ b/dlls/ntdll/unix/signal_x86_64.c
@@ -3166,6 +3166,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
"movw %ss,0x90(%rcx)\n\t"
"movw %gs,0x92(%rcx)\n\t"
"movq %rbp,0x98(%rcx)\n\t"
+ __ASM_CFI(".cfi_def_cfa %rcx,0\n\t")
+ __ASM_CFI(".cfi_rel_offset %rip,0x70\n\t")
+ __ASM_CFI(".cfi_rel_offset %rsp,0x88\n\t")
/* Legends of Runeterra hooks the first system call return instruction, and
* depends on us returning to it. Adjust the return address accordingly. */
"subq $0xb,0x70(%rcx)\n\t"
@@ -3206,6 +3209,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
#endif
"leaq 0x28(%rsp),%rsi\n\t" /* first argument */
"movq %rcx,%rsp\n\t"
+ __ASM_CFI(".cfi_def_cfa %rbp,0\n\t")
+ __ASM_CFI(".cfi_rel_offset %rip,0x20\n\t") /* frame->unwind_rip */
+ __ASM_CFI(".cfi_rel_offset %rsp,0x08\n\t") /* frame->prev_frame */
"movq 0x00(%rcx),%rax\n\t"
"movq 0x18(%rcx),%rdx\n\t"
"movl %eax,%ebx\n\t"
@@ -3231,6 +3237,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
"movq (%rbx),%r10\n\t" /* table->ServiceTable */
"callq *(%r10,%rax,8)\n\t"
"leaq -0x98(%rbp),%rcx\n"
+ __ASM_CFI(".cfi_def_cfa %rcx,0\n\t")
+ __ASM_CFI(".cfi_rel_offset %rip,0x70\n\t")
+ __ASM_CFI(".cfi_rel_offset %rsp,0x88\n\t")
"2:\tmovl 0x94(%rcx),%edx\n\t" /* frame->restore_flags */
#ifdef __linux__
"testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */
--
2.34.1
More information about the wine-devel
mailing list