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>
This commit is contained in:
Kevin Puetz 2020-11-25 13:00:27 -06:00 committed by Alexandre Julliard
parent a1078d4770
commit bf5893f489
3 changed files with 24 additions and 0 deletions

View file

@ -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 );

View file

@ -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 */

View file

@ -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" );