Alexandre Julliard : winebuild: Store wine_ldt_copy pointer in the NE header at load time.

Alexandre Julliard julliard at winehq.org
Fri May 17 16:10:14 CDT 2019


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri May 17 16:46:00 2019 +0200

winebuild: Store wine_ldt_copy pointer in the NE header at load time.

Avoids having to import libwine from 16-bit modules.

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

---

 dlls/krnl386.exe16/ne_module.c | 1 +
 tools/winebuild/relay.c        | 8 +++-----
 tools/winebuild/spec16.c       | 9 +++------
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/dlls/krnl386.exe16/ne_module.c b/dlls/krnl386.exe16/ne_module.c
index 76ef355..357a0e9 100644
--- a/dlls/krnl386.exe16/ne_module.c
+++ b/dlls/krnl386.exe16/ne_module.c
@@ -921,6 +921,7 @@ static HMODULE16 NE_DoLoadBuiltinModule( const IMAGE_DOS_HEADER *mz_header, cons
     }
 
     patch_code_segment( pModule );
+    *(void **)mz_header->e_res2 = &wine_ldt_copy;
 
     return hInstance;
 }
diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c
index 8718346..3b1f4cd 100644
--- a/tools/winebuild/relay.c
+++ b/tools/winebuild/relay.c
@@ -156,12 +156,10 @@ static void BuildCallFrom16Core( int reg_func, int thunk )
     output( "\tandl $0xfff8, %%edx\n" );
     output( "\tshrl $1, %%edx\n" );
     if (UsePIC)
-    {
-        output( "\taddl wine_ldt_copy_ptr-1b(%%ecx),%%edx\n" );
-        output( "\tmovl (%%edx), %%edx\n" );
-    }
+        output( "\taddl .Lwine_ldt_copy_ptr-1b(%%ecx),%%edx\n" );
     else
-        output( "\tmovl %s(%%edx), %%edx\n", asm_name("wine_ldt_copy") );
+        output( "\taddl .Lwine_ldt_copy_ptr,%%edx\n" );
+    output( "\tmovl (%%edx), %%edx\n" );
     output( "\tmovzwl %%sp, %%ebp\n" );
     output( "\tleal %d(%%ebp,%%edx), %%edx\n", reg_func ? 0 : -4 );
 
diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c
index 027580b..9dce748 100644
--- a/tools/winebuild/spec16.c
+++ b/tools/winebuild/spec16.c
@@ -355,11 +355,11 @@ static void output_call16_function( ORDDEF *odp )
         if (UsePIC)
         {
             output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
-            output( "1:\tmovl wine_ldt_copy_ptr-1b(%%eax),%%esi\n" );
+            output( "1:\tmovl .Lwine_ldt_copy_ptr-1b(%%eax),%%esi\n" );
             needs_get_pc_thunk = 1;
         }
         else
-            output( "\tmovl $%s,%%esi\n", asm_name("wine_ldt_copy") );
+            output( "\tmovl .Lwine_ldt_copy_ptr,%%esi\n" );
     }
 
     /* preserve 16-byte stack alignment */
@@ -584,7 +584,7 @@ static void output_module16( DLLSPEC *spec )
     output( "\t.short 0,0,0,0\n" );                                        /* e_res */
     output( "\t.short 0\n" );                                              /* e_oemid */
     output( "\t.short 0\n" );                                              /* e_oeminfo */
-    output( "\t.short 0,0,0,0,0,0,0,0,0,0\n" );                            /* e_res2 */
+    output( ".Lwine_ldt_copy_ptr:\t.long 0,0,0,0,0\n" );                   /* e_res2, used for ldt_copy */
     output( "\t.long .L__wine_spec_ne_header-.L__wine_spec_dos_header\n" );/* e_lfanew */
 
     output( ".L__wine_spec_ne_header:\n" );
@@ -794,9 +794,6 @@ static void output_module16( DLLSPEC *spec )
         output( "\n/* relay functions */\n\n" );
         output( "\t.text\n" );
         for ( i = 0; i < nb_funcs; i++ ) output_call16_function( typelist[i] );
-        output( "\t.data\n" );
-        output( "wine_ldt_copy_ptr:\n" );
-        output( "\t.long %s\n", asm_name("wine_ldt_copy") );
     }
 
     free( typelist );




More information about the wine-cvs mailing list