winebuild: Store a C-compatible version of the dll name.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-03-22 15:06:27 +09:00
parent 8e10ae6705
commit 05399ad711
5 changed files with 23 additions and 40 deletions

View file

@ -116,6 +116,7 @@ typedef struct
char *src_name; /* file name of the source spec file */
char *file_name; /* file name of the dll */
char *dll_name; /* internal name of the dll */
char *c_name; /* internal name of the dll, as a C-compatible identifier */
char *init_func; /* initialization routine */
char *main_module; /* main Win32 module for Win16 specs */
SPEC_TYPE type; /* type of dll (Win16/Win32) */
@ -259,7 +260,7 @@ extern int remove_stdcall_decoration( char *name );
extern void assemble_file( const char *src_file, const char *obj_file );
extern DLLSPEC *alloc_dll_spec(void);
extern void free_dll_spec( DLLSPEC *spec );
extern const char *make_c_identifier( const char *str );
extern char *make_c_identifier( const char *str );
extern const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec );
extern int get_cpu_from_name( const char *name );
extern unsigned int get_alignment(unsigned int align);

View file

@ -40,6 +40,7 @@
struct import
{
char *dll_name; /* exported file name of the dll */
char *c_name; /* dll name as a C-compatible identifier */
char *full_name; /* full name of the input file */
dev_t dev; /* device/inode of the input file */
ino_t ino;
@ -130,6 +131,7 @@ static void free_imports( struct import *imp )
free( imp->exports );
free( imp->imports );
free( imp->dll_name );
free( imp->c_name );
free( imp->full_name );
free( imp );
}
@ -269,6 +271,7 @@ void add_import_dll( const char *name, const char *filename )
}
imp->dll_name = spec->file_name ? spec->file_name : dll_name;
imp->c_name = make_c_identifier( imp->dll_name );
if (is_delayed_import( dll_name ))
{
@ -661,7 +664,6 @@ int has_imports(void)
static void output_immediate_imports(void)
{
int i, j;
const char *dll_name;
if (nb_imports == nb_delayed) return; /* no immediate imports */
@ -677,13 +679,12 @@ static void output_immediate_imports(void)
for (i = j = 0; i < nb_imports; i++)
{
if (dll_imports[i]->delay) continue;
dll_name = make_c_identifier( dll_imports[i]->dll_name );
output( "\t.long .L__wine_spec_import_data_names+%d-.L__wine_spec_rva_base\n", /* OriginalFirstThunk */
j * get_ptr_size() );
output( "\t.long 0\n" ); /* TimeDateStamp */
output( "\t.long 0\n" ); /* ForwarderChain */
output( "\t.long .L__wine_spec_import_name_%s-.L__wine_spec_rva_base\n", /* Name */
dll_name );
dll_imports[i]->c_name );
output( "\t.long .L__wine_spec_import_data_ptrs+%d-.L__wine_spec_rva_base\n", /* FirstThunk */
j * get_ptr_size() );
j += dll_imports[i]->nb_imports + 1;
@ -699,13 +700,12 @@ static void output_immediate_imports(void)
for (i = 0; i < nb_imports; i++)
{
if (dll_imports[i]->delay) continue;
dll_name = make_c_identifier( dll_imports[i]->dll_name );
for (j = 0; j < dll_imports[i]->nb_imports; j++)
{
ORDDEF *odp = dll_imports[i]->imports[j];
if (!(odp->flags & FLAG_NONAME))
output( "\t%s .L__wine_spec_import_data_%s_%s-.L__wine_spec_rva_base\n",
get_asm_ptr_keyword(), dll_name, odp->name );
get_asm_ptr_keyword(), dll_imports[i]->c_name, odp->name );
else
{
if (get_ptr_size() == 8)
@ -728,14 +728,13 @@ static void output_immediate_imports(void)
for (i = 0; i < nb_imports; i++)
{
if (dll_imports[i]->delay) continue;
dll_name = make_c_identifier( dll_imports[i]->dll_name );
for (j = 0; j < dll_imports[i]->nb_imports; j++)
{
ORDDEF *odp = dll_imports[i]->imports[j];
if (!(odp->flags & FLAG_NONAME))
{
output( "\t.align %d\n", get_alignment(2) );
output( ".L__wine_spec_import_data_%s_%s:\n", dll_name, odp->name );
output( ".L__wine_spec_import_data_%s_%s:\n", dll_imports[i]->c_name, odp->name );
output( "\t.short %d\n", odp->ordinal );
output( "\t%s \"%s\"\n", get_asm_string_keyword(), odp->name );
}
@ -745,9 +744,8 @@ static void output_immediate_imports(void)
for (i = 0; i < nb_imports; i++)
{
if (dll_imports[i]->delay) continue;
dll_name = make_c_identifier( dll_imports[i]->dll_name );
output( ".L__wine_spec_import_name_%s:\n\t%s \"%s\"\n",
dll_name, get_asm_string_keyword(), dll_imports[i]->dll_name );
dll_imports[i]->c_name, get_asm_string_keyword(), dll_imports[i]->dll_name );
}
}

View file

@ -158,6 +158,7 @@ static void init_dll_name( DLLSPEC *spec )
spec->dll_name = xstrdup( spec->file_name );
if ((p = strrchr( spec->dll_name, '.' ))) *p = 0;
}
spec->c_name = make_c_identifier( spec->dll_name );
}
/* set the dll subsystem */

View file

@ -110,12 +110,10 @@ static void output_entries( DLLSPEC *spec, int first, int count )
case TYPE_PASCAL:
case TYPE_VARARGS:
case TYPE_STUB:
output( "\t.short .L__wine_%s_%u-.L__wine_spec_code_segment\n",
make_c_identifier(spec->dll_name), first + i );
output( "\t.short .L__wine_%s_%u-.L__wine_spec_code_segment\n", spec->c_name, first + i );
break;
case TYPE_VARIABLE:
output( "\t.short .L__wine_%s_%u-.L__wine_spec_data_segment\n",
make_c_identifier(spec->dll_name), first + i );
output( "\t.short .L__wine_%s_%u-.L__wine_spec_data_segment\n", spec->c_name, first + i );
break;
case TYPE_ABS:
output( "\t.short 0x%04x /* %s */\n",
@ -601,8 +599,7 @@ static void output_module16( DLLSPEC *spec )
output( "\t.short %u\n", spec->heap_size ); /* ne_heap */
output( "\t.short 0\n" ); /* ne_stack */
if (!entry_point) output( "\t.long 0\n" ); /* ne_csip */
else output( "\t.short .L__wine_%s_0-.L__wine_spec_code_segment,1\n",
make_c_identifier(spec->dll_name) );
else output( "\t.short .L__wine_%s_0-.L__wine_spec_code_segment,1\n", spec->c_name );
output( "\t.short 0,2\n" ); /* ne_sssp */
output( "\t.short 2\n" ); /* ne_cseg */
output( "\t.short 0\n" ); /* ne_cmod */
@ -754,7 +751,7 @@ static void output_module16( DLLSPEC *spec )
{
ORDDEF *odp = spec->ordinals[i];
if (!odp || !is_function( odp )) continue;
output( ".L__wine_%s_%u:\n", make_c_identifier(spec->dll_name), i );
output( ".L__wine_%s_%u:\n", spec->c_name, i );
output( "\tpushw %%bp\n" );
output( "\tpushl $%s\n",
asm_name( odp->type == TYPE_STUB ? get_stub_name( odp, spec ) : odp->link_name ));
@ -770,7 +767,7 @@ static void output_module16( DLLSPEC *spec )
{
ORDDEF *odp = spec->ordinals[i];
if (!odp || odp->type != TYPE_VARIABLE) continue;
output( ".L__wine_%s_%u:\n", make_c_identifier(spec->dll_name), i );
output( ".L__wine_%s_%u:\n", spec->c_name, i );
output( "\t.long " );
for (j = 0; j < odp->u.var.n_values-1; j++)
output( "0x%08x,", odp->u.var.values[j] );

View file

@ -754,32 +754,18 @@ DLLSPEC *alloc_dll_spec(void)
DLLSPEC *spec;
spec = xmalloc( sizeof(*spec) );
spec->file_name = NULL;
spec->dll_name = NULL;
spec->init_func = NULL;
spec->main_module = NULL;
memset( spec, 0, sizeof(*spec) );
spec->type = SPEC_WIN32;
spec->base = MAX_ORDINALS;
spec->limit = 0;
spec->stack_size = 0;
spec->heap_size = 0;
spec->nb_entry_points = 0;
spec->alloc_entry_points = 0;
spec->nb_names = 0;
spec->nb_resources = 0;
spec->characteristics = IMAGE_FILE_EXECUTABLE_IMAGE;
spec->subsystem = 0;
spec->subsystem_major = 4;
spec->subsystem_minor = 0;
if (get_ptr_size() > 4)
spec->characteristics |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
else
spec->characteristics |= IMAGE_FILE_32BIT_MACHINE;
spec->dll_characteristics = IMAGE_DLLCHARACTERISTICS_NX_COMPAT;
spec->subsystem = 0;
spec->subsystem_major = 4;
spec->subsystem_minor = 0;
spec->entry_points = NULL;
spec->names = NULL;
spec->ordinals = NULL;
spec->resources = NULL;
return spec;
}
@ -802,6 +788,7 @@ void free_dll_spec( DLLSPEC *spec )
}
free( spec->file_name );
free( spec->dll_name );
free( spec->c_name );
free( spec->init_func );
free( spec->entry_points );
free( spec->names );
@ -816,10 +803,9 @@ void free_dll_spec( DLLSPEC *spec )
*
* Map a string to a valid C identifier.
*/
const char *make_c_identifier( const char *str )
char *make_c_identifier( const char *str )
{
static char buffer[256];
char *p;
char *p, buffer[256];
for (p = buffer; *str && p < buffer+sizeof(buffer)-1; p++, str++)
{
@ -827,7 +813,7 @@ const char *make_c_identifier( const char *str )
else *p = '_';
}
*p = 0;
return buffer;
return xstrdup( buffer );
}