Commit 2b87c82e authored by Alexandre Julliard's avatar Alexandre Julliard

Added a --undefined option to allow forcing some symbols to be

resolved by the linker.
parent eb889cf5
...@@ -190,6 +190,7 @@ extern const char *get_asm_short_keyword(void); ...@@ -190,6 +190,7 @@ extern const char *get_asm_short_keyword(void);
extern void add_import_dll( const char *name, const char *filename ); extern void add_import_dll( const char *name, const char *filename );
extern void add_delayed_import( const char *name ); extern void add_delayed_import( const char *name );
extern void add_ignore_symbol( const char *name ); extern void add_ignore_symbol( const char *name );
extern void add_extra_ld_symbol( const char *name );
extern void read_undef_symbols( char **argv ); extern void read_undef_symbols( char **argv );
extern int resolve_imports( DLLSPEC *spec ); extern int resolve_imports( DLLSPEC *spec );
extern int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed ); extern int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed );
......
...@@ -60,6 +60,7 @@ struct name_table ...@@ -60,6 +60,7 @@ struct name_table
static struct name_table undef_symbols; /* list of undefined symbols */ static struct name_table undef_symbols; /* list of undefined symbols */
static struct name_table ignore_symbols; /* list of symbols to ignore */ static struct name_table ignore_symbols; /* list of symbols to ignore */
static struct name_table extra_ld_symbols; /* list of extra symbols that ld should resolve */
static struct name_table delayed_imports; /* list of delayed import dlls */ static struct name_table delayed_imports; /* list of delayed import dlls */
static char *ld_tmp_file; /* ld temp file name */ static char *ld_tmp_file; /* ld temp file name */
...@@ -438,6 +439,12 @@ void add_ignore_symbol( const char *name ) ...@@ -438,6 +439,12 @@ void add_ignore_symbol( const char *name )
else add_name( &ignore_symbols, name ); else add_name( &ignore_symbols, name );
} }
/* add a symbol to the list of extra symbols that ld must resolve */
void add_extra_ld_symbol( const char *name )
{
add_name( &extra_ld_symbols, name );
}
/* add a function to the list of imports from a given dll */ /* add a function to the list of imports from a given dll */
static void add_import_func( struct import *imp, ORDDEF *func ) static void add_import_func( struct import *imp, ORDDEF *func )
{ {
...@@ -546,8 +553,8 @@ static int check_unused( const struct import* imp, const DLLSPEC *spec ) ...@@ -546,8 +553,8 @@ static int check_unused( const struct import* imp, const DLLSPEC *spec )
/* returns the name of the combined file */ /* returns the name of the combined file */
static const char *ldcombine_files( char **argv ) static const char *ldcombine_files( char **argv )
{ {
int i, len = 0; unsigned int i, len = 0;
char *cmd; char *cmd, *p;
int fd, err; int fd, err;
if (output_file_name && output_file_name[0]) if (output_file_name && output_file_name[0])
...@@ -563,10 +570,14 @@ static const char *ldcombine_files( char **argv ) ...@@ -563,10 +570,14 @@ static const char *ldcombine_files( char **argv )
atexit( remove_ld_tmp_file ); atexit( remove_ld_tmp_file );
if (!ld_command) ld_command = xstrdup("ld"); if (!ld_command) ld_command = xstrdup("ld");
for (i = 0; i < extra_ld_symbols.count; i++) len += strlen(extra_ld_symbols.names[i]) + 5;
for (i = 0; argv[i]; i++) len += strlen(argv[i]) + 1; for (i = 0; argv[i]; i++) len += strlen(argv[i]) + 1;
cmd = xmalloc( len + strlen(ld_tmp_file) + 8 + strlen(ld_command) ); cmd = p = xmalloc( len + strlen(ld_tmp_file) + 8 + strlen(ld_command) );
sprintf( cmd, "%s -r -o %s", ld_command, ld_tmp_file ); p += sprintf( cmd, "%s -r -o %s", ld_command, ld_tmp_file );
for (i = 0; argv[i]; i++) sprintf( cmd + strlen(cmd), " %s", argv[i] ); for (i = 0; i < extra_ld_symbols.count; i++)
p += sprintf( p, " -u %s", asm_name(extra_ld_symbols.names[i]) );
for (i = 0; argv[i]; i++)
p += sprintf( p, " %s", argv[i] );
err = system( cmd ); err = system( cmd );
if (err) fatal_error( "%s -r failed with status %d\n", ld_command, err ); if (err) fatal_error( "%s -r failed with status %d\n", ld_command, err );
free( cmd ); free( cmd );
......
...@@ -234,31 +234,32 @@ static void exit_on_signal( int sig ) ...@@ -234,31 +234,32 @@ static void exit_on_signal( int sig )
static const char usage_str[] = static const char usage_str[] =
"Usage: winebuild [OPTIONS] [FILES]\n\n" "Usage: winebuild [OPTIONS] [FILES]\n\n"
"Options:\n" "Options:\n"
" -C --source-dir=DIR Look for source files in DIR\n" " -C, --source-dir=DIR Look for source files in DIR\n"
" -d --delay-lib=LIB Import the specified library in delayed mode\n" " -d, --delay-lib=LIB Import the specified library in delayed mode\n"
" -D SYM Ignored for C flags compatibility\n" " -D SYM Ignored for C flags compatibility\n"
" -E --export=FILE Export the symbols defined in the .spec or .def file\n" " -E, --export=FILE Export the symbols defined in the .spec or .def file\n"
" -e --entry=FUNC Set the DLL entry point function (default: DllMain)\n" " -e, --entry=FUNC Set the DLL entry point function (default: DllMain)\n"
" -f FLAGS Compiler flags (only -fPIC is supported)\n" " -f FLAGS Compiler flags (only -fPIC is supported)\n"
" -F --filename=DLLFILE Set the DLL filename (default: from input file name)\n" " -F, --filename=DLLFILE Set the DLL filename (default: from input file name)\n"
" -h --help Display this help message\n" " -h, --help Display this help message\n"
" -H --heap=SIZE Set the heap size for a Win16 dll\n" " -H, --heap=SIZE Set the heap size for a Win16 dll\n"
" -i --ignore=SYM[,SYM] Ignore specified symbols when resolving imports\n" " -i, --ignore=SYM[,SYM] Ignore specified symbols when resolving imports\n"
" -I DIR Ignored for C flags compatibility\n" " -I DIR Ignored for C flags compatibility\n"
" -k --kill-at Kill stdcall decorations in generated .def files\n" " -k, --kill-at Kill stdcall decorations in generated .def files\n"
" -K FLAGS Compiler flags (only -KPIC is supported)\n" " -K, FLAGS Compiler flags (only -KPIC is supported)\n"
" --ld-cmd=LD Command to use for linking (default: ld)\n" " --ld-cmd=LD Command to use for linking (default: ld)\n"
" -l --library=LIB Import the specified library\n" " -l, --library=LIB Import the specified library\n"
" -L --library-path=DIR Look for imports libraries in DIR\n" " -L, --library-path=DIR Look for imports libraries in DIR\n"
" -M --main-module=MODULE Set the name of the main module for a Win16 dll\n" " -M, --main-module=MODULE Set the name of the main module for a Win16 dll\n"
" --nm-cmd=NM Command to use to get undefined symbols (default: nm)\n" " --nm-cmd=NM Command to use to get undefined symbols (default: nm)\n"
" -N --dll-name=DLLNAME Set the DLL name (default: from input file name)\n" " -N, --dll-name=DLLNAME Set the DLL name (default: from input file name)\n"
" -o --output=NAME Set the output file name (default: stdout)\n" " -o, --output=NAME Set the output file name (default: stdout)\n"
" -r --res=RSRC.RES Load resources from RSRC.RES\n" " -r, --res=RSRC.RES Load resources from RSRC.RES\n"
" --subsystem=SUBSYS Set the subsystem (one of native, windows, console)\n" " --subsystem=SUBSYS Set the subsystem (one of native, windows, console)\n"
" --target=TARGET Specify target CPU and platform for cross-compiling\n" " --target=TARGET Specify target CPU and platform for cross-compiling\n"
" -u, --undefined=SYMBOL Add an undefined reference to SYMBOL when linking\n"
" --version Print the version and exit\n" " --version Print the version and exit\n"
" -w --warnings Turn on warnings\n" " -w, --warnings Turn on warnings\n"
"\nMode options:\n" "\nMode options:\n"
" --dll Build a .c file from a .spec or .def file\n" " --dll Build a .c file from a .spec or .def file\n"
" --def Build a .def file from a .spec file\n" " --def Build a .def file from a .spec file\n"
...@@ -283,7 +284,7 @@ enum long_options_values ...@@ -283,7 +284,7 @@ enum long_options_values
LONG_OPT_VERSION LONG_OPT_VERSION
}; };
static const char short_options[] = "C:D:E:F:H:I:K:L:M:N:d:e:f:hi:kl:m:o:r:w"; static const char short_options[] = "C:D:E:F:H:I:K:L:M:N:d:e:f:hi:kl:m:o:r:u:w";
static const struct option long_options[] = static const struct option long_options[] =
{ {
...@@ -314,6 +315,7 @@ static const struct option long_options[] = ...@@ -314,6 +315,7 @@ static const struct option long_options[] =
{ "dll-name", 1, 0, 'N' }, { "dll-name", 1, 0, 'N' },
{ "output", 1, 0, 'o' }, { "output", 1, 0, 'o' },
{ "res", 1, 0, 'r' }, { "res", 1, 0, 'r' },
{ "undefined", 1, 0, 'u' },
{ "warnings", 0, 0, 'w' }, { "warnings", 0, 0, 'w' },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
}; };
...@@ -421,6 +423,9 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) ...@@ -421,6 +423,9 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
res_files = xrealloc( res_files, (nb_res_files+1) * sizeof(*res_files) ); res_files = xrealloc( res_files, (nb_res_files+1) * sizeof(*res_files) );
res_files[nb_res_files++] = xstrdup( optarg ); res_files[nb_res_files++] = xstrdup( optarg );
break; break;
case 'u':
add_extra_ld_symbol( optarg );
break;
case 'w': case 'w':
display_warnings = 1; display_warnings = 1;
break; break;
......
...@@ -196,6 +196,11 @@ Specify the target CPU and platform on which the generated code will ...@@ -196,6 +196,11 @@ Specify the target CPU and platform on which the generated code will
be built. The target specification is in the standard autoconf format be built. The target specification is in the standard autoconf format
as returned by config.sub. as returned by config.sub.
.TP .TP
.BI \-u,\ --undefined= symbol
Add \fIsymbol\fR to the list of undefined symbols when invoking the
linker. This makes it possible to force a specific module of a static
library to be included when resolving imports.
.TP
.B \--version .B \--version
Display the program version and exit. Display the program version and exit.
.TP .TP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment