Allocate entry points dynamically to allow for a larger number of

ordinals.
This commit is contained in:
Alexandre Julliard 2000-12-15 23:04:40 +00:00
parent 473fd0b0f7
commit 66fed8cb2d
6 changed files with 46 additions and 58 deletions

View File

@ -74,7 +74,6 @@ typedef struct
{ {
int n_args; int n_args;
char arg_types[17]; char arg_types[17];
char link_name[80];
} ORD_FUNCTION; } ORD_FUNCTION;
typedef struct typedef struct
@ -82,16 +81,6 @@ typedef struct
int value; int value;
} ORD_ABS; } ORD_ABS;
typedef struct
{
char link_name[80];
} ORD_EXTERN;
typedef struct
{
char link_name[80];
} ORD_FORWARD;
typedef struct typedef struct
{ {
ORD_TYPE type; ORD_TYPE type;
@ -99,14 +88,13 @@ typedef struct
int offset; int offset;
int lineno; int lineno;
int flags; int flags;
char name[80]; char *name;
char *link_name;
union union
{ {
ORD_VARIABLE var; ORD_VARIABLE var;
ORD_FUNCTION func; ORD_FUNCTION func;
ORD_ABS abs; ORD_ABS abs;
ORD_EXTERN ext;
ORD_FORWARD fwd;
} u; } u;
} ORDDEF; } ORDDEF;
@ -132,7 +120,7 @@ typedef struct
#define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack)) #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
#define MAX_ORDINALS 2048 #define MAX_ORDINALS 65535
/* global functions */ /* global functions */
@ -176,14 +164,14 @@ extern int nb_lib_paths;
extern char DLLName[80]; extern char DLLName[80];
extern char DLLFileName[80]; extern char DLLFileName[80];
extern char DLLInitFunc[80];
extern char owner_name[80]; extern char owner_name[80];
extern char *init_func;
extern const char *input_file_name; extern const char *input_file_name;
extern const char *output_file_name; extern const char *output_file_name;
extern char **debug_channels; extern char **debug_channels;
extern char **lib_path; extern char **lib_path;
extern ORDDEF EntryPoints[MAX_ORDINALS]; extern ORDDEF *EntryPoints[MAX_ORDINALS];
extern ORDDEF *Ordinals[MAX_ORDINALS]; extern ORDDEF *Ordinals[MAX_ORDINALS];
extern ORDDEF *Names[MAX_ORDINALS]; extern ORDDEF *Names[MAX_ORDINALS];
extern SPEC_MODE SpecMode; extern SPEC_MODE SpecMode;

View File

@ -247,8 +247,8 @@ static void warn_unused( const struct import* imp )
{ {
ORDDEF *odp = Ordinals[i]; ORDDEF *odp = Ordinals[i];
if (!odp || odp->type != TYPE_FORWARD) continue; if (!odp || odp->type != TYPE_FORWARD) continue;
if (!strncasecmp( odp->u.fwd.link_name, imp->dll, len ) && if (!strncasecmp( odp->link_name, imp->dll, len ) &&
odp->u.fwd.link_name[len] == '.') odp->link_name[len] == '.')
return; /* found an import, do not warn */ return; /* found an import, do not warn */
} }
/* switch current_line temporarily to the line of the import declaration */ /* switch current_line temporarily to the line of the import declaration */

View File

@ -17,7 +17,7 @@
#include "winnt.h" #include "winnt.h"
#include "build.h" #include "build.h"
ORDDEF EntryPoints[MAX_ORDINALS]; ORDDEF *EntryPoints[MAX_ORDINALS];
ORDDEF *Ordinals[MAX_ORDINALS]; ORDDEF *Ordinals[MAX_ORDINALS];
ORDDEF *Names[MAX_ORDINALS]; ORDDEF *Names[MAX_ORDINALS];
@ -40,8 +40,8 @@ int debugging = 0;
char DLLName[80]; char DLLName[80];
char DLLFileName[80]; char DLLFileName[80];
char DLLInitFunc[80];
char owner_name[80]; char owner_name[80];
char *init_func = NULL;
char **debug_channels = NULL; char **debug_channels = NULL;
char **lib_path = NULL; char **lib_path = NULL;

