ntdll: Save rdi and rsi in raise_func_trampoline. (resend)

Sebastian Lackner sebastian at fds-team.de
Tue Mar 7 12:11:11 CST 2017


From: Andrew Wesie <awesie at gmail.com>

Signed-off-by: Andrew Wesie <awesie at gmail.com>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

The tests were left out for now, but the change looks correct.
RDI/RSI are changed in setup_exception, so they should be saved/
restored.

 dlls/ntdll/signal_x86_64.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index f33fe4cbfd6..61bb2ddce6f 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2066,9 +2066,11 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from )
 extern void raise_func_trampoline( EXCEPTION_RECORD *rec, CONTEXT *context, raise_func func );
 __ASM_GLOBAL_FUNC( raise_func_trampoline,
                    __ASM_CFI(".cfi_signal_frame\n\t")
-                   __ASM_CFI(".cfi_def_cfa %rbp,144\n\t")  /* red zone + rip + rbp */
-                   __ASM_CFI(".cfi_rel_offset %rip,8\n\t")
-                   __ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
+                   __ASM_CFI(".cfi_def_cfa %rbp,160\n\t")  /* red zone + rip + rbp + rdi + rsi */
+                   __ASM_CFI(".cfi_rel_offset %rip,24\n\t")
+                   __ASM_CFI(".cfi_rel_offset %rbp,16\n\t")
+                   __ASM_CFI(".cfi_rel_offset %rdi,8\n\t")
+                   __ASM_CFI(".cfi_rel_offset %rsi,0\n\t")
                    "call *%rdx\n\t"
                    "int $3")
 
@@ -2085,6 +2087,8 @@ static EXCEPTION_RECORD *setup_exception( ucontext_t *sigcontext, raise_func fun
     {
         CONTEXT           context;
         EXCEPTION_RECORD  rec;
+        ULONG64           rsi;
+        ULONG64           rdi;
         ULONG64           rbp;
         ULONG64           rip;
         ULONG64           red_zone[16];
@@ -2154,6 +2158,8 @@ static EXCEPTION_RECORD *setup_exception( ucontext_t *sigcontext, raise_func fun
     rsp_ptr = (ULONG64 *)RSP_sig(sigcontext) - 16;
     *(--rsp_ptr) = RIP_sig(sigcontext);
     *(--rsp_ptr) = RBP_sig(sigcontext);
+    *(--rsp_ptr) = RDI_sig(sigcontext);
+    *(--rsp_ptr) = RSI_sig(sigcontext);
 
     /* now modify the sigcontext to return to the raise function */
     RIP_sig(sigcontext) = (ULONG_PTR)raise_func_trampoline;
-- 
2.11.0



More information about the wine-patches mailing list