Alexandre Julliard : winebuild: Store the syscall frame in the thread data on i386.

Alexandre Julliard julliard at winehq.org
Tue Jul 28 15:53:31 CDT 2020


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jul 28 13:00:50 2020 +0200

winebuild: Store the syscall frame in the thread data on i386.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/signal_i386.c | 14 +++++++++++++-
 tools/winebuild/import.c      | 15 +++++++++++----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c
index a258c5d8dc..519c1a76d9 100644
--- a/dlls/ntdll/unix/signal_i386.c
+++ b/dlls/ntdll/unix/signal_i386.c
@@ -473,6 +473,17 @@ enum i386_trap_code
 #endif
 };
 
+struct syscall_frame
+{
+    struct syscall_frame *prev_frame;
+    DWORD                 edi;
+    DWORD                 esi;
+    DWORD                 ebx;
+    DWORD                 ebp;
+    DWORD                 thunk_addr;
+    DWORD                 ret_addr;
+};
+
 struct x86_thread_data
 {
     DWORD              fs;            /* 1d4 TEB selector */
@@ -484,12 +495,13 @@ struct x86_thread_data
     DWORD              dr6;           /* 1ec */
     DWORD              dr7;           /* 1f0 */
     void              *exit_frame;    /* 1f4 exit frame pointer */
-    /* the ntdll_thread_data structure follows here */
+    struct syscall_frame *syscall_frame; /* 1f8 frame pointer on syscall entry */
 };
 
 C_ASSERT( sizeof(struct x86_thread_data) <= sizeof(((struct ntdll_thread_data *)0)->cpu_data) );
 C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, gs ) == 0x1d8 );
 C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, exit_frame ) == 0x1f4 );
+C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, syscall_frame ) == 0x1f8 );
 
 static inline struct x86_thread_data *x86_thread_data(void)
 {
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index 278de20522..cb0b80a6f7 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -1446,10 +1446,14 @@ void output_syscalls( DLLSPEC *spec )
             output_cfi( ".cfi_rel_offset %%ebp,0\n" );
             output( "\tmovl %%esp,%%ebp\n" );
             output_cfi( ".cfi_def_cfa_register %%ebp\n" );
+            output( "\tpushl %%ebx\n" );
+            output_cfi( ".cfi_rel_offset %%ebx,-4\n" );
             output( "\tpushl %%esi\n" );
-            output_cfi( ".cfi_rel_offset %%esi,-4\n" );
+            output_cfi( ".cfi_rel_offset %%esi,-8\n" );
             output( "\tpushl %%edi\n" );
-            output_cfi( ".cfi_rel_offset %%edi,-8\n" );
+            output_cfi( ".cfi_rel_offset %%edi,-12\n" );
+            output( "\tpushl %%fs:0x1f8\n" );  /* x86_thread_data()->syscall_frame */
+            output( "\tmovl %%esp,%%fs:0x1f8\n" );
             output( "\tcmpl $%u,%%eax\n", count );
             output( "\tjae 3f\n" );
             if (UsePIC)
@@ -1471,11 +1475,14 @@ void output_syscalls( DLLSPEC *spec )
                 output( "\tcall *.Lsyscall_table-1b(%%eax,%%edx,4)\n" );
             else
                 output( "\tcall *.Lsyscall_table(,%%eax,4)\n" );
-            output( "\tleal -8(%%ebp),%%esp\n" );
-            output( "2:\tpopl %%edi\n" );
+            output( "\tleal -16(%%ebp),%%esp\n" );
+            output( "2:\tpopl %%fs:0x1f8\n" );
+            output( "\tpopl %%edi\n" );
             output_cfi( ".cfi_same_value %%edi\n" );
             output( "\tpopl %%esi\n" );
             output_cfi( ".cfi_same_value %%esi\n" );
+            output( "\tpopl %%ebx\n" );
+            output_cfi( ".cfi_same_value %%ebx\n" );
             output( "\tpopl %%ebp\n" );
             output_cfi( ".cfi_def_cfa %%esp,4\n" );
             output_cfi( ".cfi_same_value %%ebp\n" );




More information about the wine-cvs mailing list