View File

@ -279,7 +279,7 @@ static void ParseExportFunction( ORDDEF *odp )
odp->type = TYPE_CDECL; /* stdcall is the same as cdecl for 0 args */ odp->type = TYPE_CDECL; /* stdcall is the same as cdecl for 0 args */
if (odp->type == TYPE_VARARGS) if (odp->type == TYPE_VARARGS)
odp->flags |= FLAG_NORELAY; /* no relay debug possible for varags entry point */ 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 ParseEquate( ORDDEF *odp )
static void ParseStub( ORDDEF *odp ) static void ParseStub( ORDDEF *odp )
{ {
odp->u.func.arg_types[0] = '\0'; odp->u.func.arg_types[0] = '\0';
odp->u.func.link_name[0] = '\0'; odp->link_name = xstrdup("");
} }
@ -333,7 +333,7 @@ static void ParseInterrupt( ORDDEF *odp )
if (*token != ')') fatal_error( "Expected ')' got '%s'\n", token ); if (*token != ')') fatal_error( "Expected ')' got '%s'\n", token );
odp->u.func.arg_types[0] = '\0'; 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 ParseInterrupt( ORDDEF *odp )
static void ParseExtern( ORDDEF *odp ) static void ParseExtern( ORDDEF *odp )
{ {
if (SpecType == SPEC_WIN16) fatal_error( "'extern' not supported for Win16\n" ); 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 */ /* 'extern' definitions are not available for implicit import */
odp->flags |= FLAG_NOIMPORT; odp->flags |= FLAG_NOIMPORT;
} }
@ -359,7 +359,7 @@ static void ParseExtern( ORDDEF *odp )
static void ParseForward( ORDDEF *odp ) static void ParseForward( ORDDEF *odp )
{ {
if (SpecType == SPEC_WIN16) fatal_error( "'forward' not supported for Win16\n" ); 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 @@ static void ParseOrdinal(int ordinal)
{ {
char *token; 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); token = GetToken(0);
@ -423,7 +425,7 @@ static void ParseOrdinal(int ordinal)
token = GetToken(0); token = GetToken(0);
if (*token == '-') token = ParseFlags( odp ); if (*token == '-') token = ParseFlags( odp );
strcpy( odp->name, token ); odp->name = xstrdup( token );
fix_export_name( odp->name ); fix_export_name( odp->name );
odp->lineno = current_line; odp->lineno = current_line;
odp->ordinal = ordinal; odp->ordinal = ordinal;
@ -464,8 +466,8 @@ static void ParseOrdinal(int ordinal)
if (odp->flags & FLAG_I386) if (odp->flags & FLAG_I386)
{ {
/* ignore this entry point on non-Intel archs */ /* ignore this entry point on non-Intel archs */
nb_entry_points--; EntryPoints[--nb_entry_points] = NULL;
memset( odp, 0, sizeof(*odp) ); free( odp );
return; return;
} }
#endif #endif
@ -572,11 +574,9 @@ SPEC_TYPE ParseTopLevel( FILE *file )
} }
else if (strcmp(token, "init") == 0) 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" ); fatal_error( "init cannot be used for Win16 spec files\n" );
if (!DLLInitFunc[0]) init_func = xstrdup( GetToken(0) );
fatal_error( "Expected function name after init\n" );
} }
else if (strcmp(token, "import") == 0) else if (strcmp(token, "import") == 0)
{ {

View File

@ -536,11 +536,12 @@ static void output_stub_funcs( FILE *outfile )
{ {
ORDDEF *odp = Ordinals[i]; ORDDEF *odp = Ordinals[i];
if (!odp || odp->type != TYPE_STUB) continue; if (!odp || odp->type != TYPE_STUB) continue;
strcpy( odp->u.func.link_name, "__stub_" ); odp->link_name = xrealloc( odp->link_name, strlen(odp->name) + 13 );
strcat( odp->u.func.link_name, odp->name ); strcpy( odp->link_name, "__wine_stub_" );
for (p = odp->u.func.link_name; *p; p++) if (!isalnum(*p)) *p = '_'; 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", 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 @@ void BuildSpec16File( FILE *outfile )
case TYPE_CDECL: case TYPE_CDECL:
case TYPE_PASCAL: case TYPE_PASCAL:
case TYPE_PASCAL_16: 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; break;
default: default:
break; break;
@ -727,7 +728,7 @@ void BuildSpec16File( FILE *outfile )
fprintf( outfile, " /* %s.%d */ ", DLLName, i ); fprintf( outfile, " /* %s.%d */ ", DLLName, i );
fprintf( outfile, "{ 0x5566, 0x68, %s, 0xe866, %d /* %s_%s_%s */ },\n", fprintf( outfile, "{ 0x5566, 0x68, %s, 0xe866, %d /* %s_%s_%s */ },\n",
odp->u.func.link_name, odp->link_name,
(type-typelist)*sizeof(CALLFROM16) - (type-typelist)*sizeof(CALLFROM16) -
(code_offset + sizeof(ENTRYPOINT16)), (code_offset + sizeof(ENTRYPOINT16)),
(odp->type == TYPE_CDECL) ? "c" : "p", (odp->type == TYPE_CDECL) ? "c" : "p",

View File

@ -106,7 +106,6 @@ static int output_exports( FILE *outfile, int nr_exports )
{ {
int i, fwd_size = 0, total_size = 0; int i, fwd_size = 0, total_size = 0;
char *p; char *p;
ORDDEF *odp;
if (!nr_exports) return 0; if (!nr_exports) return 0;
@ -146,12 +145,12 @@ static int output_exports( FILE *outfile, int nr_exports )
else switch(odp->type) else switch(odp->type)
{ {
case TYPE_EXTERN: 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; break;
case TYPE_STDCALL: case TYPE_STDCALL:
case TYPE_VARARGS: case TYPE_VARARGS:
case TYPE_CDECL: 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; break;
case TYPE_STUB: case TYPE_STUB:
fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", make_internal_name( odp, "stub" ) ); fprintf( outfile, " \"\\t.long " PREFIX "%s\\n\"\n", make_internal_name( odp, "stub" ) );
@ -164,7 +163,7 @@ static int output_exports( FILE *outfile, int nr_exports )
break; break;
case TYPE_FORWARD: case TYPE_FORWARD:
fprintf( outfile, " \"\\t.long __wine_spec_forwards+%d\\n\"\n", fwd_size ); 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; break;
default: default:
assert(0); assert(0);
@ -218,7 +217,7 @@ static int output_exports( FILE *outfile, int nr_exports )
{ {
ORDDEF *odp = Ordinals[i]; ORDDEF *odp = Ordinals[i];
if (odp && odp->type == TYPE_FORWARD) 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" ); fprintf( outfile, " \"\\t.align 4\\n\"\n" );
total_size += (fwd_size + 3) & ~3; total_size += (fwd_size + 3) & ~3;
@ -252,19 +251,19 @@ static int output_exports( FILE *outfile, int nr_exports )
switch(odp->type) switch(odp->type)
{ {
case TYPE_STDCALL: 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", fprintf( outfile, " \"\\tret $%d\\n\"\n",
strlen(odp->u.func.arg_types) * sizeof(int) ); strlen(odp->u.func.arg_types) * sizeof(int) );
fprintf( outfile, " \"\\t.long " PREFIX "%s,0x%08x\\n\"\n", fprintf( outfile, " \"\\t.long " PREFIX "%s,0x%08x\\n\"\n",
odp->u.func.link_name, mask ); odp->link_name, mask );
break; break;
case TYPE_CDECL: 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, " \"\\tret\\n\"\n" );
fprintf( outfile, " \"\\t.short %d\\n\"\n", fprintf( outfile, " \"\\t.short %d\\n\"\n",
strlen(odp->u.func.arg_types) * sizeof(int) ); strlen(odp->u.func.arg_types) * sizeof(int) );
fprintf( outfile, " \"\\t.long " PREFIX "%s,0x%08x\\n\"\n", fprintf( outfile, " \"\\t.long " PREFIX "%s,0x%08x\\n\"\n",
odp->u.func.link_name, mask ); odp->link_name, mask );
break; break;
case TYPE_REGISTER: case TYPE_REGISTER:
fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n", fprintf( outfile, " \"\\tjmp " PREFIX "%s\\n\"\n",
@ -304,8 +303,9 @@ static int output_exports( FILE *outfile, int nr_exports )
/* output variables */ /* 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) if (odp->type == TYPE_VARIABLE)
{ {
int j; int j;
@ -334,10 +334,10 @@ static int output_exports( FILE *outfile, int nr_exports )
static void output_stub_funcs( FILE *outfile ) static void output_stub_funcs( FILE *outfile )
{ {
int i; 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; if (odp->type != TYPE_STUB) continue;
fprintf( outfile, "#ifdef __GNUC__\n" ); fprintf( outfile, "#ifdef __GNUC__\n" );
fprintf( outfile, "static void __wine_unimplemented( const char *func ) __attribute__((noreturn));\n" ); fprintf( outfile, "static void __wine_unimplemented( const char *func ) __attribute__((noreturn));\n" );
@ -366,8 +366,9 @@ static void output_stub_funcs( FILE *outfile )
break; 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; if (odp->type != TYPE_STUB) continue;
fprintf( outfile, "void %s(void) ", make_internal_name( odp, "stub" ) ); fprintf( outfile, "void %s(void) ", make_internal_name( odp, "stub" ) );
if (odp->name[0]) if (odp->name[0])
@ -385,12 +386,12 @@ static void output_stub_funcs( FILE *outfile )
*/ */
static void output_register_funcs( FILE *outfile ) static void output_register_funcs( FILE *outfile )
{ {
ORDDEF *odp;
const char *name; const char *name;
int i; 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; if (odp->type != TYPE_REGISTER) continue;
name = make_internal_name( odp, "regs" ); name = make_internal_name( odp, "regs" );
fprintf( outfile, fprintf( outfile,
@ -400,7 +401,7 @@ static void output_register_funcs( FILE *outfile )
" \"call " PREFIX "CALL32_Regs\\n\\t\"\n" " \"call " PREFIX "CALL32_Regs\\n\\t\"\n"
" \".long " PREFIX "%s\\n\\t\"\n" " \".long " PREFIX "%s\\n\\t\"\n"
" \".byte %d,%d\");\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) ); 4 * strlen(odp->u.func.arg_types), 4 * strlen(odp->u.func.arg_types) );
} }
} }
@ -416,7 +417,6 @@ void BuildSpec32File( FILE *outfile )
int exports_size = 0; int exports_size = 0;
int nr_exports, nr_imports, nr_resources, nr_debug; int nr_exports, nr_imports, nr_resources, nr_debug;
int characteristics, subsystem; int characteristics, subsystem;
const char *init_func;
DWORD page_size; DWORD page_size;
#ifdef HAVE_GETPAGESIZE #ifdef HAVE_GETPAGESIZE
@ -490,7 +490,6 @@ void BuildSpec32File( FILE *outfile )
/* Output LibMain function */ /* Output LibMain function */
init_func = DLLInitFunc[0] ? DLLInitFunc : NULL;
characteristics = subsystem = 0; characteristics = subsystem = 0;
switch(SpecMode) switch(SpecMode)
{ {