Don't remove ignored symbols from the undefined list, simply skip them

when resolving imports.
Added get_temp_file_name utility function.
This commit is contained in:
Alexandre Julliard 2005-09-19 15:24:13 +00:00
parent cecfc3f43e
commit 87c347b18e
3 changed files with 49 additions and 37 deletions

View file

@ -169,6 +169,7 @@ extern void error( const char *msg, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
extern void warning( const char *msg, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
extern char *get_temp_file_name( const char *prefix, const char *suffix );
extern void output_standard_file_header( FILE *outfile );
extern FILE *open_input_file( const char *srcdir, const char *name );
extern void close_input_file( FILE *file );

View file

@ -63,8 +63,6 @@ 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 char *ld_tmp_file; /* ld temp file name */
static struct import **dll_imports = NULL;
static int nb_imports = 0; /* number of imported dlls (delayed or not) */
static int nb_delayed = 0; /* number of delayed dlls */
@ -222,12 +220,6 @@ static void free_imports( struct import *imp )
free( imp );
}
/* remove the temp file at exit */
static void remove_ld_tmp_file(void)
{
if (ld_tmp_file) unlink( ld_tmp_file );
}
/* check whether a given dll is imported in delayed mode */
static int is_delayed_import( const char *name )
{
@ -496,21 +488,10 @@ static int check_unused( const struct import* imp, const DLLSPEC *spec )
static const char *ldcombine_files( char **argv )
{
unsigned int i, len = 0;
char *cmd, *p;
int fd, err;
if (output_file_name && output_file_name[0])
{
ld_tmp_file = xmalloc( strlen(output_file_name) + 10 );
strcpy( ld_tmp_file, output_file_name );
strcat( ld_tmp_file, ".XXXXXX.o" );
}
else ld_tmp_file = xstrdup( "/tmp/winebuild.tmp.XXXXXX.o" );
if ((fd = mkstemps( ld_tmp_file, 2 ) == -1)) fatal_error( "could not generate a temp file\n" );
close( fd );
atexit( remove_ld_tmp_file );
char *cmd, *p, *ld_tmp_file;
int err;
ld_tmp_file = get_temp_file_name( output_file_name, ".o" );
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;
@ -565,25 +546,14 @@ void read_undef_symbols( DLLSPEC *spec, char **argv )
free( cmd );
}
static void remove_ignored_symbols(void)
{
unsigned int i;
if (!ignore_symbols.size) init_ignored_symbols();
sort_names( &ignore_symbols );
for (i = 0; i < undef_symbols.count; i++)
{
if (find_name( undef_symbols.names[i], &ignore_symbols ))
remove_name( &undef_symbols, i-- );
}
}
/* resolve the imports for a Win32 module */
int resolve_imports( DLLSPEC *spec )
{
unsigned int i, j, removed;
ORDDEF *odp;
remove_ignored_symbols();
if (!ignore_symbols.size) init_ignored_symbols();
sort_names( &ignore_symbols );
for (i = 0; i < nb_imports; i++)
{
@ -591,7 +561,8 @@ int resolve_imports( DLLSPEC *spec )
for (j = removed = 0; j < undef_symbols.count; j++)
{
ORDDEF *odp = find_export( undef_symbols.names[j], imp->exports, imp->nb_exports );
if (find_name( undef_symbols.names[j], &ignore_symbols )) continue;
odp = find_export( undef_symbols.names[j], imp->exports, imp->nb_exports );
if (odp)
{
add_import_func( imp, odp );

View file

@ -27,9 +27,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "build.h"
#define MAX_TMP_FILES 8
static const char *tmp_files[MAX_TMP_FILES];
static unsigned int nb_tmp_files;
/* atexit handler to clean tmp files */
static void cleanup_tmp_files(void)
{
unsigned int i;
for (i = 0; i < MAX_TMP_FILES; i++) if (tmp_files[i]) unlink( tmp_files[i] );
}
void *xmalloc (size_t size)
{
void *res;
@ -147,6 +162,31 @@ void warning( const char *msg, ... )
va_end( valist );
}
/* get a name for a temp file, automatically cleaned up on exit */
char *get_temp_file_name( const char *prefix, const char *suffix )
{
char *name;
int fd;
assert( nb_tmp_files < MAX_TMP_FILES );
if (!nb_tmp_files) atexit( cleanup_tmp_files );
if (!prefix || !prefix[0]) prefix = "winebuild.tmp";
if (!suffix) suffix = "";
name = xmalloc( strlen(prefix) + strlen(suffix) + sizeof("/tmp/.XXXXXX") );
sprintf( name, "%s.XXXXXX%s", prefix, suffix );
if ((fd = mkstemps( name, strlen(suffix) ) == -1))
{
sprintf( name, "/tmp/%s.XXXXXX%s", prefix, suffix );
if ((fd = mkstemps( name, strlen(suffix) ) == -1))
fatal_error( "could not generate a temp file\n" );
}
close( fd );
tmp_files[nb_tmp_files++] = name;
return name;
}
/* output a standard header for generated files */
void output_standard_file_header( FILE *outfile )
{