2000-06-23 22:15:35 +02:00
|
|
|
/*
|
|
|
|
* 32-bit spec files
|
|
|
|
*
|
|
|
|
* Copyright 1993 Robert J. Amstadt
|
|
|
|
* Copyright 1995 Martin von Loewis
|
|
|
|
* Copyright 1995, 1996, 1997 Alexandre Julliard
|
|
|
|
* Copyright 1997 Eric Youngdale
|
|
|
|
* Copyright 1999 Ulrich Weigand
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-06-23 22:15:35 +02:00
|
|
|
*/
|
|
|
|
|
2001-10-14 18:18:52 +02:00
|
|
|
#include "config.h"
|
2002-04-25 23:40:56 +02:00
|
|
|
#include "wine/port.h"
|
2001-10-14 18:18:52 +02:00
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
#include <assert.h>
|
2000-11-09 21:31:18 +01:00
|
|
|
#include <ctype.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-03-21 21:30:46 +01:00
|
|
|
#include <string.h>
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-06-23 22:15:35 +02:00
|
|
|
#include "winbase.h"
|
2000-10-27 00:03:34 +02:00
|
|
|
#include "wine/exception.h"
|
2000-06-23 22:15:35 +02:00
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
|
2003-10-24 02:27:27 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
# define __ASM_SKIP ".space"
|
|
|
|
#else
|
|
|
|
# define __ASM_SKIP ".skip"
|
|
|
|
#endif
|
|
|
|
|
2000-11-05 05:49:13 +01:00
|
|
|
static int string_compare( const void *ptr1, const void *ptr2 )
|
|
|
|
{
|
|
|
|
const char * const *str1 = ptr1;
|
|
|
|
const char * const *str2 = ptr2;
|
|
|
|
return strcmp( *str1, *str2 );
|
|
|
|
}
|
|
|
|
|
2000-11-26 05:31:48 +01:00
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* make_internal_name
|
|
|
|
*
|
|
|
|
* Generate an internal name for an entry point. Used for stubs etc.
|
|
|
|
*/
|
2004-02-11 07:41:01 +01:00
|
|
|
static const char *make_internal_name( const ORDDEF *odp, DLLSPEC *spec, const char *prefix )
|
2000-11-26 05:31:48 +01:00
|
|
|
{
|
|
|
|
static char buffer[256];
|
2002-07-28 19:54:31 +02:00
|
|
|
if (odp->name || odp->export_name)
|
2000-12-29 04:26:27 +01:00
|
|
|
{
|
|
|
|
char *p;
|
2004-02-11 07:41:01 +01:00
|
|
|
sprintf( buffer, "__wine_%s_%s_%s", prefix, spec->file_name,
|
2002-07-28 19:54:31 +02:00
|
|
|
odp->name ? odp->name : odp->export_name );
|
2000-12-29 04:26:27 +01:00
|
|
|
/* make sure name is a legal C identifier */
|
|
|
|
for (p = buffer; *p; p++) if (!isalnum(*p) && *p != '_') break;
|
|
|
|
if (!*p) return buffer;
|
|
|
|
}
|
2004-02-11 07:41:01 +01:00
|
|
|
sprintf( buffer, "__wine_%s_%s_%d", prefix, make_c_identifier(spec->file_name), odp->ordinal );
|
2000-11-26 05:31:48 +01:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2004-02-13 23:42:13 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* declare_weak_function
|
|
|
|
*
|
|
|
|
* Output a prototype for a weak function.
|
|
|
|
*/
|
|
|
|
static void declare_weak_function( FILE *outfile, const char *name, const char *prototype )
|
|
|
|
{
|
|
|
|
fprintf( outfile, "#ifdef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "# ifdef __APPLE__\n" );
|
|
|
|
fprintf( outfile, "extern %s __attribute__((weak_import));\n", prototype );
|
|
|
|
fprintf( outfile, "# else\n" );
|
|
|
|
fprintf( outfile, "extern %s __attribute__((weak));\n", prototype );
|
|
|
|
fprintf( outfile, "# endif\n" );
|
|
|
|
fprintf( outfile, "#else\n" );
|
|
|
|
fprintf( outfile, "extern %s;\n", prototype );
|
|
|
|
fprintf( outfile, "static void __asm__dummy_%s(void)", name );
|
|
|
|
fprintf( outfile, " { asm(\".weak " __ASM_NAME("%s") "\"); }\n", name );
|
|
|
|
fprintf( outfile, "#endif\n\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-05 05:49:13 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_debug
|
|
|
|
*
|
|
|
|
* Output the debug channels.
|
|
|
|
*/
|
|
|
|
static int output_debug( FILE *outfile )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!nb_debug_channels) return 0;
|
|
|
|
qsort( debug_channels, nb_debug_channels, sizeof(debug_channels[0]), string_compare );
|
|
|
|
|
|
|
|
for (i = 0; i < nb_debug_channels; i++)
|
|
|
|
fprintf( outfile, "char __wine_dbch_%s[] = \"\\003%s\";\n",
|
|
|
|
debug_channels[i], debug_channels[i] );
|
|
|
|
|
|
|
|
fprintf( outfile, "\nstatic char * const debug_channels[%d] =\n{\n", nb_debug_channels );
|
|
|
|
for (i = 0; i < nb_debug_channels; i++)
|
|
|
|
{
|
|
|
|
fprintf( outfile, " __wine_dbch_%s", debug_channels[i] );
|
|
|
|
if (i < nb_debug_channels - 1) fprintf( outfile, ",\n" );
|
|
|
|
}
|
|
|
|
fprintf( outfile, "\n};\n\n" );
|
|
|
|
fprintf( outfile, "static void *debug_registration;\n\n" );
|
|
|
|
|
|
|
|
return nb_debug_channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_exports
|
|
|
|
*
|
|
|
|
* Output the export table for a Win32 module.
|
|
|
|
*/
|
2004-02-11 07:41:01 +01:00
|
|
|
static int output_exports( FILE *outfile, int nr_exports, DLLSPEC *spec )
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
int i, fwd_size = 0, total_size = 0;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
if (!nr_exports) return 0;
|
|
|
|
|
|
|
|
fprintf( outfile, "asm(\".data\\n\"\n" );
|
2001-02-13 03:06:38 +01:00
|
|
|
fprintf( outfile, " \"\\t.align %d\\n\"\n", get_alignment(4) );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"" __ASM_NAME("__wine_spec_exports") ":\\n\"\n" );
|
2000-12-11 04:42:20 +01:00
|
|
|
|
|
|
|
/* export directory header */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\t.long 0\\n\"\n" ); /* Characteristics */
|
|
|
|
fprintf( outfile, " \"\\t.long 0\\n\"\n" ); /* TimeDateStamp */
|
|
|
|
fprintf( outfile, " \"\\t.long 0\\n\"\n" ); /* MajorVersion/MinorVersion */
|
2003-09-26 06:36:46 +02:00
|
|
|
fprintf( outfile, " \"\\t.long __wine_spec_exp_names\\n\"\n" ); /* Name */
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf( outfile, " \"\\t.long %d\\n\"\n", spec->base ); /* Base */
|
|
|
|
fprintf( outfile, " \"\\t.long %d\\n\"\n", nr_exports ); /* NumberOfFunctions */
|
|
|
|
fprintf( outfile, " \"\\t.long %d\\n\"\n", spec->nb_names ); /* NumberOfNames */
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\t.long __wine_spec_exports_funcs\\n\"\n" ); /* AddressOfFunctions */
|
2004-02-11 07:41:01 +01:00
|
|
|
if (spec->nb_names)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\t.long __wine_spec_exp_name_ptrs\\n\"\n" ); /* AddressOfNames */
|
|
|
|
fprintf( outfile, " \"\\t.long __wine_spec_exp_ordinals\\n\"\n" ); /* AddressOfNameOrdinals */
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\t.long 0\\n\"\n" ); /* AddressOfNames */
|
|
|
|
fprintf( outfile, " \"\\t.long 0\\n\"\n" ); /* AddressOfNameOrdinals */
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
2000-12-11 04:42:20 +01:00
|
|
|
total_size += 10 * sizeof(int);
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
/* output the function pointers */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"__wine_spec_exports_funcs:\\n\"\n" );
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = spec->base; i <= spec->limit; i++)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
ORDDEF *odp = spec->ordinals[i];
|
2000-12-11 04:42:20 +01:00
|
|
|
if (!odp) fprintf( outfile, " \"\\t.long 0\\n\"\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
else switch(odp->type)
|
|
|
|
{
|
|
|
|
case TYPE_EXTERN:
|
|
|
|
case TYPE_STDCALL:
|
|
|
|
case TYPE_VARARGS:
|
|
|
|
case TYPE_CDECL:
|
2002-12-15 02:22:40 +01:00
|
|
|
if (!(odp->flags & FLAG_FORWARD))
|
|
|
|
{
|
|
|
|
fprintf( outfile, " \"\\t.long " __ASM_NAME("%s") "\\n\"\n",
|
2004-02-11 07:41:01 +01:00
|
|
|
(odp->flags & FLAG_REGISTER) ? make_internal_name( odp, spec, "regs" )
|
|
|
|
: odp->link_name );
|
2002-12-15 02:22:40 +01:00
|
|
|
}
|
2003-03-17 05:56:10 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf( outfile, " \"\\t.long __wine_spec_forwards+%d\\n\"\n", fwd_size );
|
|
|
|
fwd_size += strlen(odp->link_name) + 1;
|
|
|
|
}
|
2000-06-23 22:15:35 +02:00
|
|
|
break;
|
|
|
|
case TYPE_STUB:
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf( outfile, " \"\\t.long " __ASM_NAME("%s") "\\n\"\n",
|
|
|
|
make_internal_name( odp, spec, "stub" ) );
|
2000-06-23 22:15:35 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
2004-02-11 07:41:01 +01:00
|
|
|
total_size += (spec->limit - spec->base + 1) * sizeof(int);
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
if (spec->nb_names)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
/* output the function name pointers */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
int namepos = strlen(spec->file_name) + 1;
|
2000-12-11 04:42:20 +01:00
|
|
|
|
|
|
|
fprintf( outfile, " \"__wine_spec_exp_name_ptrs:\\n\"\n" );
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = 0; i < spec->nb_names; i++)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\t.long __wine_spec_exp_names+%d\\n\"\n", namepos );
|
2004-02-11 07:41:01 +01:00
|
|
|
namepos += strlen(spec->names[i]->name) + 1;
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
2004-02-11 07:41:01 +01:00
|
|
|
total_size += spec->nb_names * sizeof(int);
|
2003-09-26 06:36:46 +02:00
|
|
|
}
|
2000-12-11 04:42:20 +01:00
|
|
|
|
2003-09-26 06:36:46 +02:00
|
|
|
/* output the function names */
|
2000-12-11 04:42:20 +01:00
|
|
|
|
2003-09-26 06:36:46 +02:00
|
|
|
fprintf( outfile, " \"\\t.text\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"__wine_spec_exp_names:\\n\"\n" );
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf( outfile, " \"\\t" __ASM_STRING " \\\"%s\\\"\\n\"\n", spec->file_name );
|
|
|
|
for (i = 0; i < spec->nb_names; i++)
|
|
|
|
fprintf( outfile, " \"\\t" __ASM_STRING " \\\"%s\\\"\\n\"\n", spec->names[i]->name );
|
2003-09-26 06:36:46 +02:00
|
|
|
fprintf( outfile, " \"\\t.data\\n\"\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
if (spec->nb_names)
|
2003-09-26 06:36:46 +02:00
|
|
|
{
|
2000-06-23 22:15:35 +02:00
|
|
|
/* output the function ordinals */
|
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"__wine_spec_exp_ordinals:\\n\"\n" );
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = 0; i < spec->nb_names; i++)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf( outfile, " \"\\t" __ASM_SHORT " %d\\n\"\n",
|
|
|
|
spec->names[i]->ordinal - spec->base );
|
2000-12-11 04:42:20 +01:00
|
|
|
}
|
2004-02-11 07:41:01 +01:00
|
|
|
total_size += spec->nb_names * sizeof(short);
|
|
|
|
if (spec->nb_names % 2)
|
2000-12-11 04:42:20 +01:00
|
|
|
{
|
2003-03-23 01:18:26 +01:00
|
|
|
fprintf( outfile, " \"\\t" __ASM_SHORT " 0\\n\"\n" );
|
2000-12-11 04:42:20 +01:00
|
|
|
total_size += sizeof(short);
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
/* output forward strings */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
if (fwd_size)
|
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"__wine_spec_forwards:\\n\"\n" );
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = spec->base; i <= spec->limit; i++)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
ORDDEF *odp = spec->ordinals[i];
|
2002-12-15 02:22:40 +01:00
|
|
|
if (odp && (odp->flags & FLAG_FORWARD))
|
2003-03-23 01:18:26 +01:00
|
|
|
fprintf( outfile, " \"\\t" __ASM_STRING " \\\"%s\\\"\\n\"\n", odp->link_name );
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
2001-02-13 03:06:38 +01:00
|
|
|
fprintf( outfile, " \"\\t.align %d\\n\"\n", get_alignment(4) );
|
2000-12-11 04:42:20 +01:00
|
|
|
total_size += (fwd_size + 3) & ~3;
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* output relays */
|
|
|
|
|
2000-11-28 00:48:08 +01:00
|
|
|
if (debugging)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = spec->base; i <= spec->limit; i++)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
ORDDEF *odp = spec->ordinals[i];
|
2001-12-15 00:14:22 +01:00
|
|
|
unsigned int j, args, mask = 0;
|
|
|
|
const char *name;
|
2000-11-28 00:48:08 +01:00
|
|
|
|
|
|
|
/* skip non-existent entry points */
|
|
|
|
if (!odp) goto ignore;
|
|
|
|
/* skip non-functions */
|
2001-12-15 00:14:22 +01:00
|
|
|
if ((odp->type != TYPE_STDCALL) && (odp->type != TYPE_CDECL)) goto ignore;
|
2002-12-15 02:22:40 +01:00
|
|
|
/* skip norelay and forward entry points */
|
|
|
|
if (odp->flags & (FLAG_NORELAY|FLAG_FORWARD)) goto ignore;
|
2000-11-28 00:48:08 +01:00
|
|
|
|
|
|
|
for (j = 0; odp->u.func.arg_types[j]; j++)
|
|
|
|
{
|
|
|
|
if (odp->u.func.arg_types[j] == 't') mask |= 1<< (j*2);
|
|
|
|
if (odp->u.func.arg_types[j] == 'W') mask |= 2<< (j*2);
|
|
|
|
}
|
|
|
|
if ((odp->flags & FLAG_RET64) && (j < 16)) mask |= 0x80000000;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2001-12-15 00:14:22 +01:00
|
|
|
name = odp->link_name;
|
|
|
|
args = strlen(odp->u.func.arg_types) * sizeof(int);
|
2004-02-11 07:41:01 +01:00
|
|
|
if (odp->flags & FLAG_REGISTER) name = make_internal_name( odp, spec, "regs" );
|
2001-12-15 00:14:22 +01:00
|
|
|
|
2000-11-28 00:48:08 +01:00
|
|
|
switch(odp->type)
|
|
|
|
{
|
|
|
|
case TYPE_STDCALL:
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tjmp " __ASM_NAME("%s") "\\n\"\n", name );
|
2002-11-04 23:50:24 +01:00
|
|
|
fprintf( outfile, " \"\\tret $%d\\n\"\n", args );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\t.long " __ASM_NAME("%s") ",0x%08x\\n\"\n", name, mask );
|
2000-11-28 00:48:08 +01:00
|
|
|
break;
|
|
|
|
case TYPE_CDECL:
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tjmp " __ASM_NAME("%s") "\\n\"\n", name );
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\tret\\n\"\n" );
|
2003-03-23 01:18:26 +01:00
|
|
|
fprintf( outfile, " \"\\t" __ASM_SHORT " %d\\n\"\n", args );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\t.long " __ASM_NAME("%s") ",0x%08x\\n\"\n", name, mask );
|
2000-11-28 00:48:08 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
2000-12-11 04:42:20 +01:00
|
|
|
continue;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-11-28 00:48:08 +01:00
|
|
|
ignore:
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " \"\\t.long 0,0,0,0\\n\"\n" );
|
2000-11-28 00:48:08 +01:00
|
|
|
}
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.text\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.align %d\\n\"\n", get_alignment(4) );
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, ");\n\n" );
|
|
|
|
|
|
|
|
return total_size;
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-12 04:45:55 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_stub_funcs
|
|
|
|
*
|
|
|
|
* Output the functions for stub entry points
|
|
|
|
*/
|
2004-02-11 07:41:01 +01:00
|
|
|
static void output_stub_funcs( FILE *outfile, DLLSPEC *spec )
|
2000-11-12 04:45:55 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = 0; i < spec->nb_entry_points; i++)
|
2000-11-12 04:45:55 +01:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
ORDDEF *odp = &spec->entry_points[i];
|
2000-11-12 04:45:55 +01:00
|
|
|
if (odp->type != TYPE_STUB) continue;
|
|
|
|
fprintf( outfile, "#ifdef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "static void __wine_unimplemented( const char *func ) __attribute__((noreturn));\n" );
|
2000-12-15 04:38:11 +01:00
|
|
|
fprintf( outfile, "#endif\n\n" );
|
|
|
|
fprintf( outfile, "struct exc_record {\n" );
|
|
|
|
fprintf( outfile, " unsigned int code, flags;\n" );
|
|
|
|
fprintf( outfile, " void *rec, *addr;\n" );
|
|
|
|
fprintf( outfile, " unsigned int params;\n" );
|
|
|
|
fprintf( outfile, " const void *info[15];\n" );
|
|
|
|
fprintf( outfile, "};\n\n" );
|
|
|
|
fprintf( outfile, "extern void __stdcall RtlRaiseException( struct exc_record * );\n\n" );
|
2000-11-12 04:45:55 +01:00
|
|
|
fprintf( outfile, "static void __wine_unimplemented( const char *func )\n{\n" );
|
2000-12-15 04:38:11 +01:00
|
|
|
fprintf( outfile, " struct exc_record rec;\n" );
|
2000-11-12 04:45:55 +01:00
|
|
|
fprintf( outfile, " rec.code = 0x%08x;\n", EXCEPTION_WINE_STUB );
|
|
|
|
fprintf( outfile, " rec.flags = %d;\n", EH_NONCONTINUABLE );
|
|
|
|
fprintf( outfile, " rec.rec = 0;\n" );
|
|
|
|
fprintf( outfile, " rec.params = 2;\n" );
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf( outfile, " rec.info[0] = \"%s\";\n", spec->file_name );
|
2000-11-12 04:45:55 +01:00
|
|
|
fprintf( outfile, " rec.info[1] = func;\n" );
|
|
|
|
fprintf( outfile, "#ifdef __GNUC__\n" );
|
|
|
|
fprintf( outfile, " rec.addr = __builtin_return_address(1);\n" );
|
|
|
|
fprintf( outfile, "#else\n" );
|
|
|
|
fprintf( outfile, " rec.addr = 0;\n" );
|
|
|
|
fprintf( outfile, "#endif\n" );
|
|
|
|
fprintf( outfile, " for (;;) RtlRaiseException( &rec );\n}\n\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = 0; i < spec->nb_entry_points; i++)
|
2000-11-12 04:45:55 +01:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
const ORDDEF *odp = &spec->entry_points[i];
|
2000-11-12 04:45:55 +01:00
|
|
|
if (odp->type != TYPE_STUB) continue;
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf( outfile, "void %s(void) ", make_internal_name( odp, spec, "stub" ) );
|
2002-07-28 19:54:31 +02:00
|
|
|
if (odp->name)
|
2000-11-26 05:31:48 +01:00
|
|
|
fprintf( outfile, "{ __wine_unimplemented(\"%s\"); }\n", odp->name );
|
2002-07-28 19:54:31 +02:00
|
|
|
else if (odp->export_name)
|
|
|
|
fprintf( outfile, "{ __wine_unimplemented(\"%s\"); }\n", odp->export_name );
|
2000-11-12 04:45:55 +01:00
|
|
|
else
|
2000-11-26 05:31:48 +01:00
|
|
|
fprintf( outfile, "{ __wine_unimplemented(\"%d\"); }\n", odp->ordinal );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_register_funcs
|
|
|
|
*
|
|
|
|
* Output the functions for register entry points
|
|
|
|
*/
|
2004-02-11 07:41:01 +01:00
|
|
|
static void output_register_funcs( FILE *outfile, DLLSPEC *spec )
|
2000-11-26 05:31:48 +01:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int i;
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
for (i = 0; i < spec->nb_entry_points; i++)
|
2000-11-26 05:31:48 +01:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
const ORDDEF *odp = &spec->entry_points[i];
|
2001-12-15 00:14:22 +01:00
|
|
|
if (odp->type != TYPE_STDCALL && odp->type != TYPE_CDECL) continue;
|
|
|
|
if (!(odp->flags & FLAG_REGISTER)) continue;
|
2003-04-03 20:05:17 +02:00
|
|
|
if (odp->flags & FLAG_FORWARD) continue;
|
2004-02-11 07:41:01 +01:00
|
|
|
name = make_internal_name( odp, spec, "regs" );
|
2000-11-26 05:31:48 +01:00
|
|
|
fprintf( outfile,
|
2001-02-13 03:06:38 +01:00
|
|
|
"asm(\".align %d\\n\\t\"\n"
|
2000-12-01 22:27:43 +01:00
|
|
|
" \"" __ASM_FUNC("%s") "\\n\\t\"\n"
|
2002-07-22 22:47:11 +02:00
|
|
|
" \"" __ASM_NAME("%s") ":\\n\\t\"\n"
|
|
|
|
" \"call " __ASM_NAME("__wine_call_from_32_regs") "\\n\\t\"\n"
|
|
|
|
" \".long " __ASM_NAME("%s") "\\n\\t\"\n"
|
2000-11-26 05:31:48 +01:00
|
|
|
" \".byte %d,%d\");\n",
|
2001-02-13 03:06:38 +01:00
|
|
|
get_alignment(4),
|
2000-12-16 00:04:40 +01:00
|
|
|
name, name, odp->link_name,
|
2001-12-15 00:14:22 +01:00
|
|
|
strlen(odp->u.func.arg_types) * sizeof(int),
|
|
|
|
(odp->type == TYPE_CDECL) ? 0 : (strlen(odp->u.func.arg_types) * sizeof(int)) );
|
2000-11-12 04:45:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-15 01:42:53 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_dll_init
|
|
|
|
*
|
|
|
|
* Output code for calling a dll constructor and destructor.
|
|
|
|
*/
|
|
|
|
void output_dll_init( FILE *outfile, const char *constructor, const char *destructor )
|
|
|
|
{
|
|
|
|
fprintf( outfile, "#ifndef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "static void __asm__dummy_dll_init(void) {\n" );
|
|
|
|
fprintf( outfile, "#endif\n" );
|
|
|
|
|
|
|
|
#if defined(__i386__)
|
|
|
|
if (constructor)
|
|
|
|
{
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("%s") "\\n\"\n", constructor );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("%s") "\\n\"\n", destructor );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
|
|
|
#elif defined(__sparc__)
|
|
|
|
if (constructor)
|
|
|
|
{
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("%s") "\\n\"\n", constructor );
|
2002-06-15 01:42:53 +02:00
|
|
|
fprintf( outfile, " \"\\tnop\\n\"\n" );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("%s") "\\n\"\n", destructor );
|
2002-06-15 01:42:53 +02:00
|
|
|
fprintf( outfile, " \"\\tnop\\n\"\n" );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
2003-10-24 02:27:27 +02:00
|
|
|
#elif defined(__powerpc__)
|
|
|
|
# ifdef __APPLE__
|
|
|
|
/* Mach-O doesn't have an init section */
|
|
|
|
if (constructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.mod_init_func\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.align 2\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.long " __ASM_NAME("%s") "\\n\"\n", constructor );
|
|
|
|
fprintf( outfile, " \"\\t.text\\n\");\n" );
|
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.mod_term_func\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.align 2\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.long " __ASM_NAME("%s") "\\n\"\n", destructor );
|
|
|
|
fprintf( outfile, " \"\\t.text\\n\");\n" );
|
|
|
|
}
|
|
|
|
# else /* __APPLE__ */
|
2002-06-15 01:42:53 +02:00
|
|
|
if (constructor)
|
|
|
|
{
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tbl " __ASM_NAME("%s") "\\n\"\n", constructor );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tbl " __ASM_NAME("%s") "\\n\"\n", destructor );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
2003-10-24 02:27:27 +02:00
|
|
|
# endif /* __APPLE__ */
|
2002-06-15 01:42:53 +02:00
|
|
|
#else
|
|
|
|
#error You need to define the DLL constructor for your architecture
|
|
|
|
#endif
|
|
|
|
fprintf( outfile, "#ifndef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "}\n" );
|
|
|
|
fprintf( outfile, "#endif\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* BuildSpec32File
|
|
|
|
*
|
|
|
|
* Build a Win32 C file from a spec file.
|
|
|
|
*/
|
2004-02-11 07:41:01 +01:00
|
|
|
void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2000-12-11 04:42:20 +01:00
|
|
|
int exports_size = 0;
|
2004-02-11 07:41:01 +01:00
|
|
|
int nr_exports, nr_imports;
|
2000-06-23 22:15:35 +02:00
|
|
|
DWORD page_size;
|
2004-02-11 07:41:01 +01:00
|
|
|
const char *init_func = spec->init_func;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_GETPAGESIZE
|
|
|
|
page_size = getpagesize();
|
2002-03-11 06:09:02 +01:00
|
|
|
#elif defined(__svr4__)
|
2000-06-23 22:15:35 +02:00
|
|
|
page_size = sysconf(_SC_PAGESIZE);
|
2002-03-11 06:09:02 +01:00
|
|
|
#elif defined(_WINDOWS)
|
|
|
|
{
|
|
|
|
SYSTEM_INFO si;
|
|
|
|
GetSystemInfo(&si);
|
|
|
|
page_size = si.dwPageSize;
|
|
|
|
}
|
|
|
|
#else
|
2000-06-23 22:15:35 +02:00
|
|
|
# error Cannot get the page size on this platform
|
|
|
|
#endif
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0;
|
|
|
|
resolve_imports( spec );
|
2002-03-10 00:29:33 +01:00
|
|
|
output_standard_file_header( outfile );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
/* Reserve some space for the PE header */
|
|
|
|
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, "extern char __wine_spec_pe_header[];\n" );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "#ifndef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "static void __asm__dummy_header(void) {\n" );
|
|
|
|
fprintf( outfile, "#endif\n" );
|
2003-10-24 02:27:27 +02:00
|
|
|
fprintf( outfile, "asm(\".text\\n\\t\"\n" );
|
2001-02-13 03:06:38 +01:00
|
|
|
fprintf( outfile, " \".align %d\\n\"\n", get_alignment(page_size) );
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, " \"" __ASM_NAME("__wine_spec_pe_header") ":\\t" __ASM_SKIP " 65536\\n\\t\"\n" );
|
|
|
|
fprintf( outfile, " \".data\\n\\t\"\n" );
|
|
|
|
fprintf( outfile, " \".align %d\\n\"\n", get_alignment(4) );
|
|
|
|
fprintf( outfile, " \"" __ASM_NAME("__wine_spec_data_start") ":\\t.long 1\");\n" );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "#ifndef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "}\n" );
|
|
|
|
fprintf( outfile, "#endif\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-03-22 22:12:23 +01:00
|
|
|
#ifdef __APPLE__
|
|
|
|
fprintf( outfile, "static char _end[4];\n" );
|
|
|
|
#else
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, "extern char _end[];\n" );
|
2004-03-22 22:12:23 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, "extern int __wine_spec_data_start[], __wine_spec_exports[];\n\n" );
|
2000-10-27 00:03:34 +02:00
|
|
|
|
2000-12-02 21:38:47 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
fprintf( outfile, "#define __stdcall __attribute__((__stdcall__))\n\n" );
|
|
|
|
#else
|
|
|
|
fprintf( outfile, "#define __stdcall\n\n" );
|
|
|
|
#endif
|
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
if (nr_exports)
|
|
|
|
{
|
|
|
|
/* Output the stub functions */
|
2000-10-27 00:03:34 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
output_stub_funcs( outfile, spec );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, "#ifndef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "static void __asm__dummy(void) {\n" );
|
|
|
|
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
/* Output code for all register functions */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
output_register_funcs( outfile, spec );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
/* Output the exports and relay entry points */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
exports_size = output_exports( outfile, nr_exports, spec );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, "#ifndef __GNUC__\n" );
|
|
|
|
fprintf( outfile, "}\n" );
|
|
|
|
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
|
|
|
|
}
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
/* Output the DLL imports */
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
nr_imports = output_imports( outfile, spec );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2000-10-23 23:33:06 +02:00
|
|
|
/* Output the resources */
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
output_resources( outfile, spec );
|
2000-10-23 23:33:06 +02:00
|
|
|
|
2004-01-08 04:36:53 +01:00
|
|
|
/* Output the entry point function */
|
|
|
|
|
2004-01-15 05:58:17 +01:00
|
|
|
fprintf( outfile, "static int __wine_spec_init_state;\n" );
|
2004-01-08 04:36:53 +01:00
|
|
|
fprintf( outfile, "extern int __wine_main_argc;\n" );
|
|
|
|
fprintf( outfile, "extern char **__wine_main_argv;\n" );
|
|
|
|
fprintf( outfile, "extern char **__wine_main_environ;\n" );
|
|
|
|
fprintf( outfile, "extern unsigned short **__wine_main_wargv;\n" );
|
2004-03-22 22:12:23 +01:00
|
|
|
#ifdef __APPLE__
|
|
|
|
fprintf( outfile, "extern _dyld_func_lookup(char *, void *);");
|
|
|
|
fprintf( outfile, "void _init(int argc, char** argv, char** chr)\n" );
|
|
|
|
fprintf( outfile, "{\n");
|
|
|
|
fprintf( outfile, " void (*init)(void);\n");
|
|
|
|
fprintf( outfile, " _dyld_func_lookup(\"__dyld_make_delayed_module_initializer_calls\", (unsigned long *)&init);\n");
|
|
|
|
fprintf( outfile, " init();\n");
|
|
|
|
fprintf( outfile, "}\n");
|
|
|
|
fprintf( outfile, "void _fini()\n" );
|
|
|
|
fprintf( outfile, "{\n");
|
|
|
|
fprintf( outfile, " void (*fini)(void);\n");
|
|
|
|
fprintf( outfile, " _dyld_func_lookup(\"__dyld_mod_term_funcs\", (unsigned long *)&fini);\n");
|
|
|
|
fprintf( outfile, " fini();\n");
|
|
|
|
fprintf( outfile, "}\n");
|
|
|
|
#else
|
2004-01-08 04:36:53 +01:00
|
|
|
fprintf( outfile, "extern void _init(int, char**, char**);\n" );
|
|
|
|
fprintf( outfile, "extern void _fini();\n" );
|
2004-03-22 22:12:23 +01:00
|
|
|
#endif
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-03-25 01:40:52 +01:00
|
|
|
if (spec->characteristics & IMAGE_FILE_DLL)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2004-01-08 04:36:53 +01:00
|
|
|
if (init_func)
|
|
|
|
fprintf( outfile, "extern int __stdcall %s( void*, unsigned int, void* );\n\n", init_func );
|
2002-11-05 00:53:41 +01:00
|
|
|
else
|
|
|
|
{
|
2004-02-13 23:42:13 +01:00
|
|
|
declare_weak_function( outfile, "DllMain",
|
|
|
|
"int __stdcall DllMain( void*, unsigned int, void* )" );
|
2004-01-08 04:36:53 +01:00
|
|
|
init_func = "DllMain";
|
2002-11-05 00:53:41 +01:00
|
|
|
}
|
2000-06-23 22:15:35 +02:00
|
|
|
fprintf( outfile,
|
2004-01-08 04:36:53 +01:00
|
|
|
"static int __stdcall __wine_dll_main( void *inst, unsigned int reason, void *reserved )\n"
|
2000-06-23 22:15:35 +02:00
|
|
|
"{\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" int ret;\n"
|
2004-01-15 05:58:17 +01:00
|
|
|
" if (reason == %d && __wine_spec_init_state == 1)\n"
|
|
|
|
" _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" ret = %s ? %s( inst, reason, reserved ) : 1;\n"
|
2004-01-15 05:58:17 +01:00
|
|
|
" if (reason == %d && __wine_spec_init_state == 1) _fini();\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" return ret;\n"
|
|
|
|
"}\n",
|
|
|
|
DLL_PROCESS_ATTACH, init_func, init_func, DLL_PROCESS_DETACH );
|
|
|
|
init_func = "__wine_dll_main";
|
2004-03-25 01:40:52 +01:00
|
|
|
}
|
|
|
|
else switch(spec->subsystem)
|
|
|
|
{
|
|
|
|
case IMAGE_SUBSYSTEM_NATIVE:
|
2004-02-13 23:42:13 +01:00
|
|
|
if (init_func)
|
|
|
|
fprintf( outfile, "extern int __stdcall %s( void*, void* );\n\n", init_func );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
declare_weak_function( outfile, "DriverEntry",
|
|
|
|
"int __stdcall DriverEntry( void*, void* )" );
|
|
|
|
init_func = "DriverEntry";
|
|
|
|
}
|
|
|
|
fprintf( outfile,
|
|
|
|
"static int __stdcall __wine_driver_entry( void *obj, void *path )\n"
|
|
|
|
"{\n"
|
|
|
|
" int ret;\n"
|
2004-02-16 21:24:32 +01:00
|
|
|
" if (__wine_spec_init_state == 1)\n"
|
2004-02-13 23:42:13 +01:00
|
|
|
" _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n"
|
|
|
|
" ret = %s ? %s( obj, path ) : 0;\n"
|
2004-02-16 21:24:32 +01:00
|
|
|
" if (__wine_spec_init_state == 1) _fini();\n"
|
2004-02-13 23:42:13 +01:00
|
|
|
" return ret;\n"
|
|
|
|
"}\n",
|
2004-02-16 21:24:32 +01:00
|
|
|
init_func, init_func );
|
2004-02-13 23:42:13 +01:00
|
|
|
init_func = "__wine_driver_entry";
|
|
|
|
break;
|
2004-03-25 01:40:52 +01:00
|
|
|
case IMAGE_SUBSYSTEM_WINDOWS_GUI:
|
2004-04-08 06:41:14 +02:00
|
|
|
case IMAGE_SUBSYSTEM_WINDOWS_CUI:
|
|
|
|
if (init_func)
|
|
|
|
fprintf( outfile, "extern int %s( int argc, char *argv[] );\n", init_func );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
declare_weak_function( outfile, "main", "int main( int argc, char *argv[] )" );
|
|
|
|
declare_weak_function( outfile, "wmain", "int wmain( int argc, unsigned short *argv[] )" );
|
|
|
|
declare_weak_function( outfile, "WinMain", "int __stdcall WinMain(void *,void *,char *,int)" );
|
|
|
|
}
|
2000-12-15 04:38:11 +01:00
|
|
|
fprintf( outfile,
|
2004-01-08 04:36:53 +01:00
|
|
|
"\ntypedef struct {\n"
|
2001-10-02 22:32:58 +02:00
|
|
|
" unsigned int cb;\n"
|
|
|
|
" char *lpReserved, *lpDesktop, *lpTitle;\n"
|
|
|
|
" unsigned int dwX, dwY, dwXSize, dwYSize;\n"
|
|
|
|
" unsigned int dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags;\n"
|
|
|
|
" unsigned short wShowWindow, cbReserved2;\n"
|
|
|
|
" char *lpReserved2;\n"
|
|
|
|
" void *hStdInput, *hStdOutput, *hStdError;\n"
|
|
|
|
"} STARTUPINFOA;\n"
|
|
|
|
"extern char * __stdcall GetCommandLineA(void);\n"
|
|
|
|
"extern void * __stdcall GetModuleHandleA(char *);\n"
|
|
|
|
"extern void __stdcall GetStartupInfoA(STARTUPINFOA *);\n"
|
|
|
|
"extern void __stdcall ExitProcess(unsigned int);\n"
|
2000-12-15 04:38:11 +01:00
|
|
|
"static void __wine_exe_main(void)\n"
|
|
|
|
"{\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" int ret;\n"
|
2004-01-15 05:58:17 +01:00
|
|
|
" if (__wine_spec_init_state == 1)\n"
|
2004-03-24 04:39:57 +01:00
|
|
|
" _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" );
|
|
|
|
if (init_func)
|
|
|
|
fprintf( outfile,
|
|
|
|
" ret = %s( __wine_main_argc, __wine_main_argv );\n", init_func );
|
|
|
|
else
|
|
|
|
fprintf( outfile,
|
2004-04-08 06:41:14 +02:00
|
|
|
" if (WinMain) {\n"
|
|
|
|
" STARTUPINFOA info;\n"
|
|
|
|
" char *cmdline = GetCommandLineA();\n"
|
|
|
|
" int bcount=0, in_quotes=0;\n"
|
|
|
|
" while (*cmdline) {\n"
|
|
|
|
" if ((*cmdline=='\\t' || *cmdline==' ') && !in_quotes) break;\n"
|
|
|
|
" else if (*cmdline=='\\\\') bcount++;\n"
|
|
|
|
" else if (*cmdline=='\\\"') {\n"
|
|
|
|
" if ((bcount & 1)==0) in_quotes=!in_quotes;\n"
|
|
|
|
" bcount=0;\n"
|
|
|
|
" }\n"
|
|
|
|
" else bcount=0;\n"
|
|
|
|
" cmdline++;\n"
|
|
|
|
" }\n"
|
|
|
|
" while (*cmdline=='\\t' || *cmdline==' ') cmdline++;\n"
|
|
|
|
" GetStartupInfoA( &info );\n"
|
|
|
|
" if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n"
|
|
|
|
" ret = WinMain( GetModuleHandleA(0), 0, cmdline, info.wShowWindow );\n"
|
|
|
|
" }\n"
|
|
|
|
" else if (wmain) ret = wmain( __wine_main_argc, __wine_main_wargv );\n"
|
2004-03-24 04:39:57 +01:00
|
|
|
" else ret = main( __wine_main_argc, __wine_main_argv );\n" );
|
2000-12-15 04:38:11 +01:00
|
|
|
fprintf( outfile,
|
2004-01-15 05:58:17 +01:00
|
|
|
" if (__wine_spec_init_state == 1) _fini();\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" ExitProcess( ret );\n"
|
2004-03-24 04:39:57 +01:00
|
|
|
"}\n\n" );
|
2000-12-15 04:38:11 +01:00
|
|
|
init_func = "__wine_exe_main";
|
2000-06-23 22:15:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-09-28 01:40:43 +02:00
|
|
|
/* Output the NT header */
|
|
|
|
|
|
|
|
/* this is the IMAGE_NT_HEADERS structure, but we cannot include winnt.h here */
|
|
|
|
fprintf( outfile, "static const struct image_nt_headers\n{\n" );
|
|
|
|
fprintf( outfile, " int Signature;\n" );
|
|
|
|
fprintf( outfile, " struct file_header {\n" );
|
|
|
|
fprintf( outfile, " short Machine;\n" );
|
|
|
|
fprintf( outfile, " short NumberOfSections;\n" );
|
|
|
|
fprintf( outfile, " int TimeDateStamp;\n" );
|
|
|
|
fprintf( outfile, " void *PointerToSymbolTable;\n" );
|
|
|
|
fprintf( outfile, " int NumberOfSymbols;\n" );
|
|
|
|
fprintf( outfile, " short SizeOfOptionalHeader;\n" );
|
|
|
|
fprintf( outfile, " short Characteristics;\n" );
|
|
|
|
fprintf( outfile, " } FileHeader;\n" );
|
|
|
|
fprintf( outfile, " struct opt_header {\n" );
|
|
|
|
fprintf( outfile, " short Magic;\n" );
|
|
|
|
fprintf( outfile, " char MajorLinkerVersion, MinorLinkerVersion;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfCode;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfInitializedData;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfUninitializedData;\n" );
|
|
|
|
fprintf( outfile, " void *AddressOfEntryPoint;\n" );
|
|
|
|
fprintf( outfile, " void *BaseOfCode;\n" );
|
|
|
|
fprintf( outfile, " void *BaseOfData;\n" );
|
|
|
|
fprintf( outfile, " void *ImageBase;\n" );
|
|
|
|
fprintf( outfile, " int SectionAlignment;\n" );
|
|
|
|
fprintf( outfile, " int FileAlignment;\n" );
|
|
|
|
fprintf( outfile, " short MajorOperatingSystemVersion;\n" );
|
|
|
|
fprintf( outfile, " short MinorOperatingSystemVersion;\n" );
|
|
|
|
fprintf( outfile, " short MajorImageVersion;\n" );
|
|
|
|
fprintf( outfile, " short MinorImageVersion;\n" );
|
|
|
|
fprintf( outfile, " short MajorSubsystemVersion;\n" );
|
|
|
|
fprintf( outfile, " short MinorSubsystemVersion;\n" );
|
|
|
|
fprintf( outfile, " int Win32VersionValue;\n" );
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, " void *SizeOfImage;\n" );
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " int SizeOfHeaders;\n" );
|
|
|
|
fprintf( outfile, " int CheckSum;\n" );
|
|
|
|
fprintf( outfile, " short Subsystem;\n" );
|
|
|
|
fprintf( outfile, " short DllCharacteristics;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfStackReserve;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfStackCommit;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfHeapReserve;\n" );
|
|
|
|
fprintf( outfile, " int SizeOfHeapCommit;\n" );
|
|
|
|
fprintf( outfile, " int LoaderFlags;\n" );
|
|
|
|
fprintf( outfile, " int NumberOfRvaAndSizes;\n" );
|
2000-10-23 23:33:06 +02:00
|
|
|
fprintf( outfile, " struct { const void *VirtualAddress; int Size; } DataDirectory[%d];\n",
|
2000-09-28 01:40:43 +02:00
|
|
|
IMAGE_NUMBEROF_DIRECTORY_ENTRIES );
|
|
|
|
fprintf( outfile, " } OptionalHeader;\n" );
|
|
|
|
fprintf( outfile, "} nt_header = {\n" );
|
|
|
|
fprintf( outfile, " 0x%04x,\n", IMAGE_NT_SIGNATURE ); /* Signature */
|
2003-10-24 02:27:27 +02:00
|
|
|
#ifdef __i386__
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " { 0x%04x,\n", IMAGE_FILE_MACHINE_I386 ); /* Machine */
|
2003-10-24 02:27:27 +02:00
|
|
|
#elif defined(__powerpc__)
|
|
|
|
fprintf( outfile, " { 0x%04x,\n", IMAGE_FILE_MACHINE_POWERPC ); /* Machine */
|
|
|
|
#else
|
|
|
|
fprintf( outfile, " { 0x%04x,\n", IMAGE_FILE_MACHINE_UNKNOWN ); /* Machine */
|
|
|
|
#endif
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " 0, 0, 0, 0,\n" );
|
|
|
|
fprintf( outfile, " sizeof(nt_header.OptionalHeader),\n" ); /* SizeOfOptionalHeader */
|
2004-03-25 01:40:52 +01:00
|
|
|
fprintf( outfile, " 0x%04x },\n", spec->characteristics ); /* Characteristics */
|
2000-09-28 01:40:43 +02:00
|
|
|
|
|
|
|
fprintf( outfile, " { 0x%04x,\n", IMAGE_NT_OPTIONAL_HDR_MAGIC ); /* Magic */
|
|
|
|
fprintf( outfile, " 0, 0,\n" ); /* Major/MinorLinkerVersion */
|
|
|
|
fprintf( outfile, " 0, 0, 0,\n" ); /* SizeOfCode/Data */
|
2004-01-08 04:36:53 +01:00
|
|
|
fprintf( outfile, " %s,\n", init_func ); /* AddressOfEntryPoint */
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, " 0, __wine_spec_data_start,\n" ); /* BaseOfCode/Data */
|
|
|
|
fprintf( outfile, " __wine_spec_pe_header,\n" ); /* ImageBase */
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " %ld,\n", page_size ); /* SectionAlignment */
|
|
|
|
fprintf( outfile, " %ld,\n", page_size ); /* FileAlignment */
|
|
|
|
fprintf( outfile, " 1, 0,\n" ); /* Major/MinorOperatingSystemVersion */
|
|
|
|
fprintf( outfile, " 0, 0,\n" ); /* Major/MinorImageVersion */
|
2004-03-25 01:40:52 +01:00
|
|
|
fprintf( outfile, " %d,\n", spec->subsystem_major ); /* MajorSubsystemVersion */
|
|
|
|
fprintf( outfile, " %d,\n", spec->subsystem_minor ); /* MinorSubsystemVersion */
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " 0,\n" ); /* Win32VersionValue */
|
2003-11-03 23:19:44 +01:00
|
|
|
fprintf( outfile, " _end,\n" ); /* SizeOfImage */
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " %ld,\n", page_size ); /* SizeOfHeaders */
|
|
|
|
fprintf( outfile, " 0,\n" ); /* CheckSum */
|
2004-03-25 01:40:52 +01:00
|
|
|
fprintf( outfile, " 0x%04x,\n", spec->subsystem );/* Subsystem */
|
2001-06-08 00:29:03 +02:00
|
|
|
fprintf( outfile, " 0,\n" ); /* DllCharacteristics */
|
2003-10-30 23:49:01 +01:00
|
|
|
fprintf( outfile, " %d, %ld,\n", /* SizeOfStackReserve/Commit */
|
2004-02-11 07:41:01 +01:00
|
|
|
(spec->stack_size ? spec->stack_size : 1024) * 1024, page_size );
|
2003-10-30 23:49:01 +01:00
|
|
|
fprintf( outfile, " %d, %ld,\n", /* SizeOfHeapReserve/Commit */
|
2004-02-11 07:41:01 +01:00
|
|
|
(spec->heap_size ? spec->heap_size : 1024) * 1024, page_size );
|
2001-06-08 00:29:03 +02:00
|
|
|
fprintf( outfile, " 0,\n" ); /* LoaderFlags */
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " %d,\n", IMAGE_NUMBEROF_DIRECTORY_ENTRIES ); /* NumberOfRvaAndSizes */
|
|
|
|
fprintf( outfile, " {\n" );
|
2000-12-11 04:42:20 +01:00
|
|
|
fprintf( outfile, " { %s, %d },\n", /* IMAGE_DIRECTORY_ENTRY_EXPORT */
|
|
|
|
exports_size ? "__wine_spec_exports" : "0", exports_size );
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " { %s, %s },\n", /* IMAGE_DIRECTORY_ENTRY_IMPORT */
|
|
|
|
nr_imports ? "&imports" : "0", nr_imports ? "sizeof(imports)" : "0" );
|
2000-10-23 23:33:06 +02:00
|
|
|
fprintf( outfile, " { %s, %s },\n", /* IMAGE_DIRECTORY_ENTRY_RESOURCE */
|
2004-02-11 07:41:01 +01:00
|
|
|
spec->nb_resources ? "&resources" : "0",
|
|
|
|
spec->nb_resources ? "sizeof(resources)" : "0" );
|
2000-09-28 01:40:43 +02:00
|
|
|
fprintf( outfile, " }\n }\n};\n\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
/* Output the DLL constructor */
|
|
|
|
|
2000-12-06 21:18:35 +01:00
|
|
|
fprintf( outfile,
|
2004-01-08 04:36:53 +01:00
|
|
|
"void __wine_spec_init(void)\n"
|
2000-12-06 21:18:35 +01:00
|
|
|
"{\n"
|
|
|
|
" extern void __wine_dll_register( const struct image_nt_headers *, const char * );\n"
|
2004-01-15 05:58:17 +01:00
|
|
|
" __wine_spec_init_state = 1;\n"
|
2002-06-15 01:42:53 +02:00
|
|
|
" __wine_dll_register( &nt_header, \"%s\" );\n"
|
2004-01-15 05:58:17 +01:00
|
|
|
"}\n\n",
|
2004-02-11 07:41:01 +01:00
|
|
|
spec->file_name );
|
2004-01-15 05:58:17 +01:00
|
|
|
|
|
|
|
output_dll_init( outfile, "__wine_spec_init_ctor", NULL );
|
|
|
|
fprintf( outfile,
|
|
|
|
"void __wine_spec_init_ctor(void)\n"
|
|
|
|
"{\n"
|
|
|
|
" if (__wine_spec_init_state) return;\n"
|
|
|
|
" __wine_spec_init();\n"
|
|
|
|
" __wine_spec_init_state = 2;\n"
|
|
|
|
"}\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
2002-02-04 19:48:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* BuildDef32File
|
|
|
|
*
|
|
|
|
* Build a Win32 def file from a spec file.
|
|
|
|
*/
|
2004-02-11 07:41:01 +01:00
|
|
|
void BuildDef32File( FILE *outfile, DLLSPEC *spec )
|
2002-02-04 19:48:18 +01:00
|
|
|
{
|
2002-07-28 19:54:31 +02:00
|
|
|
const char *name;
|
2002-02-04 19:48:18 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
fprintf(outfile, "; File generated automatically from %s; do not edit!\n\n",
|
|
|
|
input_file_name );
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
fprintf(outfile, "LIBRARY %s\n\n", spec->file_name);
|
2002-02-04 19:48:18 +01:00
|
|
|
|
|
|
|
fprintf(outfile, "EXPORTS\n");
|
|
|
|
|
|
|
|
/* Output the exports and relay entry points */
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
for(i = 0; i < spec->nb_entry_points; i++)
|
2002-02-04 19:48:18 +01:00
|
|
|
{
|
2004-02-11 07:41:01 +01:00
|
|
|
const ORDDEF *odp = &spec->entry_points[i];
|
2002-12-12 03:20:47 +01:00
|
|
|
int is_data = 0;
|
2002-07-28 19:54:31 +02:00
|
|
|
|
|
|
|
if (!odp) continue;
|
2002-12-12 03:20:47 +01:00
|
|
|
if (odp->flags & FLAG_REGISTER) continue;
|
2002-05-20 00:29:34 +02:00
|
|
|
if (odp->type == TYPE_STUB) continue;
|
2002-02-04 19:48:18 +01:00
|
|
|
|
2002-07-28 19:54:31 +02:00
|
|
|
if (odp->name) name = odp->name;
|
|
|
|
else if (odp->export_name) name = odp->export_name;
|
|
|
|
else continue;
|
|
|
|
|
|
|
|
fprintf(outfile, " %s", name);
|
2002-02-04 19:48:18 +01:00
|
|
|
|
|
|
|
switch(odp->type)
|
|
|
|
{
|
|
|
|
case TYPE_EXTERN:
|
2002-12-12 03:20:47 +01:00
|
|
|
is_data = 1;
|
|
|
|
/* fall through */
|
2002-02-04 19:48:18 +01:00
|
|
|
case TYPE_VARARGS:
|
|
|
|
case TYPE_CDECL:
|
|
|
|
/* try to reduce output */
|
2002-12-15 02:22:40 +01:00
|
|
|
if(strcmp(name, odp->link_name) || (odp->flags & FLAG_FORWARD))
|
2002-02-04 19:48:18 +01:00
|
|
|
fprintf(outfile, "=%s", odp->link_name);
|
|
|
|
break;
|
|
|
|
case TYPE_STDCALL:
|
|
|
|
{
|
|
|
|
int at_param = strlen(odp->u.func.arg_types) * sizeof(int);
|
2002-12-12 05:06:28 +01:00
|
|
|
if (!kill_at) fprintf(outfile, "@%d", at_param);
|
2002-12-15 02:22:40 +01:00
|
|
|
if (odp->flags & FLAG_FORWARD)
|
|
|
|
{
|
|
|
|
fprintf(outfile, "=%s", odp->link_name);
|
|
|
|
}
|
|
|
|
else if (strcmp(name, odp->link_name)) /* try to reduce output */
|
2002-02-04 19:48:18 +01:00
|
|
|
{
|
|
|
|
fprintf(outfile, "=%s", odp->link_name);
|
2002-12-12 05:06:28 +01:00
|
|
|
if (!kill_at) fprintf(outfile, "@%d", at_param);
|
2002-02-04 19:48:18 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
2003-07-28 21:19:48 +02:00
|
|
|
fprintf( outfile, " @%d", odp->ordinal );
|
|
|
|
if (!odp->name) fprintf( outfile, " NONAME" );
|
|
|
|
if (is_data) fprintf( outfile, " DATA" );
|
|
|
|
if (odp->flags & FLAG_PRIVATE) fprintf( outfile, " PRIVATE" );
|
|
|
|
fprintf( outfile, "\n" );
|
2002-02-04 19:48:18 +01:00
|
|
|
}
|
|
|
|
}
|
2002-05-14 22:54:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* BuildDebugFile
|
|
|
|
*
|
|
|
|
* Build the debugging channels source file.
|
|
|
|
*/
|
2002-08-01 20:34:12 +02:00
|
|
|
void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv )
|
2002-05-14 22:54:58 +02:00
|
|
|
{
|
|
|
|
int nr_debug;
|
|
|
|
char *prefix, *p;
|
|
|
|
|
2003-03-18 06:30:54 +01:00
|
|
|
while (*argv)
|
|
|
|
{
|
|
|
|
if (!parse_debug_channels( srcdir, *argv++ )) exit(1);
|
|
|
|
}
|
2002-08-01 20:34:12 +02:00
|
|
|
|
2002-05-14 22:54:58 +02:00
|
|
|
output_standard_file_header( outfile );
|
|
|
|
nr_debug = output_debug( outfile );
|
|
|
|
if (!nr_debug)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "/* no debug channels found for this module */\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (output_file_name)
|
|
|
|
{
|
|
|
|
if ((p = strrchr( output_file_name, '/' ))) p++;
|
|
|
|
prefix = xstrdup( p ? p : output_file_name );
|
|
|
|
if ((p = strchr( prefix, '.' ))) *p = 0;
|
|
|
|
strcpy( p, make_c_identifier(p) );
|
|
|
|
}
|
|
|
|
else prefix = xstrdup( "_" );
|
|
|
|
|
|
|
|
/* Output the DLL constructor */
|
|
|
|
|
|
|
|
fprintf( outfile,
|
|
|
|
"#ifdef __GNUC__\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
"void __wine_dbg_%s_init(void) __attribute__((constructor));\n"
|
|
|
|
"void __wine_dbg_%s_fini(void) __attribute__((destructor));\n"
|
2002-05-14 22:54:58 +02:00
|
|
|
"#else\n"
|
|
|
|
"static void __asm__dummy_dll_init(void) {\n",
|
|
|
|
prefix, prefix );
|
|
|
|
|
|
|
|
#if defined(__i386__)
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("__wine_dbg_%s_init") "\\n\"\n", prefix );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("__wine_dbg_%s_fini") "\\n\"\n", prefix );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
2002-05-14 22:54:58 +02:00
|
|
|
#elif defined(__sparc__)
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("__wine_dbg_%s_init") "\\n\"\n", prefix );
|
2002-05-14 22:54:58 +02:00
|
|
|
fprintf( outfile, " \"\\tnop\\n\"\n" );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tcall " __ASM_NAME("__wine_dbg_%s_fini") "\\n\"\n", prefix );
|
2002-05-14 22:54:58 +02:00
|
|
|
fprintf( outfile, " \"\\tnop\\n\"\n" );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\t\\\".text\\\"\\n\");\n" );
|
2003-10-24 02:27:27 +02:00
|
|
|
#elif defined(__powerpc__)
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tbl " __ASM_NAME("__wine_dbg_%s_init") "\\n\"\n", prefix );
|
2002-07-05 02:20:42 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2002-07-22 22:47:11 +02:00
|
|
|
fprintf( outfile, " \"\\tbl " __ASM_NAME("__wine_dbg_%s_fini") "\\n\"\n", prefix );
|
2003-10-24 02:27:27 +02:00
|
|
|
fprintf( outfile, " \"\\t.text\\n\");\n" );
|
2002-05-14 22:54:58 +02:00
|
|
|
#else
|
|
|
|
#error You need to define the DLL constructor for your architecture
|
|
|
|
#endif
|
2004-01-08 04:36:53 +01:00
|
|
|
fprintf( outfile, "}\n#endif /* defined(__GNUC__) */\n\n" );
|
2002-05-14 22:54:58 +02:00
|
|
|
|
|
|
|
fprintf( outfile,
|
|
|
|
"void __wine_dbg_%s_init(void)\n"
|
|
|
|
"{\n"
|
|
|
|
" extern void *__wine_dbg_register( char * const *, int );\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" if (!debug_registration) debug_registration = __wine_dbg_register( debug_channels, %d );\n"
|
|
|
|
"}\n\n", prefix, nr_debug );
|
2002-05-14 22:54:58 +02:00
|
|
|
fprintf( outfile,
|
|
|
|
"void __wine_dbg_%s_fini(void)\n"
|
|
|
|
"{\n"
|
|
|
|
" extern void __wine_dbg_unregister( void* );\n"
|
|
|
|
" __wine_dbg_unregister( debug_registration );\n"
|
|
|
|
"}\n", prefix );
|
|
|
|
|
|
|
|
free( prefix );
|
|
|
|
}
|