Allocate entry points dynamically to allow for a larger number of ordinals.
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index e182674..5173ba5 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h
@@ -74,7 +74,6 @@ { int n_args; char arg_types[17]; - char link_name[80]; } ORD_FUNCTION; typedef struct @@ -84,29 +83,18 @@ typedef struct { - char link_name[80]; -} ORD_EXTERN; - -typedef struct -{ - char link_name[80]; -} ORD_FORWARD; - -typedef struct -{ ORD_TYPE type; int ordinal; int offset; int lineno; int flags; - char name[80]; + char *name; + char *link_name; union { ORD_VARIABLE var; ORD_FUNCTION func; ORD_ABS abs; - ORD_EXTERN ext; - ORD_FORWARD fwd; } u; } ORDDEF; @@ -132,7 +120,7 @@ #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack)) -#define MAX_ORDINALS 2048 +#define MAX_ORDINALS 65535 /* global functions */ @@ -176,14 +164,14 @@ extern char DLLName[80]; extern char DLLFileName[80]; -extern char DLLInitFunc[80]; extern char owner_name[80]; +extern char *init_func; extern const char *input_file_name; extern const char *output_file_name; extern char **debug_channels; extern char **lib_path; -extern ORDDEF EntryPoints[MAX_ORDINALS]; +extern ORDDEF *EntryPoints[MAX_ORDINALS]; extern ORDDEF *Ordinals[MAX_ORDINALS]; extern ORDDEF *Names[MAX_ORDINALS]; extern SPEC_MODE SpecMode;
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index b050b8f..618abec 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c
@@ -247,8 +247,8 @@ { ORDDEF *odp = Ordinals[i]; if (!odp || odp->type != TYPE_FORWARD) continue; - if (!strncasecmp( odp->u.fwd.link_name, imp->dll, len ) && - odp->u.fwd.link_name[len] == '.') + if (!strncasecmp( odp->link_name, imp->dll, len ) && + odp->link_name[len] == '.') return; /* found an import, do not warn */ } /* switch current_line temporarily to the line of the import declaration */
diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index b64049b..ead9345 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c
@@ -17,7 +17,7 @@ #include "winnt.h" #include "build.h" -ORDDEF EntryPoints[MAX_ORDINALS]; +ORDDEF *EntryPoints[MAX_ORDINALS]; ORDDEF *Ordinals[MAX_ORDINALS]; ORDDEF *Names[MAX_ORDINALS]; @@ -40,8 +40,8 @@ char DLLName[80]; char DLLFileName[80]; -char DLLInitFunc[80]; char owner_name[80]; +char *init_func = NULL; char **debug_channels = NULL; char **lib_path = NULL;
diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c index e08165d..b49f20f 100644 --- a/tools/winebuild/parser.c +++ b/tools/winebuild/parser.c
@@ -279,7 +279,7 @@ odp->type = TYPE_CDECL; /* stdcall is the same as cdecl for 0 args */ if (odp->type == TYPE_VARARGS) odp->flags |= FLAG_NORELAY; /* no relay debug possible for varags entry point */ - strcpy(odp->u.func.link_name, GetToken(0)); + odp->link_name = xstrdup( GetToken(0) ); } @@ -310,7 +310,7 @@ static void ParseStub( ORDDEF *odp ) { odp->u.func.arg_types[0] = '\0'; - odp->u.func.link_name[0] = '\0'; + odp->link_name = xstrdup(""); } @@ -333,7 +333,7 @@ if (*token != ')') fatal_error( "Expected ')' got '%s'\n", token ); odp->u.func.arg_types[0] = '\0'; - strcpy( odp->u.func.link_name, GetToken(0) ); + odp->link_name = xstrdup( GetToken(0) ); } @@ -345,7 +345,7 @@ static void ParseExtern( ORDDEF *odp ) { if (SpecType == SPEC_WIN16) fatal_error( "'extern' not supported for Win16\n" ); - strcpy( odp->u.ext.link_name, GetToken(0) ); + odp->link_name = xstrdup( GetToken(0) ); /* 'extern' definitions are not available for implicit import */ odp->flags |= FLAG_NOIMPORT; } @@ -359,7 +359,7 @@ static void ParseForward( ORDDEF *odp ) { if (SpecType == SPEC_WIN16) fatal_error( "'forward' not supported for Win16\n" ); - strcpy( odp->u.fwd.link_name, GetToken(0) ); + odp->link_name = xstrdup( GetToken(0) ); } @@ -409,7 +409,9 @@ { char *token; - ORDDEF *odp = &EntryPoints[nb_entry_points++]; + ORDDEF *odp = xmalloc( sizeof(*odp) ); + memset( odp, 0, sizeof(*odp) ); + EntryPoints[nb_entry_points++] = odp; token = GetToken(0); @@ -423,7 +425,7 @@ token = GetToken(0); if (*token == '-') token = ParseFlags( odp ); - strcpy( odp->name, token ); + odp->name = xstrdup( token ); fix_export_name( odp->name ); odp->lineno = current_line; odp->ordinal = ordinal; @@ -464,8 +466,8 @@ if (odp->flags & FLAG_I386) { /* ignore this entry point on non-Intel archs */ - nb_entry_points--; - memset( odp, 0, sizeof(*odp) ); + EntryPoints[--nb_entry_points] = NULL; + free( odp ); return; } #endif @@ -572,11 +574,9 @@ } else if (strcmp(token, "init") == 0) { - strcpy(DLLInitFunc, GetToken(0)); - if (SpecType == SPEC_WIN16) + if (SpecType == SPEC_WIN16) fatal_error( "init cannot be used for Win16 spec files\n" ); - if (!DLLInitFunc[0]) - fatal_error( "Expected function name after init\n" ); + init_func = xstrdup( GetToken(0) ); } else if (strcmp(token, "import") == 0) {
diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c index a22c81c..58a4953 100644 --- a/tools/winebuild/spec16.c +++ b/tools/winebuild/spec16.c
@@ -536,11 +536,12 @@ { ORDDEF *odp = Ordinals[i]; if (!odp || odp->type != TYPE_STUB) continue; - strcpy( odp->u.func.link_name, "__stub_" ); - strcat( odp->u.func.link_name, odp->name ); - for (p = odp->u.func.link_name; *p; p++) if (!isalnum(*p)) *p = '_'; + odp->link_name = xrealloc( odp->link_name, strlen(odp->name) + 13 ); + strcpy( odp->link_name, "__wine_stub_" ); + strcat( odp->link_name, odp->name ); + for (p = odp->link_name; *p; p++) if (!isalnum(*p)) *p = '_'; fprintf( outfile, "static void %s(void) { __wine_unimplemented(\"%s\"); }\n", - odp->u.func.link_name, odp->name ); + odp->link_name, odp->name ); } } @@ -640,7 +641,7 @@ case TYPE_CDECL: case TYPE_PASCAL: case TYPE_PASCAL_16: - fprintf( outfile, "extern void %s();\n", odp->u.func.link_name ); + fprintf( outfile, "extern void %s();\n", odp->link_name ); break; default: break; @@ -727,7 +728,7 @@ fprintf( outfile, " /* %s.%d */ ", DLLName, i ); fprintf( outfile, "{ 0x5566, 0x68, %s, 0xe866, %d /* %s_%s_%s */ },\n", - odp->u.func.link_name, + odp->link_name, (type-typelist)*sizeof(CALLFROM16) - (code_offset + sizeof(ENTRYPOINT16)), (odp->type == TYPE_CDECL) ? "c" : "p",
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 9400e15..5daeabb 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c
@@ -106,7 +106,6 @@ { int i, fwd_size = 0, total_size = 0; char *p; - ORDDEF *odp; if (!nr_exports) return 0; @@ -146,12 +145,12 @@ else switch(odp->type) { case TYPE_EXTERN: - fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", odp->u.ext.link_name ); + fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", odp->link_name ); break; case TYPE_STDCALL: case TYPE_VARARGS: case TYPE_CDECL: - fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", odp->u.func.link_name); + fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", odp->link_name); break; case TYPE_STUB: fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", make_internal_name( odp, "stub" ) ); @@ -164,7 +163,7 @@ break; case TYPE_FORWARD: fprintf( outfile, " \"\\t.long __wine_spec_forwards+%d\\n\"\n", fwd_size ); - fwd_size += strlen(odp->u.fwd.link_name) + 1; + fwd_size += strlen(odp->link_name) + 1; break; default: assert(0); @@ -218,7 +217,7 @@ { ORDDEF *odp = Ordinals[i]; if (odp && odp->type == TYPE_FORWARD) - fprintf( outfile, " \"\\t" STRING " \\\"%s\\\"\\n\"\n", odp->u.fwd.link_name ); + fprintf( outfile, " \"\\t" STRING " \\\"%s\\\"\\n\"\n", odp->link_name ); } fprintf( outfile, " \"\\t.align 4\\n\"\n" ); total_size += (fwd_size + 3) & ~3; @@ -252,19 +251,19 @@ switch(odp->type) { case TYPE_STDCALL: - fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n", odp->u.func.link_name ); + fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n", odp->link_name ); fprintf( outfile, " \"\\tret $%d\\n\"\n", strlen(odp->u.func.arg_types) * sizeof(int) ); fprintf( outfile, " \"\\t.long " PREFIX "%s,0x%08x\\n\"\n", - odp->u.func.link_name, mask ); + odp->link_name, mask ); break; case TYPE_CDECL: - fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n", odp->u.func.link_name ); + fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n", odp->link_name ); fprintf( outfile, " \"\\tret\\n\"\n" ); fprintf( outfile, " \"\\t.short %d\\n\"\n", strlen(odp->u.func.arg_types) * sizeof(int) ); fprintf( outfile, " \"\\t.long " PREFIX "%s,0x%08x\\n\"\n", - odp->u.func.link_name, mask ); + odp->link_name, mask ); break; case TYPE_REGISTER: fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n", @@ -304,8 +303,9 @@ /* output variables */ - for (i = 0, odp = EntryPoints; i < nb_entry_points; i++, odp++) + for (i = 0; i < nb_entry_points; i++) { + ORDDEF *odp = EntryPoints[i]; if (odp->type == TYPE_VARIABLE) { int j; @@ -334,10 +334,10 @@ static void output_stub_funcs( FILE *outfile ) { int i; - ORDDEF *odp; - for (i = 0, odp = EntryPoints; i < nb_entry_points; i++, odp++) + for (i = 0; i < nb_entry_points; i++) { + ORDDEF *odp = EntryPoints[i]; if (odp->type != TYPE_STUB) continue; fprintf( outfile, "#ifdef __GNUC__\n" ); fprintf( outfile, "static void __wine_unimplemented( const char *func ) __attribute__((noreturn));\n" ); @@ -366,8 +366,9 @@ break; } - for (i = 0, odp = EntryPoints; i < nb_entry_points; i++, odp++) + for (i = 0; i < nb_entry_points; i++) { + ORDDEF *odp = EntryPoints[i]; if (odp->type != TYPE_STUB) continue; fprintf( outfile, "void %s(void) ", make_internal_name( odp, "stub" ) ); if (odp->name[0]) @@ -385,12 +386,12 @@ */ static void output_register_funcs( FILE *outfile ) { - ORDDEF *odp; const char *name; int i; - for (i = 0, odp = EntryPoints; i < nb_entry_points; i++, odp++) + for (i = 0; i < nb_entry_points; i++) { + ORDDEF *odp = EntryPoints[i]; if (odp->type != TYPE_REGISTER) continue; name = make_internal_name( odp, "regs" ); fprintf( outfile, @@ -400,7 +401,7 @@ " \"call " PREFIX "CALL32_Regs\\n\\t\"\n" " \".long " PREFIX "%s\\n\\t\"\n" " \".byte %d,%d\");\n", - name, name, odp->u.func.link_name, + name, name, odp->link_name, 4 * strlen(odp->u.func.arg_types), 4 * strlen(odp->u.func.arg_types) ); } } @@ -416,7 +417,6 @@ int exports_size = 0; int nr_exports, nr_imports, nr_resources, nr_debug; int characteristics, subsystem; - const char *init_func; DWORD page_size; #ifdef HAVE_GETPAGESIZE @@ -490,7 +490,6 @@ /* Output LibMain function */ - init_func = DLLInitFunc[0] ? DLLInitFunc : NULL; characteristics = subsystem = 0; switch(SpecMode) {