Alexandre Julliard : winebuild: Use a global flag to determine when to generate the get_pc thunk.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 22 10:55:11 CDT 2016


Module: wine
Branch: master
Commit: ebb9c5e246f12b2147d085c4e8f343f23c231312
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ebb9c5e246f12b2147d085c4e8f343f23c231312

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Mar 22 17:59:30 2016 +0900

winebuild: Use a global flag to determine when to generate the get_pc thunk.

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

---

 tools/winebuild/build.h  |  2 +-
 tools/winebuild/import.c | 13 +++----------
 tools/winebuild/spec16.c |  3 +++
 tools/winebuild/spec32.c |  7 ++++++-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index f2f0e58..5cf984b 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -284,7 +284,6 @@ extern void read_undef_symbols( DLLSPEC *spec, char **argv );
 extern void resolve_imports( DLLSPEC *spec );
 extern int is_undefined( const char *name );
 extern int has_imports(void);
-extern int has_relays( DLLSPEC *spec );
 extern void output_get_pc_thunk(void);
 extern void output_module( DLLSPEC *spec );
 extern void output_stubs( DLLSPEC *spec );
@@ -363,5 +362,6 @@ extern struct strarray nm_command;
 extern char *cpu_option;
 extern char *arch_option;
 extern int thumb_mode;
+extern int needs_get_pc_thunk;
 
 #endif  /* __WINE_BUILD_H */
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index b549db8..69d4765 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -587,8 +587,7 @@ int is_undefined( const char *name )
 /* output the get_pc thunk if needed */
 void output_get_pc_thunk(void)
 {
-    if (target_cpu != CPU_x86) return;
-    if (!UsePIC) return;
+    assert( target_cpu == CPU_x86 );
     output( "\n\t.text\n" );
     output( "\t.align %d\n", get_alignment(4) );
     output( "\t%s\n", func_declaration("__wine_spec_get_pc_thunk_eax") );
@@ -619,6 +618,7 @@ static void output_import_thunk( const char *name, const char *table, int pos )
         {
             output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
             output( "1:\tjmp *%s+%d-1b(%%eax)\n", table, pos );
+            needs_get_pc_thunk = 1;
         }
         break;
     case CPU_x86_64:
@@ -1189,6 +1189,7 @@ void output_stubs( DLLSPEC *spec )
             {
                 output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
                 output( "1:" );
+                needs_get_pc_thunk = 1;
                 if (exp_name)
                 {
                     output( "\tleal .L%s_string-1b(%%eax),%%ecx\n", name );
@@ -1291,14 +1292,6 @@ void output_imports( DLLSPEC *spec )
     output_immediate_import_thunks();
     output_delayed_import_thunks( spec );
     output_external_link_imports( spec );
-    if (!list_empty( &dll_imports ) ||
-        !list_empty( &dll_delayed ) ||
-        ext_link_imports.count ||
-        has_stubs(spec) ||
-        has_relays(spec))
-    {
-        output_get_pc_thunk();
-    }
 }
 
 /* output an import library for a Win32 module and additional object files */
diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c
index e837571..85bcf09 100644
--- a/tools/winebuild/spec16.c
+++ b/tools/winebuild/spec16.c
@@ -356,6 +356,7 @@ static void output_call16_function( ORDDEF *odp )
         {
             output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
             output( "1:\tmovl wine_ldt_copy_ptr-1b(%%eax),%%esi\n" );
+            needs_get_pc_thunk = 1;
         }
         else
             output( "\tmovl $%s,%%esi\n", asm_name("wine_ldt_copy") );
@@ -814,6 +815,7 @@ void output_spec16_file( DLLSPEC *spec16 )
     resolve_imports( spec16 );
     add_16bit_exports( spec32, spec16 );
 
+    needs_get_pc_thunk = 0;
     output_standard_file_header();
     output_module( spec32 );
     output_module16( spec16 );
@@ -821,6 +823,7 @@ void output_spec16_file( DLLSPEC *spec16 )
     output_exports( spec32 );
     output_imports( spec16 );
     if (is_undefined( "__wine_call_from_16" )) output_asm_relays16();
+    if (needs_get_pc_thunk) output_get_pc_thunk();
     if (spec16->main_module)
     {
         output( "\n\t%s\n", get_asm_string_section() );
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index cb56abe..f3feb0f 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -46,6 +46,8 @@
 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC  0x107
 
+int needs_get_pc_thunk = 0;
+
 /* check if entry point needs a relay thunk */
 static inline int needs_relay( const ORDDEF *odp )
 {
@@ -78,7 +80,7 @@ static int is_float_arg( const ORDDEF *odp, int arg )
 }
 
 /* check if dll will output relay thunks */
-int has_relays( DLLSPEC *spec )
+static int has_relays( DLLSPEC *spec )
 {
     int i;
 
@@ -189,6 +191,7 @@ static void output_relay_debug( DLLSPEC *spec )
             {
                 output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
                 output( "1:\tleal .L__wine_spec_relay_descr-1b(%%eax),%%eax\n" );
+                needs_get_pc_thunk = 1;
             }
             else output( "\tmovl $.L__wine_spec_relay_descr,%%eax\n" );
             output( "\tpushl %%eax\n" );
@@ -616,6 +619,7 @@ void output_module( DLLSPEC *spec )
  */
 void BuildSpec32File( DLLSPEC *spec )
 {
+    needs_get_pc_thunk = 0;
     resolve_imports( spec );
     output_standard_file_header();
     output_module( spec );
@@ -623,6 +627,7 @@ void BuildSpec32File( DLLSPEC *spec )
     output_exports( spec );
     output_imports( spec );
     if (is_undefined( "__wine_call_from_regs" )) output_asm_relays();
+    if (needs_get_pc_thunk) output_get_pc_thunk();
     output_resources( spec );
     output_gnu_stack_note();
 }




More information about the wine-cvs mailing list