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"
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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 );
|
|
|
|
|
2005-09-23 12:52:07 +02:00
|
|
|
fprintf( outfile, "#include \"wine/debug.h\"\n\n" );
|
|
|
|
|
2000-11-05 05:49:13 +01:00
|
|
|
for (i = 0; i < nb_debug_channels; i++)
|
2005-09-23 12:52:07 +02:00
|
|
|
fprintf( outfile, "struct __wine_debug_channel __wine_dbch_%s = { 3, \"%s\" };\n",
|
2000-11-05 05:49:13 +01:00
|
|
|
debug_channels[i], debug_channels[i] );
|
|
|
|
|
2005-09-23 12:52:07 +02:00
|
|
|
fprintf( outfile, "\nstatic struct __wine_debug_channel * const debug_channels[%d] =\n{\n",
|
|
|
|
nb_debug_channels );
|
2000-11-05 05:49:13 +01:00
|
|
|
for (i = 0; i < nb_debug_channels; i++)
|
|
|
|
{
|
2005-09-23 12:52:07 +02:00
|
|
|
fprintf( outfile, " &__wine_dbch_%s", debug_channels[i] );
|
2000-11-05 05:49:13 +01:00
|
|
|
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.
|
|
|
|
*/
|
2005-06-06 17:59:50 +02:00
|
|
|
static void output_exports( FILE *outfile, DLLSPEC *spec )
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2005-06-06 17:59:50 +02:00
|
|
|
int i, fwd_size = 0;
|
|
|
|
int nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2005-06-06 17:59:50 +02:00
|
|
|
if (!nr_exports) return;
|
2000-12-11 04:42:20 +01:00
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n/* export table */\n\n" );
|
|
|
|
fprintf( outfile, "\t.data\n" );
|
|
|
|
fprintf( outfile, "\t.align %d\n", get_alignment(4) );
|
|
|
|
fprintf( outfile, ".L__wine_spec_exports:\n" );
|
2000-12-11 04:42:20 +01:00
|
|
|
|
|
|
|
/* export directory header */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* Characteristics */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* TimeDateStamp */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* MajorVersion/MinorVersion */
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_exp_names-.L__wine_spec_rva_base\n" ); /* Name */
|
|
|
|
fprintf( outfile, "\t.long %u\n", spec->base ); /* Base */
|
|
|
|
fprintf( outfile, "\t.long %u\n", nr_exports ); /* NumberOfFunctions */
|
|
|
|
fprintf( outfile, "\t.long %u\n", spec->nb_names ); /* NumberOfNames */
|
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_exports_funcs-.L__wine_spec_rva_base\n" ); /* AddressOfFunctions */
|
2004-02-11 07:41:01 +01:00
|
|
|
if (spec->nb_names)
|
2000-06-23 22:15:35 +02:00
|
|
|
{
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_exp_name_ptrs-.L__wine_spec_rva_base\n" ); /* AddressOfNames */
|
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_exp_ordinals-.L__wine_spec_rva_base\n" ); /* AddressOfNameOrdinals */
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* AddressOfNames */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* AddressOfNameOrdinals */
|
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
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n.L__wine_spec_exports_funcs:\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];
|
2005-09-15 17:01:30 +02:00
|
|
|
if (!odp) fprintf( outfile, "\t.long 0\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:
|
2005-09-19 19:04:43 +02:00
|
|
|
if (odp->flags & FLAG_FORWARD)
|
2002-12-15 02:22:40 +01:00
|
|
|
{
|
2005-09-19 19:04:43 +02:00
|
|
|
fprintf( outfile, "\t%s .L__wine_spec_forwards+%u\n", get_asm_ptr_keyword(), fwd_size );
|
|
|
|
fwd_size += strlen(odp->link_name) + 1;
|
|
|
|
}
|
|
|
|
else if (odp->flags & FLAG_EXT_LINK)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "\t%s %s_%s\n",
|
|
|
|
get_asm_ptr_keyword(), asm_name("__wine_spec_ext_link"), odp->link_name );
|
2002-12-15 02:22:40 +01:00
|
|
|
}
|
2003-03-17 05:56:10 +01:00
|
|
|
else
|
|
|
|
{
|
2005-09-19 19:04:43 +02:00
|
|
|
fprintf( outfile, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp->link_name) );
|
2003-03-17 05:56:10 +01:00
|
|
|
}
|
2000-06-23 22:15:35 +02:00
|
|
|
break;
|
|
|
|
case TYPE_STUB:
|
2005-09-19 19:04:43 +02:00
|
|
|
fprintf( outfile, "\t%s %s\n", get_asm_ptr_keyword(),
|
2005-09-21 12:57:04 +02:00
|
|
|
asm_name( get_stub_name( odp, spec )) );
|
2000-06-23 22:15:35 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n.L__wine_spec_exp_name_ptrs:\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
|
|
|
{
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_exp_names+%u-.L__wine_spec_rva_base\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
|
|
|
}
|
2000-12-11 04:42:20 +01:00
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
/* output the function ordinals */
|
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n.L__wine_spec_exp_ordinals:\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
|
|
|
{
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s %d\n",
|
2005-06-29 22:18:58 +02:00
|
|
|
get_asm_short_keyword(), spec->names[i]->ordinal - spec->base );
|
2000-12-11 04:42:20 +01:00
|
|
|
}
|
2004-02-11 07:41:01 +01:00
|
|
|
if (spec->nb_names % 2)
|
2000-12-11 04:42:20 +01:00
|
|
|
{
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0\n", get_asm_short_keyword() );
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-23 22:08:37 +02:00
|
|
|
/* output the export name strings */
|
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n.L__wine_spec_exp_names:\n" );
|
|
|
|
fprintf( outfile, "\t%s \"%s\"\n", get_asm_string_keyword(), spec->file_name );
|
2005-08-23 22:08:37 +02:00
|
|
|
for (i = 0; i < spec->nb_names; i++)
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s \"%s\"\n",
|
2005-08-23 22:08:37 +02:00
|
|
|
get_asm_string_keyword(), spec->names[i]->name );
|
|
|
|
|
2000-12-11 04:42:20 +01:00
|
|
|
/* output forward strings */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
if (fwd_size)
|
|
|
|
{
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n.L__wine_spec_forwards:\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))
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s \"%s\"\n", get_asm_string_keyword(), odp->link_name );
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.align %d\n", get_alignment(4) );
|
|
|
|
fprintf( outfile, ".L__wine_spec_exports_end:\n" );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
/* output relays */
|
|
|
|
|
2005-07-05 14:52:57 +02:00
|
|
|
/* we only support relay debugging on i386 */
|
|
|
|
if (target_cpu == CPU_x86)
|
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;
|
2000-11-28 00:48:08 +01:00
|
|
|
|
2005-02-10 20:19:35 +01:00
|
|
|
/* skip nonexistent entry points */
|
2000-11-28 00:48:08 +01:00
|
|
|
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
|
|
|
|
2005-09-08 13:35:19 +02:00
|
|
|
args = strlen(odp->u.func.arg_types) * get_ptr_size();
|
2001-12-15 00:14:22 +01:00
|
|
|
|
2000-11-28 00:48:08 +01:00
|
|
|
switch(odp->type)
|
|
|
|
{
|
|
|
|
case TYPE_STDCALL:
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\tjmp %s\n", asm_name(odp->link_name) );
|
|
|
|
fprintf( outfile, "\tret $%d\n", args );
|
|
|
|
fprintf( outfile, "\t.long %s,0x%08x\n", asm_name(odp->link_name), mask );
|
2000-11-28 00:48:08 +01:00
|
|
|
break;
|
|
|
|
case TYPE_CDECL:
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\tjmp %s\n", asm_name(odp->link_name) );
|
|
|
|
fprintf( outfile, "\tret\n" );
|
|
|
|
fprintf( outfile, "\t%s %d\n", get_asm_short_keyword(), args );
|
|
|
|
fprintf( outfile, "\t.long %s,0x%08x\n", asm_name(odp->link_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:
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0,0,0,0\n" );
|
2000-11-28 00:48:08 +01:00
|
|
|
}
|
2000-06-23 22:15:35 +02:00
|
|
|
}
|
2005-09-15 17:01:30 +02:00
|
|
|
else fprintf( outfile, "\t.long 0\n" );
|
2000-06-23 22:15:35 +02: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 )
|
|
|
|
{
|
2005-06-27 13:23:24 +02:00
|
|
|
if (target_platform == PLATFORM_APPLE)
|
2002-06-15 01:42:53 +02:00
|
|
|
{
|
2005-06-27 13:23:24 +02:00
|
|
|
/* 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" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\t.long %s\\n\"\n", asm_name(constructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.text\\n\");\n" );
|
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.mod_term_func\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.align 2\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\t.long %s\\n\"\n", asm_name(destructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.text\\n\");\n" );
|
|
|
|
}
|
2004-10-18 23:27:52 +02:00
|
|
|
}
|
2005-06-27 13:23:24 +02:00
|
|
|
else switch(target_cpu)
|
2004-10-18 23:27:52 +02:00
|
|
|
{
|
2005-06-27 13:23:24 +02:00
|
|
|
case CPU_x86:
|
2005-09-07 15:31:37 +02:00
|
|
|
case CPU_x86_64:
|
2005-06-27 13:23:24 +02:00
|
|
|
if (constructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tcall %s\\n\"\n", asm_name(constructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tcall %s\\n\"\n", asm_name(destructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CPU_SPARC:
|
|
|
|
if (constructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tcall %s\\n\"\n", asm_name(constructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\tnop\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tcall %s\\n\"\n", asm_name(destructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\tnop\\n\"\n" );
|
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CPU_ALPHA:
|
|
|
|
if (constructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tjsr $26,%s\\n\"\n", asm_name(constructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tjsr $26,%s\\n\"\n", asm_name(destructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CPU_POWERPC:
|
|
|
|
if (constructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tbl %s\\n\"\n", asm_name(constructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
if (destructor)
|
|
|
|
{
|
|
|
|
fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" );
|
2005-06-27 20:59:54 +02:00
|
|
|
fprintf( outfile, " \"\\tbl %s\\n\"\n", asm_name(destructor) );
|
2005-06-27 13:23:24 +02:00
|
|
|
fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" );
|
|
|
|
}
|
|
|
|
break;
|
2004-10-18 23:27:52 +02:00
|
|
|
}
|
2002-06-15 01:42:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_asm_constructor
|
|
|
|
*
|
|
|
|
* Output code for calling a dll constructor.
|
|
|
|
*/
|
|
|
|
static void output_asm_constructor( FILE *outfile, const char *constructor )
|
|
|
|
{
|
|
|
|
if (target_platform == PLATFORM_APPLE)
|
|
|
|
{
|
|
|
|
/* Mach-O doesn't have an init section */
|
|
|
|
fprintf( outfile, "\n\t.mod_init_func\n" );
|
|
|
|
fprintf( outfile, "\t.align %d\n", get_alignment(4) );
|
|
|
|
fprintf( outfile, "\t.long %s\n", asm_name(constructor) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf( outfile, "\n\t.section \".init\",\"ax\"\n" );
|
|
|
|
switch(target_cpu)
|
|
|
|
{
|
|
|
|
case CPU_x86:
|
|
|
|
case CPU_x86_64:
|
|
|
|
fprintf( outfile, "\tcall %s\n", asm_name(constructor) );
|
|
|
|
break;
|
|
|
|
case CPU_SPARC:
|
|
|
|
fprintf( outfile, "\tcall %s\n", asm_name(constructor) );
|
|
|
|
fprintf( outfile, "\tnop\n" );
|
|
|
|
break;
|
|
|
|
case CPU_ALPHA:
|
|
|
|
fprintf( outfile, "\tjsr $26,%s\n", asm_name(constructor) );
|
|
|
|
break;
|
|
|
|
case CPU_POWERPC:
|
|
|
|
fprintf( outfile, "\tbl %s\n", asm_name(constructor) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2005-09-15 11:42:22 +02:00
|
|
|
int machine = 0;
|
2005-06-27 13:23:24 +02:00
|
|
|
unsigned int page_size = get_page_size();
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
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 */
|
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.text\n" );
|
|
|
|
fprintf( outfile, "\t.align %d\n", get_alignment(page_size) );
|
|
|
|
fprintf( outfile, "__wine_spec_pe_header:\n" );
|
2005-06-27 13:23:24 +02:00
|
|
|
if (target_platform == PLATFORM_APPLE)
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.space 65536\n" );
|
2005-06-27 13:23:24 +02:00
|
|
|
else
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.skip 65536\n" );
|
2000-10-23 23:33:06 +02:00
|
|
|
|
2000-09-28 01:40:43 +02:00
|
|
|
/* Output the NT header */
|
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\n\t.data\n" );
|
|
|
|
fprintf( outfile, "\t.align %d\n", get_alignment(get_ptr_size()) );
|
2005-09-15 20:48:39 +02:00
|
|
|
fprintf( outfile, "%s\n", asm_globl("__wine_spec_nt_header") );
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, ".L__wine_spec_rva_base:\n" );
|
2005-09-07 13:44:16 +02:00
|
|
|
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0x%04x\n", IMAGE_NT_SIGNATURE ); /* Signature */
|
2005-06-27 13:23:24 +02:00
|
|
|
switch(target_cpu)
|
|
|
|
{
|
2005-09-07 13:44:16 +02:00
|
|
|
case CPU_x86: machine = IMAGE_FILE_MACHINE_I386; break;
|
2005-09-07 15:31:37 +02:00
|
|
|
case CPU_x86_64: machine = IMAGE_FILE_MACHINE_AMD64; break;
|
2005-09-07 13:44:16 +02:00
|
|
|
case CPU_POWERPC: machine = IMAGE_FILE_MACHINE_POWERPC; break;
|
|
|
|
case CPU_ALPHA: machine = IMAGE_FILE_MACHINE_ALPHA; break;
|
|
|
|
case CPU_SPARC: machine = IMAGE_FILE_MACHINE_UNKNOWN; break;
|
2005-06-27 13:23:24 +02:00
|
|
|
}
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0x%04x\n", /* Machine */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword(), machine );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0\n", /* NumberOfSections */
|
2005-09-08 13:35:19 +02:00
|
|
|
get_asm_short_keyword() );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* TimeDateStamp */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* PointerToSymbolTable */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* NumberOfSymbols */
|
|
|
|
fprintf( outfile, "\t%s %d\n", /* SizeOfOptionalHeader */
|
2005-09-08 13:35:19 +02:00
|
|
|
get_asm_short_keyword(),
|
|
|
|
get_ptr_size() == 8 ? IMAGE_SIZEOF_NT_OPTIONAL64_HEADER : IMAGE_SIZEOF_NT_OPTIONAL32_HEADER );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0x%04x\n", /* Characteristics */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword(), spec->characteristics );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0x%04x\n", /* Magic */
|
2005-09-08 13:35:19 +02:00
|
|
|
get_asm_short_keyword(),
|
|
|
|
get_ptr_size() == 8 ? IMAGE_NT_OPTIONAL_HDR64_MAGIC : IMAGE_NT_OPTIONAL_HDR32_MAGIC );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.byte 0\n" ); /* MajorLinkerVersion */
|
|
|
|
fprintf( outfile, "\t.byte 0\n" ); /* MinorLinkerVersion */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* SizeOfCode */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* SizeOfInitializedData */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* SizeOfUninitializedData */
|
2005-09-17 16:39:51 +02:00
|
|
|
/* note: we expand the AddressOfEntryPoint field on 64-bit by overwriting the BaseOfCode field */
|
|
|
|
fprintf( outfile, "\t%s %s\n", /* AddressOfEntryPoint */
|
|
|
|
get_asm_ptr_keyword(), asm_name(spec->init_func) );
|
2005-09-15 11:42:22 +02:00
|
|
|
if (get_ptr_size() == 4)
|
2005-09-17 16:39:51 +02:00
|
|
|
{
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* BaseOfCode */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* BaseOfData */
|
|
|
|
}
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s __wine_spec_pe_header\n", /* ImageBase */
|
2005-09-08 13:35:19 +02:00
|
|
|
get_asm_ptr_keyword() );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long %u\n", page_size ); /* SectionAlignment */
|
|
|
|
fprintf( outfile, "\t.long %u\n", page_size ); /* FileAlignment */
|
|
|
|
fprintf( outfile, "\t%s 1,0\n", /* Major/MinorOperatingSystemVersion */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword() );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0,0\n", /* Major/MinorImageVersion */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword() );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s %u,%u\n", /* Major/MinorSubsystemVersion */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword(), spec->subsystem_major, spec->subsystem_minor );
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* Win32VersionValue */
|
|
|
|
fprintf( outfile, "\t.long %s-.L__wine_spec_rva_base\n", /* SizeOfImage */
|
2005-09-07 13:44:16 +02:00
|
|
|
asm_name("_end") );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long %u\n", page_size ); /* SizeOfHeaders */
|
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* CheckSum */
|
|
|
|
fprintf( outfile, "\t%s 0x%04x\n", /* Subsystem */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword(), spec->subsystem );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s 0\n", /* DllCharacteristics */
|
2005-09-07 13:44:16 +02:00
|
|
|
get_asm_short_keyword() );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s %u,%u\n", /* SizeOfStackReserve/Commit */
|
2005-09-08 13:35:19 +02:00
|
|
|
get_asm_ptr_keyword(), (spec->stack_size ? spec->stack_size : 1024) * 1024, page_size );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s %u,%u\n", /* SizeOfHeapReserve/Commit */
|
2005-09-08 13:35:19 +02:00
|
|
|
get_asm_ptr_keyword(), (spec->heap_size ? spec->heap_size : 1024) * 1024, page_size );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0\n" ); /* LoaderFlags */
|
|
|
|
fprintf( outfile, "\t.long 16\n" ); /* NumberOfRvaAndSizes */
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2005-09-08 13:35:19 +02:00
|
|
|
if (spec->base <= spec->limit) /* DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT] */
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_exports-.L__wine_spec_rva_base,"
|
|
|
|
".L__wine_spec_exports_end-.L__wine_spec_exports\n" );
|
2005-09-07 13:44:16 +02:00
|
|
|
else
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0,0\n" );
|
2005-09-07 13:44:16 +02:00
|
|
|
|
2005-09-08 13:35:19 +02:00
|
|
|
if (has_imports()) /* DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] */
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_imports-.L__wine_spec_rva_base,"
|
|
|
|
".L__wine_spec_imports_end-.L__wine_spec_imports\n" );
|
2005-09-07 13:44:16 +02:00
|
|
|
else
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0,0\n" );
|
2005-09-07 13:44:16 +02:00
|
|
|
|
2005-09-15 11:42:22 +02:00
|
|
|
if (spec->nb_resources) /* DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE] */
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.long .L__wine_spec_resources-.L__wine_spec_rva_base,"
|
|
|
|
".L__wine_spec_resources_end-.L__wine_spec_resources\n" );
|
2005-09-15 11:42:22 +02:00
|
|
|
else
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t.long 0,0\n" );
|
|
|
|
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[3] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[4] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[5] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[6] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[7] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[8] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[9] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[10] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[11] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[12] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[13] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[14] */
|
|
|
|
fprintf( outfile, "\t.long 0,0\n" ); /* DataDirectory[15] */
|
|
|
|
|
|
|
|
fprintf( outfile, "\n\t%s\n", get_asm_string_section() );
|
2005-09-15 20:48:39 +02:00
|
|
|
fprintf( outfile, "%s\n", asm_globl("__wine_spec_file_name") );
|
2005-09-21 12:57:04 +02:00
|
|
|
fprintf( outfile, ".L__wine_spec_file_name:\n" );
|
2005-09-15 17:01:30 +02:00
|
|
|
fprintf( outfile, "\t%s \"%s\"\n", get_asm_string_keyword(), spec->file_name );
|
2005-09-15 11:42:22 +02:00
|
|
|
if (target_platform == PLATFORM_APPLE)
|
2005-09-17 16:39:51 +02:00
|
|
|
fprintf( outfile, "\t.lcomm %s,4\n", asm_name("_end") );
|
2005-09-14 21:18:05 +02:00
|
|
|
|
2005-09-14 17:49:45 +02:00
|
|
|
output_stubs( outfile, spec );
|
2005-06-06 17:59:50 +02:00
|
|
|
output_exports( outfile, spec );
|
2005-09-03 17:39:13 +02:00
|
|
|
output_imports( outfile, spec );
|
2005-09-15 11:42:22 +02:00
|
|
|
output_resources( outfile, spec );
|
2005-09-15 17:01:30 +02:00
|
|
|
output_asm_constructor( outfile, "__wine_spec_init_ctor" );
|
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;
|
2005-07-26 20:57:19 +02:00
|
|
|
int i, total;
|
2002-02-04 19:48:18 +01:00
|
|
|
|
2005-03-15 16:42:32 +01:00
|
|
|
if (spec_file_name)
|
|
|
|
fprintf( outfile, "; File generated automatically from %s; do not edit!\n\n",
|
|
|
|
spec_file_name );
|
|
|
|
else
|
|
|
|
fprintf( outfile, "; File generated automatically; do not edit!\n\n" );
|
2002-02-04 19:48:18 +01:00
|
|
|
|
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 */
|
|
|
|
|
2005-07-26 20:57:19 +02:00
|
|
|
for (i = total = 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-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;
|
|
|
|
|
2005-07-26 20:57:19 +02:00
|
|
|
if (!(odp->flags & FLAG_PRIVATE)) total++;
|
|
|
|
|
|
|
|
if (odp->type == TYPE_STUB) continue;
|
|
|
|
|
2002-07-28 19:54:31 +02:00
|
|
|
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:
|
|
|
|
{
|
2005-09-08 13:35:19 +02:00
|
|
|
int at_param = strlen(odp->u.func.arg_types) * get_ptr_size();
|
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
|
|
|
}
|
2005-07-26 20:57:19 +02:00
|
|
|
if (!total) warning( "%s: Import library doesn't export anything\n", spec->file_name );
|
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;
|
2005-06-10 21:56:05 +02:00
|
|
|
char *prefix, *p, *constructor, *destructor;
|
2002-05-14 22:54:58 +02:00
|
|
|
|
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 */
|
|
|
|
|
2005-06-10 21:56:05 +02:00
|
|
|
constructor = xmalloc( strlen(prefix) + 17 );
|
|
|
|
destructor = xmalloc( strlen(prefix) + 17 );
|
|
|
|
sprintf( constructor, "__wine_dbg_%s_init", prefix );
|
|
|
|
sprintf( destructor, "__wine_dbg_%s_fini", prefix );
|
2002-05-14 22:54:58 +02:00
|
|
|
fprintf( outfile,
|
|
|
|
"#ifdef __GNUC__\n"
|
2005-06-10 21:56:05 +02:00
|
|
|
"void %s(void) __attribute__((constructor));\n"
|
|
|
|
"void %s(void) __attribute__((destructor));\n"
|
2002-05-14 22:54:58 +02:00
|
|
|
"#else\n"
|
|
|
|
"static void __asm__dummy_dll_init(void) {\n",
|
2005-06-10 21:56:05 +02:00
|
|
|
constructor, destructor );
|
|
|
|
output_dll_init( outfile, constructor, destructor );
|
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,
|
2005-06-10 21:56:05 +02:00
|
|
|
"void %s(void)\n"
|
2002-05-14 22:54:58 +02:00
|
|
|
"{\n"
|
2005-09-23 12:52:07 +02:00
|
|
|
" extern void *__wine_dbg_register( struct __wine_debug_channel * const *, int );\n"
|
2004-01-08 04:36:53 +01:00
|
|
|
" if (!debug_registration) debug_registration = __wine_dbg_register( debug_channels, %d );\n"
|
2005-06-10 21:56:05 +02:00
|
|
|
"}\n\n", constructor, nr_debug );
|
2002-05-14 22:54:58 +02:00
|
|
|
fprintf( outfile,
|
2005-06-10 21:56:05 +02:00
|
|
|
"void %s(void)\n"
|
2002-05-14 22:54:58 +02:00
|
|
|
"{\n"
|
|
|
|
" extern void __wine_dbg_unregister( void* );\n"
|
|
|
|
" __wine_dbg_unregister( debug_registration );\n"
|
2005-06-10 21:56:05 +02:00
|
|
|
"}\n", destructor );
|
2002-05-14 22:54:58 +02:00
|
|
|
|
2005-06-10 21:56:05 +02:00
|
|
|
free( constructor );
|
|
|
|
free( destructor );
|
2002-05-14 22:54:58 +02:00
|
|
|
free( prefix );
|
|
|
|
}
|