Module: wine Branch: master Commit: bf5893f4899b0539fbae39879c46b6b7da33c6f5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=bf5893f4899b0539fbae39879...
Author: Kevin Puetz PuetzKevinA@JohnDeere.com Date: Wed Nov 25 13:00:27 2020 -0600
winebuild: Find main/wmain in static libraries.
Have the winebuild -spec.o include an undefined .globl referencing symbols we know the winecrt0 entry point will eventually reference, so ld knows about that need while scanning library archives.
Signed-off-by: Kevin Puetz PuetzKevinA@JohnDeere.com Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
tools/winebuild/build.h | 1 + tools/winebuild/main.c | 11 +++++++++++ tools/winebuild/spec32.c | 12 ++++++++++++ 3 files changed, 24 insertions(+)
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 26a0539c500..a4b9bc97e3e 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -300,6 +300,7 @@ extern void output_gnu_stack_note(void); extern void add_import_dll( const char *name, const char *filename ); extern void add_delayed_import( const char *name ); extern void add_extra_ld_symbol( const char *name ); +extern void add_spec_extra_ld_symbol( const char *name ); extern void read_undef_symbols( DLLSPEC *spec, char **argv ); extern void resolve_imports( DLLSPEC *spec ); extern int is_undefined( const char *name ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index b1e6d115717..b37aec9cf6f 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -397,11 +397,22 @@ static const char *get_default_entry_point( const DLLSPEC *spec ) if (spec->characteristics & IMAGE_FILE_DLL) return "DllMain"; if (spec->subsystem == IMAGE_SUBSYSTEM_NATIVE) return "DriverEntry"; if (spec->type == SPEC_WIN16) + { + add_spec_extra_ld_symbol("WinMain16"); return "__wine_spec_exe16_entry"; + } else if (spec->unicode_app) + { + /* __wine_spec_exe_wentry always calls wmain */ + add_spec_extra_ld_symbol("wmain"); return "__wine_spec_exe_wentry"; + } else + { + /* __wine_spec_exe_entry always calls main */ + add_spec_extra_ld_symbol("main"); return "__wine_spec_exe_entry"; + } }
/* parse options from the argv array and remove all the recognized ones */ diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index ba2edfb588f..a12e7d38aac 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -50,6 +50,13 @@ int needs_get_pc_thunk = 0;
static const char builtin_signature[32] = "Wine builtin DLL"; static const char fakedll_signature[32] = "Wine placeholder DLL"; +static struct strarray spec_extra_ld_symbols = { 0 }; /* list of extra symbols that ld should resolve */ + +/* add a symbol to the list of extra symbols that ld must resolve */ +void add_spec_extra_ld_symbol( const char *name ) +{ + strarray_add( &spec_extra_ld_symbols, name, NULL ); +}
static unsigned int hash_filename( const char *name ) { @@ -610,6 +617,7 @@ void output_exports( DLLSPEC *spec ) void output_module( DLLSPEC *spec ) { int machine = 0; + int i; unsigned int page_size = get_page_size(); const char *data_dirs[16] = { NULL };
@@ -688,6 +696,10 @@ void output_module( DLLSPEC *spec ) output( "\t.long 0\n" ); /* SizeOfCode */ output( "\t.long 0\n" ); /* SizeOfInitializedData */ output( "\t.long 0\n" ); /* SizeOfUninitializedData */ + + for (i = 0; i < spec_extra_ld_symbols.count; i++) + output( "\t.globl %s\n", asm_name(spec_extra_ld_symbols.str[i]) ); + /* note: we expand the AddressOfEntryPoint field on 64-bit by overwriting the BaseOfCode field */ output( "\t%s %s\n", /* AddressOfEntryPoint */ get_asm_ptr_keyword(), spec->init_func ? asm_name(spec->init_func) : "0" );