Author: akhaldi
Date: Fri Jul 30 22:10:00 2010
New Revision: 48373
URL:
http://svn.reactos.org/svn/reactos?rev=48373&view=rev
Log:
[CMAKE]
- CMake is awesome, unlike rbuild, and can work with vanilla winebuild.
- Dedicated to Richard.
Removed:
branches/cmake-bringup/tools/winebuild/ros_diff.patch
Modified:
branches/cmake-bringup/tools/winebuild/CMakeLists.txt
branches/cmake-bringup/tools/winebuild/Makefile.in
branches/cmake-bringup/tools/winebuild/build.h
branches/cmake-bringup/tools/winebuild/import.c
branches/cmake-bringup/tools/winebuild/main.c
branches/cmake-bringup/tools/winebuild/parser.c
branches/cmake-bringup/tools/winebuild/relay.c
branches/cmake-bringup/tools/winebuild/res32.c
branches/cmake-bringup/tools/winebuild/spec16.c
branches/cmake-bringup/tools/winebuild/spec32.c
branches/cmake-bringup/tools/winebuild/utils.c
branches/cmake-bringup/tools/winebuild/winebuild.man.in
Modified: branches/cmake-bringup/tools/winebuild/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/C…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/CMakeLists.txt [iso-8859-1] Fri Jul 30 22:10:00
2010
@@ -1,3 +1,5 @@
+
+add_definitions(-DEXEEXT=".exe")
file(GLOB_RECURSE SOURCE "*.c")
Modified: branches/cmake-bringup/tools/winebuild/Makefile.in
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/M…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/Makefile.in [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/Makefile.in [iso-8859-1] Fri Jul 30 22:10:00
2010
@@ -35,5 +35,3 @@
uninstall::
$(RM) $(DESTDIR)$(bindir)/winebuild$(EXEEXT)
$(DESTDIR)$(mandir)/man$(prog_manext)/winebuild.$(prog_manext)
-
-@DEPENDENCIES@ # everything below this line is overwritten by make depend
Modified: branches/cmake-bringup/tools/winebuild/build.h
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/b…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/build.h [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/build.h [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -38,8 +38,6 @@
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
-#define EXEEXT ".exe"
-
typedef enum
{
TYPE_VARIABLE, /* variable */
@@ -49,7 +47,6 @@
TYPE_STDCALL, /* stdcall function (Win32) */
TYPE_CDECL, /* cdecl function (Win32) */
TYPE_VARARGS, /* varargs function (Win32) */
- TYPE_FASTCALL, /* fastcall function (Win32) */
TYPE_EXTERN, /* external symbol (Win32) */
TYPE_NBTYPES
} ORD_TYPE;
@@ -149,6 +146,7 @@
#define FLAG_FORWARD 0x100 /* function is a forwarded name */
#define FLAG_EXT_LINK 0x200 /* function links to an external symbol */
+#define FLAG_EXPORT32 0x400 /* 32-bit export in 16-bit spec file */
#define FLAG_CPU(cpu) (0x01000 << (cpu))
#define FLAG_CPU_MASK (FLAG_CPU(CPU_LAST + 1) - FLAG_CPU(0))
@@ -211,10 +209,12 @@
__attribute__ ((__format__ (__printf__, 1, 2)));
extern int output( const char *format, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
+extern void output_cfi( const char *format, ... )
+ __attribute__ ((__format__ (__printf__, 1, 2)));
+extern char *find_tool( const char *name, const char * const *names );
extern const char *get_as_command(void);
extern const char *get_ld_command(void);
extern const char *get_nm_command(void);
-extern const char *get_windres_command(void);
extern char *get_temp_file_name( const char *prefix, const char *suffix );
extern void output_standard_file_header(void);
extern FILE *open_input_file( const char *srcdir, const char *name );
@@ -246,18 +246,21 @@
extern void add_ignore_symbol( const char *name );
extern void add_extra_ld_symbol( const char *name );
extern void read_undef_symbols( DLLSPEC *spec, char **argv );
-extern int resolve_imports( DLLSPEC *spec );
+extern void resolve_imports( DLLSPEC *spec );
+extern int is_undefined( const char *name );
extern int has_imports(void);
extern int has_relays( DLLSPEC *spec );
extern void output_get_pc_thunk(void);
extern void output_module( DLLSPEC *spec );
extern void output_stubs( DLLSPEC *spec );
extern void output_imports( DLLSPEC *spec );
+extern void output_import_lib( DLLSPEC *spec, char **argv );
extern void output_exports( DLLSPEC *spec );
extern int load_res32_file( const char *name, DLLSPEC *spec );
extern void output_resources( DLLSPEC *spec );
extern void output_bin_resources( DLLSPEC *spec, unsigned int start_rva );
extern void output_fake_module( DLLSPEC *spec );
+extern void output_def_file( DLLSPEC *spec, int include_private );
extern void load_res16_file( const char *name, DLLSPEC *spec );
extern void output_res16_data( DLLSPEC *spec );
extern void output_bin_res16_data( DLLSPEC *spec );
@@ -266,13 +269,10 @@
extern void output_spec16_file( DLLSPEC *spec );
extern void output_fake_module16( DLLSPEC *spec16 );
extern void output_res_o_file( DLLSPEC *spec );
-
-extern void BuildRelays16(void);
-extern void BuildRelays32(void);
-extern void BuildSpec16File( DLLSPEC *spec );
+extern void output_asm_relays(void);
+extern void output_asm_relays16(void);
+
extern void BuildSpec32File( DLLSPEC *spec );
-extern void BuildDef32File( DLLSPEC *spec );
-extern void BuildPedllFile( DLLSPEC *spec );
extern void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 );
extern int parse_spec_file( FILE *file, DLLSPEC *spec );
@@ -315,6 +315,7 @@
extern int save_temps;
extern int link_ext_symbols;
extern int force_pointer_size;
+extern int unwind_tables;
extern char *input_file_name;
extern char *spec_file_name;
Modified: branches/cmake-bringup/tools/winebuild/import.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/i…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/import.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/import.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -466,7 +466,7 @@
for (i = 0; i < spec->nb_entry_points; i++)
{
ORDDEF *odp = &spec->entry_points[i];
- if (odp->type == TYPE_STUB || odp->type == TYPE_ABS) continue;
+ if (odp->type == TYPE_STUB || odp->type == TYPE_ABS || odp->type ==
TYPE_VARIABLE) continue;
if (odp->flags & FLAG_FORWARD) continue;
if (find_name( odp->link_name, &undef_symbols ))
{
@@ -508,7 +508,7 @@
for (i = 0; i < spec->nb_entry_points; i++)
{
ORDDEF *odp = &spec->entry_points[i];
- if (odp->type == TYPE_STUB || odp->type == TYPE_ABS) continue;
+ if (odp->type == TYPE_STUB || odp->type == TYPE_ABS || odp->type ==
TYPE_VARIABLE) continue;
if (odp->flags & FLAG_FORWARD) continue;
fprintf( f, "\t%s %s\n", get_asm_ptr_keyword(),
asm_name(odp->link_name) );
}
@@ -585,7 +585,7 @@
}
/* resolve the imports for a Win32 module */
-int resolve_imports( DLLSPEC *spec )
+void resolve_imports( DLLSPEC *spec )
{
int i;
unsigned int j, removed;
@@ -628,8 +628,12 @@
sort_names( &undef_symbols );
check_undefined_exports( spec );
-
- return 1;
+}
+
+/* check if symbol is still undefined */
+int is_undefined( const char *name )
+{
+ return find_name( name, &undef_symbols ) != NULL;
}
/* output the get_pc thunk if needed */
@@ -641,9 +645,10 @@
output( "\t.align %d\n", get_alignment(4) );
output( "\t%s\n",
func_declaration("__wine_spec_get_pc_thunk_eax") );
output( "%s:\n", asm_name("__wine_spec_get_pc_thunk_eax") );
- output( "\tpopl %%eax\n" );
- output( "\tpushl %%eax\n" );
+ output_cfi( ".cfi_startproc" );
+ output( "\tmovl (%%esp),%%eax\n" );
output( "\tret\n" );
+ output_cfi( ".cfi_endproc" );
output_function_size( "__wine_spec_get_pc_thunk_eax" );
}
@@ -653,6 +658,7 @@
output( "\n\t.align %d\n", get_alignment(4) );
output( "\t%s\n", func_declaration(name) );
output( "%s\n", asm_globl(name) );
+ output_cfi( ".cfi_startproc" );
switch(target_cpu)
{
@@ -668,9 +674,7 @@
}
break;
case CPU_x86_64:
- output( "\t.cfi_startproc\n" );
output( "\tjmpq *%s+%d(%%rip)\n", table, pos );
- output( "\t.cfi_endproc\n" );
break;
case CPU_SPARC:
if ( !UsePIC )
@@ -721,6 +725,7 @@
output( "\tbctr\n" );
break;
}
+ output_cfi( ".cfi_endproc" );
output_function_size( name );
}
@@ -964,21 +969,27 @@
output( "%s:\n", asm_name(delayed_import_loaders));
output( "\t%s\n", func_declaration("__wine_delay_load_asm") );
output( "%s:\n", asm_name("__wine_delay_load_asm") );
+ output_cfi( ".cfi_startproc" );
switch(target_cpu)
{
case CPU_x86:
output( "\tpushl %%ecx\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
output( "\tpushl %%edx\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
output( "\tpushl %%eax\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
output( "\tcall %s\n", asm_name("__wine_spec_delay_load") );
+ output_cfi( ".cfi_adjust_cfa_offset -4" );
output( "\tpopl %%edx\n" );
+ output_cfi( ".cfi_adjust_cfa_offset -4" );
output( "\tpopl %%ecx\n" );
+ output_cfi( ".cfi_adjust_cfa_offset -4" );
output( "\tjmp *%%eax\n" );
break;
case CPU_x86_64:
- output( "\t.cfi_startproc\n" );
output( "\tsubq $88,%%rsp\n" );
- output( "\t.cfi_adjust_cfa_offset 88\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 88" );
output( "\tmovq %%rdx,80(%%rsp)\n" );
output( "\tmovq %%rcx,72(%%rsp)\n" );
output( "\tmovq %%r8,64(%%rsp)\n" );
@@ -994,9 +1005,8 @@
output( "\tmovq 72(%%rsp),%%rcx\n" );
output( "\tmovq 80(%%rsp),%%rdx\n" );
output( "\taddq $88,%%rsp\n" );
- output( "\t.cfi_adjust_cfa_offset -88\n" );
+ output_cfi( ".cfi_adjust_cfa_offset -88" );
output( "\tjmp *%%rax\n" );
- output( "\t.cfi_endproc\n" );
break;
case CPU_SPARC:
output( "\tsave %%sp, -96, %%sp\n" );
@@ -1064,6 +1074,7 @@
output( "\tbctr\n");
break;
}
+ output_cfi( ".cfi_endproc" );
output_function_size( "__wine_delay_load_asm" );
output( "\n" );
@@ -1076,6 +1087,7 @@
const char *name = odp->name ? odp->name : odp->export_name;
output( ".L__wine_delay_imp_%d_%s:\n", i, name );
+ output_cfi( ".cfi_startproc" );
switch(target_cpu)
{
case CPU_x86:
@@ -1083,10 +1095,8 @@
output( "\tjmp %s\n",
asm_name("__wine_delay_load_asm") );
break;
case CPU_x86_64:
- output( "\t.cfi_startproc\n" );
output( "\tmovq $%d,%%rax\n", (idx << 16) | j );
output( "\tjmp %s\n",
asm_name("__wine_delay_load_asm") );
- output( "\t.cfi_endproc\n" );
break;
case CPU_SPARC:
output( "\tset %d, %%g1\n", (idx << 16) | j );
@@ -1128,6 +1138,7 @@
}
break;
}
+ output_cfi( ".cfi_endproc" );
}
idx++;
}
@@ -1210,6 +1221,7 @@
output( "\t.align %d\n", get_alignment(4) );
output( "\t%s\n", func_declaration(name) );
output( "%s:\n", asm_name(name) );
+ output_cfi( ".cfi_startproc" );
switch (target_cpu)
{
@@ -1225,7 +1237,8 @@
output(" \tnop\n" );
output(" \tnop\n" );
- output( "\tsubl $4,%%esp\n" );
+ output( "\tsubl $12,%%esp\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 12" );
if (UsePIC)
{
output( "\tcall %s\n",
asm_name("__wine_spec_get_pc_thunk_eax") );
@@ -1233,31 +1246,30 @@
if (exp_name)
{
output( "\tleal .L%s_string-1b(%%eax),%%ecx\n", name );
- output( "\tpushl %%ecx\n" );
+ output( "\tmovl %%ecx,4(%%esp)\n" );
count++;
}
else
- output( "\tpushl $%d\n", odp->ordinal );
+ output( "\tmovl $%d,4(%%esp)\n", odp->ordinal );
output( "\tleal .L__wine_spec_file_name-1b(%%eax),%%ecx\n" );
- output( "\tpushl %%ecx\n" );
+ output( "\tmovl %%ecx,(%%esp)\n" );
}
else
{
if (exp_name)
{
- output( "\tpushl $.L%s_string\n", name );
+ output( "\tmovl $.L%s_string,4(%%esp)\n", name );
count++;
}
else
- output( "\tpushl $%d\n", odp->ordinal );
- output( "\tpushl $.L__wine_spec_file_name\n" );
+ output( "\tmovl $%d,4(%%esp)\n", odp->ordinal );
+ output( "\tmovl $.L__wine_spec_file_name,(%%esp)\n" );
}
output( "\tcall %s\n",
asm_name("__wine_spec_unimplemented_stub") );
break;
case CPU_x86_64:
- output( "\t.cfi_startproc\n" );
output( "\tsubq $8,%%rsp\n" );
- output( "\t.cfi_adjust_cfa_offset 8\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 8" );
output( "\tleaq .L__wine_spec_file_name(%%rip),%%rdi\n" );
if (exp_name)
{
@@ -1267,11 +1279,11 @@
else
output( "\tmovq $%d,%%rsi\n", odp->ordinal );
output( "\tcall %s\n",
asm_name("__wine_spec_unimplemented_stub") );
- output( "\t.cfi_endproc\n" );
break;
default:
assert(0);
}
+ output_cfi( ".cfi_endproc" );
output_function_size( name );
}
@@ -1304,3 +1316,52 @@
if (nb_imports || ext_link_imports.count || has_stubs(spec) || has_relays(spec))
output_get_pc_thunk();
}
+
+/* output an import library for a Win32 module and additional object files */
+void output_import_lib( DLLSPEC *spec, char **argv )
+{
+ char *dlltool, *def_file;
+ char *cmd;
+ int err;
+
+ if (target_platform != PLATFORM_WINDOWS)
+ fatal_error( "Unix-style import libraries not supported yet\n" );
+
+ def_file = get_temp_file_name( output_file_name, ".def" );
+ fclose( output_file );
+ if (!(output_file = fopen( def_file, "w" )))
+ fatal_error( "Unable to create output file '%s'\n", def_file
);
+ output_def_file( spec, 0 );
+ fclose( output_file );
+ output_file = NULL;
+
+ dlltool = find_tool( "dlltool", NULL );
+ cmd = xmalloc( strlen(dlltool) + strlen(output_file_name) + strlen(def_file) + 12 );
+ sprintf( cmd, "%s -k -l %s -d %s", dlltool, output_file_name, def_file );
+ if (verbose) fprintf( stderr, "%s\n", cmd );
+ err = system( cmd );
+ if (err) fatal_error( "%s failed with status %d\n", dlltool, err );
+ free( cmd );
+ free( dlltool );
+
+ if (argv[0])
+ {
+ char *ar = find_tool( "ar", NULL );
+ int i, len;
+
+ for (i = len = 0; argv[i]; i++) len += strlen(argv[i]) + 1;
+ cmd = xmalloc( strlen(ar) + strlen(output_file_name) + len + 5 );
+ sprintf( cmd, "%s rs %s", ar, output_file_name );
+ for (i = 0; argv[i]; i++)
+ {
+ strcat( cmd, " " );
+ strcat( cmd, argv[i] );
+ }
+ if (verbose) fprintf( stderr, "%s\n", cmd );
+ err = system( cmd );
+ if (err) fatal_error( "%s failed with status %d\n", dlltool, err );
+ free( cmd );
+ free( ar );
+ }
+ output_file_name = NULL;
+}
Modified: branches/cmake-bringup/tools/winebuild/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/m…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/main.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/main.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -47,10 +47,11 @@
int save_temps = 0;
int link_ext_symbols = 0;
int force_pointer_size = 0;
-
-#if defined(TARGET_i386)
+int unwind_tables = 0;
+
+#ifdef __i386__
enum target_cpu target_cpu = CPU_x86;
-#elif defined(TARGET_amd64)
+#elif defined(__x86_64__)
enum target_cpu target_cpu = CPU_x86_64;
#elif defined(__sparc__)
enum target_cpu target_cpu = CPU_SPARC;
@@ -58,7 +59,7 @@
enum target_cpu target_cpu = CPU_ALPHA;
#elif defined(__powerpc__)
enum target_cpu target_cpu = CPU_POWERPC;
-#elif defined(TARGET_arm)
+#elif defined(__arm__)
enum target_cpu target_cpu = CPU_ARM;
#else
#error Unsupported CPU
@@ -100,10 +101,8 @@
MODE_DLL,
MODE_EXE,
MODE_DEF,
- MODE_RELAY16,
- MODE_RELAY32,
- MODE_RESOURCES,
- MODE_PEDLL
+ MODE_IMPLIB,
+ MODE_RESOURCES
};
static enum exec_mode_values exec_mode = MODE_NONE;
@@ -118,6 +117,7 @@
{ "darwin", PLATFORM_APPLE },
{ "freebsd", PLATFORM_FREEBSD },
{ "solaris", PLATFORM_SOLARIS },
+ { "mingw32", PLATFORM_WINDOWS },
{ "windows", PLATFORM_WINDOWS },
{ "winnt", PLATFORM_WINDOWS }
};
@@ -136,6 +136,23 @@
if ((p = strrchr( spec->file_name, '.' )))
{
if (!strcmp( p, ".spec" ) || !strcmp( p, ".def" )) *p = 0;
+ }
+}
+
+/* set the dll name from the file name */
+static void init_dll_name( DLLSPEC *spec )
+{
+ if (!spec->file_name)
+ {
+ char *p;
+ spec->file_name = xstrdup( output_file_name );
+ if ((p = strrchr( spec->file_name, '.' ))) *p = 0;
+ }
+ if (!spec->dll_name) /* set default name from file name */
+ {
+ char *p;
+ spec->dll_name = xstrdup( spec->file_name );
+ if ((p = strrchr( spec->dll_name, '.' ))) *p = 0;
}
}
@@ -221,7 +238,7 @@
" -e, --entry=FUNC Set the DLL entry point function (default:
DllMain)\n"
" -E, --export=FILE Export the symbols defined in the .spec or .def
file\n"
" --external-symbols Allow linking to external symbols\n"
-" -f FLAGS Compiler flags (only -fPIC is supported)\n"
+" -f FLAGS Compiler flags (-fPIC and -fasynchronous-unwind-tables
are supported)\n"
" -F, --filename=DLLFILE Set the DLL filename (default: from input file
name)\n"
" --fake-module Create a fake binary module\n"
" -h, --help Display this help message\n"
@@ -234,7 +251,7 @@
" --ld-cmd=LD Command to use for linking (default: ld)\n"
" -l, --library=LIB Import the specified library\n"
" -L, --library-path=DIR Look for imports libraries in DIR\n"
-" -m32, -m64 Force building 32-bit resp. 64-bit code\n"
+" -m16, -m32, -m64 Force building 16-bit, 32-bit resp. 64-bit
code\n"
" -M, --main-module=MODULE Set the name of the main module for a Win16
dll\n"
" --nm-cmd=NM Command to use to get undefined symbols (default:
nm)\n"
" --nxcompat=y|n Set the NX compatibility flag (default: yes)\n"
@@ -251,10 +268,8 @@
" --dll Build a .c file from a .spec or .def file\n"
" --def Build a .def file from a .spec file\n"
" --exe Build a .c file for an executable\n"
-" --relay16 Build the 16-bit relay assembly routines\n"
-" --relay32 Build the 32-bit relay assembly routines\n"
+" --implib Build an import library\n"
" --resources Build a .o file for the resource files\n\n"
-" --pedll Build a .c file for PE dll\n\n"
"The mode options are mutually exclusive; you must specify one and only
one.\n\n";
enum long_options_values
@@ -262,6 +277,7 @@
LONG_OPT_DLL = 1,
LONG_OPT_DEF,
LONG_OPT_EXE,
+ LONG_OPT_IMPLIB,
LONG_OPT_ASCMD,
LONG_OPT_EXTERNAL_SYMS,
LONG_OPT_FAKE_MODULE,
@@ -269,13 +285,10 @@
LONG_OPT_LDCMD,
LONG_OPT_NMCMD,
LONG_OPT_NXCOMPAT,
- LONG_OPT_RELAY16,
- LONG_OPT_RELAY32,
LONG_OPT_RESOURCES,
LONG_OPT_SAVE_TEMPS,
LONG_OPT_SUBSYSTEM,
- LONG_OPT_VERSION,
- LONG_OPT_PEDLL
+ LONG_OPT_VERSION
};
static const char short_options[] =
"C:D:E:F:H:I:K:L:M:N:b:d:e:f:hi:kl:m:o:r:u:vw";
@@ -285,6 +298,7 @@
{ "dll", 0, 0, LONG_OPT_DLL },
{ "def", 0, 0, LONG_OPT_DEF },
{ "exe", 0, 0, LONG_OPT_EXE },
+ { "implib", 0, 0, LONG_OPT_IMPLIB },
{ "as-cmd", 1, 0, LONG_OPT_ASCMD },
{ "external-symbols", 0, 0, LONG_OPT_EXTERNAL_SYMS },
{ "fake-module", 0, 0, LONG_OPT_FAKE_MODULE },
@@ -292,13 +306,10 @@
{ "ld-cmd", 1, 0, LONG_OPT_LDCMD },
{ "nm-cmd", 1, 0, LONG_OPT_NMCMD },
{ "nxcompat", 1, 0, LONG_OPT_NXCOMPAT },
- { "relay16", 0, 0, LONG_OPT_RELAY16 },
- { "relay32", 0, 0, LONG_OPT_RELAY32 },
{ "resources", 0, 0, LONG_OPT_RESOURCES },
{ "save-temps", 0, 0, LONG_OPT_SAVE_TEMPS },
{ "subsystem", 1, 0, LONG_OPT_SUBSYSTEM },
{ "version", 0, 0, LONG_OPT_VERSION },
- { "pedll", 1, 0, LONG_OPT_PEDLL },
/* aliases for short options */
{ "target", 1, 0, 'b' },
{ "delay-lib", 1, 0, 'd' },
@@ -371,9 +382,10 @@
lib_path[nb_lib_paths++] = xstrdup( optarg );
break;
case 'm':
- if (strcmp( optarg, "32" ) && strcmp( optarg,
"64" ))
- fatal_error( "Invalid -m option '%s', expected -m32 or
-m64\n", optarg );
- if (!strcmp( optarg, "32" )) force_pointer_size = 4;
+ if (strcmp( optarg, "16" ) && strcmp( optarg,
"32" ) && strcmp( optarg, "64" ))
+ fatal_error( "Invalid -m option '%s', expected -m16, -m32 or
-m64\n", optarg );
+ if (!strcmp( optarg, "16" )) spec->type = SPEC_WIN16;
+ else if (!strcmp( optarg, "32" )) force_pointer_size = 4;
else force_pointer_size = 8;
break;
case 'M':
@@ -394,6 +406,8 @@
break;
case 'f':
if (!strcmp( optarg, "PIC") || !strcmp( optarg, "pic"))
UsePIC = 1;
+ else if (!strcmp( optarg, "asynchronous-unwind-tables"))
unwind_tables = 1;
+ else if (!strcmp( optarg, "no-asynchronous-unwind-tables"))
unwind_tables = 0;
/* ignore all other flags */
break;
case 'h':
@@ -461,6 +475,9 @@
set_exec_mode( MODE_EXE );
if (!spec->subsystem) spec->subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
break;
+ case LONG_OPT_IMPLIB:
+ set_exec_mode( MODE_IMPLIB );
+ break;
case LONG_OPT_ASCMD:
as_command = xstrdup( optarg );
break;
@@ -483,12 +500,6 @@
if (optarg[0] == 'n' || optarg[0] == 'N')
spec->dll_characteristics &= ~IMAGE_DLLCHARACTERISTICS_NX_COMPAT;
break;
- case LONG_OPT_RELAY16:
- set_exec_mode( MODE_RELAY16 );
- break;
- case LONG_OPT_RELAY32:
- set_exec_mode( MODE_RELAY32 );
- break;
case LONG_OPT_RESOURCES:
set_exec_mode( MODE_RESOURCES );
break;
@@ -501,11 +512,6 @@
case LONG_OPT_VERSION:
printf( "winebuild version " PACKAGE_VERSION "\n" );
exit(0);
- case LONG_OPT_PEDLL:
- set_exec_mode( MODE_PEDLL );
- spec_file_name = xstrdup( optarg );
- set_dll_file_name( optarg, spec );
- break;
case '?':
usage(1);
break;
@@ -514,6 +520,7 @@
if (spec->file_name && !strchr( spec->file_name, '.' ))
strcat( spec->file_name, exec_mode == MODE_EXE ? ".exe" :
".dll" );
+ init_dll_name( spec );
switch (target_cpu)
{
@@ -615,14 +622,6 @@
case MODE_DLL:
if (spec->subsystem != IMAGE_SUBSYSTEM_NATIVE)
spec->characteristics |= IMAGE_FILE_DLL;
- if (!spec_file_name) fatal_error( "missing .spec file\n" );
- if (spec->type == SPEC_WIN32 && spec->main_module) /* embedded
16-bit module */
- {
- spec->type = SPEC_WIN16;
- load_resources( argv, spec );
- if (parse_input_file( spec )) BuildSpec16File( spec );
- break;
- }
/* fall through */
case MODE_EXE:
load_resources( argv, spec );
@@ -648,23 +647,14 @@
break;
case MODE_DEF:
if (argv[0]) fatal_error( "file argument '%s' not allowed in this
mode\n", argv[0] );
- if (spec->type == SPEC_WIN16) fatal_error( "Cannot yet build .def file
for 16-bit dlls\n" );
if (!spec_file_name) fatal_error( "missing .spec file\n" );
if (!parse_input_file( spec )) break;
- BuildDef32File( spec );
- break;
- case MODE_RELAY16:
- if (argv[0]) fatal_error( "file argument '%s' not allowed in this
mode\n", argv[0] );
- BuildRelays16();
- break;
- case MODE_RELAY32:
- if (argv[0]) fatal_error( "file argument '%s' not allowed in this
mode\n", argv[0] );
- BuildRelays32();
- break;
- case MODE_PEDLL:
- if (argv[0]) fatal_error( "file argument '%s' not allowed in this
mode\n", argv[0] );
+ output_def_file( spec, 1 );
+ break;
+ case MODE_IMPLIB:
+ if (!spec_file_name) fatal_error( "missing .spec file\n" );
if (!parse_input_file( spec )) break;
- BuildPedllFile( spec );
+ output_import_lib( spec, argv );
break;
case MODE_RESOURCES:
load_resources( argv, spec );
Modified: branches/cmake-bringup/tools/winebuild/parser.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/p…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/parser.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/parser.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -56,7 +56,6 @@
"stdcall", /* TYPE_STDCALL */
"cdecl", /* TYPE_CDECL */
"varargs", /* TYPE_VARARGS */
- "fastcall", /* TYPE_FASTCALL */
"extern" /* TYPE_EXTERN */
};
@@ -229,25 +228,17 @@
{
const char *token;
unsigned int i;
-
- switch(spec->type)
- {
- case SPEC_WIN16:
- if (odp->type == TYPE_STDCALL)
- {
- error( "'stdcall' not supported for Win16\n" );
- return 0;
- }
- break;
- case SPEC_WIN32:
- if (odp->type == TYPE_PASCAL)
- {
- error( "'pascal' not supported for Win32\n" );
- return 0;
- }
- break;
- default:
- break;
+ int is_win32 = (spec->type == SPEC_WIN32) || (odp->flags & FLAG_EXPORT32);
+
+ if (!is_win32 && odp->type == TYPE_STDCALL)
+ {
+ error( "'stdcall' not supported for Win16\n" );
+ return 0;
+ }
+ if (is_win32 && odp->type == TYPE_PASCAL)
+ {
+ error( "'pascal' not supported for Win32\n" );
+ return 0;
}
if (!(token = GetToken(0))) return 0;
@@ -289,7 +280,7 @@
return 0;
}
- if (spec->type == SPEC_WIN32)
+ if (is_win32)
{
if (strcmp(token, "long") &&
strcmp(token, "ptr") &&
@@ -297,7 +288,7 @@
strcmp(token, "wstr") &&
strcmp(token, "double"))
{
- error( "Type '%s' not supported for Win32\n", token );
+ error( "Type '%s' not supported for Win32 function\n",
token );
return 0;
}
}
@@ -326,7 +317,7 @@
odp->link_name = xstrdup( token );
if (strchr( odp->link_name, '.' ))
{
- if (spec->type == SPEC_WIN16)
+ if (!is_win32)
{
error( "Forwarded functions not supported for Win16\n" );
return 0;
@@ -422,7 +413,7 @@
*
* Parse the optional flags for an entry point in a .spec file.
*/
-static const char *parse_spec_flags( ORDDEF *odp )
+static const char *parse_spec_flags( DLLSPEC *spec, ORDDEF *odp )
{
unsigned int i;
const char *token;
@@ -437,7 +428,12 @@
while (cpu_name)
{
if (!strcmp( cpu_name, "win32" ))
- odp->flags |= FLAG_CPU_WIN32;
+ {
+ if (spec->type == SPEC_WIN32)
+ odp->flags |= FLAG_CPU_WIN32;
+ else
+ odp->flags |= FLAG_EXPORT32;
+ }
else if (!strcmp( cpu_name, "win64" ))
odp->flags |= FLAG_CPU_WIN64;
else
@@ -500,7 +496,13 @@
}
if (!(token = GetToken(0))) goto error;
- if (*token == '-' && !(token = parse_spec_flags( odp ))) goto error;
+ if (*token == '-' && !(token = parse_spec_flags( spec, odp ))) goto
error;
+
+ if (ordinal == -1 && spec->type != SPEC_WIN32 && !(odp->flags
& FLAG_EXPORT32))
+ {
+ error( "'@' ordinals not supported for Win16\n" );
+ goto error;
+ }
odp->name = xstrdup( token );
odp->lineno = current_line;
@@ -522,7 +524,6 @@
case TYPE_STDCALL:
case TYPE_VARARGS:
case TYPE_CDECL:
- case TYPE_FASTCALL:
if (!parse_spec_export( odp, spec )) goto error;
break;
case TYPE_ABS:
@@ -652,7 +653,8 @@
{
const char *name1 = all_names[i]->name ? all_names[i]->name :
all_names[i]->export_name;
const char *name2 = all_names[i+1]->name ? all_names[i+1]->name :
all_names[i+1]->export_name;
- if (!strcmp( name1, name2 ))
+ if (!strcmp( name1, name2 ) &&
+ !((all_names[i]->flags ^ all_names[i+1]->flags) & FLAG_EXPORT32))
{
current_line = max( all_names[i]->lineno, all_names[i+1]->lineno );
error( "'%s' redefined\n%s:%d: First defined here\n",
@@ -739,12 +741,21 @@
*/
void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 )
{
+ int i;
ORDDEF *odp;
+
+ spec32->file_name = xstrdup( spec16->file_name );
+ if (spec16->characteristics & IMAGE_FILE_DLL)
+ {
+ spec32->characteristics = IMAGE_FILE_DLL;
+ spec32->init_func = xstrdup( "__wine_spec_dll_entry" );
+ }
/* add an export for the NE module */
odp = add_entry_point( spec32 );
odp->type = TYPE_EXTERN;
+ odp->flags = FLAG_PRIVATE;
odp->name = xstrdup( "__wine_spec_dos_header" );
odp->lineno = 0;
odp->ordinal = 1;
@@ -754,12 +765,32 @@
{
odp = add_entry_point( spec32 );
odp->type = TYPE_EXTERN;
+ odp->flags = FLAG_PRIVATE;
odp->name = xstrdup( "__wine_spec_main_module" );
odp->lineno = 0;
odp->ordinal = 2;
odp->link_name = xstrdup( ".L__wine_spec_main_module" );
}
+ /* add the explicit win32 exports */
+
+ for (i = 1; i <= spec16->limit; i++)
+ {
+ ORDDEF *odp16 = spec16->ordinals[i];
+
+ if (!odp16 || !odp16->name) continue;
+ if (!(odp16->flags & FLAG_EXPORT32)) continue;
+
+ odp = add_entry_point( spec32 );
+ odp->flags = odp16->flags & ~FLAG_EXPORT32;
+ odp->type = odp16->type;
+ odp->name = xstrdup( odp16->name );
+ odp->lineno = odp16->lineno;
+ odp->ordinal = -1;
+ odp->link_name = xstrdup( odp16->link_name );
+ strcpy( odp->u.func.arg_types, odp16->u.func.arg_types );
+ }
+
assign_names( spec32 );
assign_ordinals( spec32 );
}
@@ -785,11 +816,6 @@
if (!(token = GetToken(1))) continue;
if (strcmp(token, "@") == 0)
{
- if (spec->type != SPEC_WIN32)
- {
- error( "'@' ordinals not supported for Win16\n" );
- continue;
- }
if (!parse_spec_ordinal( -1, spec )) continue;
}
else if (IsNumberString(token))
@@ -947,32 +973,33 @@
/* check for other optional keywords */
- if (token && !strcmp( token, "NONAME" ))
- {
- if (odp->ordinal == -1)
- {
- error( "NONAME requires an ordinal\n" );
+ while (token)
+ {
+ if (!strcmp( token, "NONAME" ))
+ {
+ if (odp->ordinal == -1)
+ {
+ error( "NONAME requires an ordinal\n" );
+ goto error;
+ }
+ odp->export_name = odp->name;
+ odp->name = NULL;
+ odp->flags |= FLAG_NONAME;
+ }
+ else if (!strcmp( token, "PRIVATE" ))
+ {
+ odp->flags |= FLAG_PRIVATE;
+ }
+ else if (!strcmp( token, "DATA" ))
+ {
+ odp->type = TYPE_EXTERN;
+ }
+ else
+ {
+ error( "Garbage text '%s' found at end of export
declaration\n", token );
goto error;
}
- odp->export_name = odp->name;
- odp->name = NULL;
- odp->flags |= FLAG_NONAME;
token = GetToken(1);
- }
- if (token && !strcmp( token, "PRIVATE" ))
- {
- odp->flags |= FLAG_PRIVATE;
- token = GetToken(1);
- }
- if (token && !strcmp( token, "DATA" ))
- {
- odp->type = TYPE_EXTERN;
- token = GetToken(1);
- }
- if (token)
- {
- error( "Garbage text '%s' found at end of export
declaration\n", token );
- goto error;
}
return 1;
Modified: branches/cmake-bringup/tools/winebuild/relay.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/r…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/relay.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/relay.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -386,13 +386,20 @@
function_header( name );
/* Function entry sequence */
+ output_cfi( ".cfi_startproc" );
output( "\tpushl %%ebp\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
+ output_cfi( ".cfi_rel_offset %%ebp,0" );
output( "\tmovl %%esp, %%ebp\n" );
+ output_cfi( ".cfi_def_cfa_register %%ebp" );
/* Save the 32-bit registers */
output( "\tpushl %%ebx\n" );
+ output_cfi( ".cfi_rel_offset %%ebx,-4" );
output( "\tpushl %%esi\n" );
+ output_cfi( ".cfi_rel_offset %%esi,-8" );
output( "\tpushl %%edi\n" );
+ output_cfi( ".cfi_rel_offset %%edi,-12" );
output( "\t.byte 0x64\n\tmov %%gs,(%d)\n", GS_OFFSET );
/* Setup exception frame */
@@ -443,12 +450,18 @@
/* Restore the 32-bit registers */
output( "\tpopl %%edi\n" );
+ output_cfi( ".cfi_same_value %%edi" );
output( "\tpopl %%esi\n" );
+ output_cfi( ".cfi_same_value %%esi" );
output( "\tpopl %%ebx\n" );
+ output_cfi( ".cfi_same_value %%ebx" );
/* Function exit sequence */
output( "\tpopl %%ebp\n" );
+ output_cfi( ".cfi_def_cfa %%esp,4" );
+ output_cfi( ".cfi_same_value %%ebp" );
output( "\tret $12\n" );
+ output_cfi( ".cfi_endproc" );
/* Start of the actual CallTo16 routine */
@@ -652,11 +665,18 @@
/* Entry code */
+ output_cfi( ".cfi_startproc" );
output( "\tpushl %%ebp\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
+ output_cfi( ".cfi_rel_offset %%ebp,0" );
output( "\tmovl %%esp,%%ebp\n" );
+ output_cfi( ".cfi_def_cfa_register %%ebp" );
output( "\tpushl %%edi\n" );
+ output_cfi( ".cfi_rel_offset %%edi,-4" );
output( "\tpushl %%esi\n" );
+ output_cfi( ".cfi_rel_offset %%esi,-8" );
output( "\tpushl %%ebx\n" );
+ output_cfi( ".cfi_rel_offset %%ebx,-12" );
/* Get pointer to temporary area and save the 32-bit stack pointer */
@@ -694,10 +714,16 @@
/* Restore registers and return */
output( "\tpopl %%ebx\n" );
+ output_cfi( ".cfi_same_value %%ebx" );
output( "\tpopl %%esi\n" );
+ output_cfi( ".cfi_same_value %%esi" );
output( "\tpopl %%edi\n" );
+ output_cfi( ".cfi_same_value %%edi" );
output( "\tpopl %%ebp\n" );
+ output_cfi( ".cfi_def_cfa %%esp,4" );
+ output_cfi( ".cfi_same_value %%ebp" );
output( "\tret\n" );
+ output_cfi( ".cfi_endproc" );
output_function_size( isEx ? "CALL32_CBClientEx" :
"CALL32_CBClient" );
/* '16-bit' return stub */
@@ -721,7 +747,7 @@
/*******************************************************************
- * BuildCallFrom32Regs
+ * build_call_from_regs_x86
*
* Build a 32-bit-to-Wine call-back function for a 'register' function.
* 'args' is the number of dword arguments.
@@ -746,18 +772,23 @@
* pointer on return (with the return address and arguments already
* removed).
*/
-static void BuildCallFrom32Regs(void)
+static void build_call_from_regs_x86(void)
{
static const int STACK_SPACE = 128 + 0x2cc /* sizeof(CONTEXT86) */;
/* Function header */
- function_header( "__wine_call_from_32_regs" );
+ output( "\t.text\n" );
+ function_header( "__wine_call_from_regs" );
/* Allocate some buffer space on the stack */
+ output_cfi( ".cfi_startproc" );
output( "\tpushl %%ebp\n" );
- output( "\tmovl %%esp,%%ebp\n ");
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
+ output_cfi( ".cfi_rel_offset %%ebp,0" );
+ output( "\tmovl %%esp,%%ebp\n" );
+ output_cfi( ".cfi_def_cfa_register %%ebp" );
output( "\tleal -%d(%%esp),%%esp\n", STACK_SPACE );
/* Build the context structure */
@@ -845,12 +876,15 @@
output( "\tpopl %%ds\n" );
output( "\tiret\n" );
- output_function_size( "__wine_call_from_32_regs" );
-
- function_header( "__wine_call_from_32_restore_regs" );
+ output_cfi( ".cfi_endproc" );
+ output_function_size( "__wine_call_from_regs" );
+
+ function_header( "__wine_restore_regs" );
+ output_cfi( ".cfi_startproc" );
output( "\tmovl 4(%%esp),%%ecx\n" );
output( "\tjmp 2b\n" );
- output_function_size( "__wine_call_from_32_restore_regs" );
+ output_cfi( ".cfi_endproc" );
+ output_function_size( "__wine_restore_regs" );
}
@@ -902,23 +936,15 @@
/*******************************************************************
- * BuildRelays16
+ * output_asm_relays16
*
* Build all the 16-bit relay callbacks
*/
-void BuildRelays16(void)
+void output_asm_relays16(void)
{
- if (target_cpu != CPU_x86)
- {
- output( "/* File not used with this architecture. Do not edit! */\n\n"
);
- return;
- }
-
/* File header */
- output( "/* File generated automatically. Do not edit! */\n\n" );
output( "\t.text\n" );
-
output( "%s:\n\n", asm_name("__wine_spec_thunk_text_16") );
output( "%s\n", asm_globl("__wine_call16_start") );
@@ -957,14 +983,11 @@
output( "\n\t.data\n\t.align %d\n", get_alignment(4) );
output( "%s\n\t.long 0\n", asm_globl("CallTo16_DataSelector") );
output( "%s\n\t.long 0\n", asm_globl("CallTo16_TebSelector") );
- if (UsePIC) output( "wine_ldt_copy_ptr:\t.long %s\n",
asm_name("wine_ldt_copy") );
output( "\t.text\n" );
- output( "%s:\n\n", asm_name("__wine_spec_thunk_text_32") );
- BuildCallFrom32Regs();
+ output( "%s:\n", asm_name("__wine_spec_thunk_text_32") );
+ build_call_from_regs_x86();
output_function_size( "__wine_spec_thunk_text_32" );
-
- output_gnu_stack_note();
}
@@ -991,48 +1014,49 @@
/* Function header */
+ output( "\t.text\n" );
function_header( "__wine_call_from_regs" );
- output( "\t.cfi_startproc\n" );
+ output_cfi( ".cfi_startproc" );
output( "\tsubq $%u,%%rsp\n", STACK_SPACE );
- output( "\t.cfi_adjust_cfa_offset %u\n", STACK_SPACE );
+ output_cfi( ".cfi_adjust_cfa_offset %u", STACK_SPACE );
/* save registers into the context */
output( "\tmovq %%rax,0x78(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%rax,0x78\n" );
+ output_cfi( ".cfi_rel_offset %%rax,0x78" );
output( "\tmovq %u(%%rsp),%%rax\n", STACK_SPACE + 16 ); /* saved %rcx on
stack */
output( "\tmovq %%rax,0x80(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%rcx,0x80\n" );
+ output_cfi( ".cfi_rel_offset %%rcx,0x80" );
output( "\tmovq %u(%%rsp),%%rax\n", STACK_SPACE + 24 ); /* saved %rdx on
stack */
- output( "\t.cfi_rel_offset %%rdx,0x88\n" );
+ output_cfi( ".cfi_rel_offset %%rdx,0x88" );
output( "\tmovq %%rax,0x88(%%rsp)\n" );
output( "\tmovq %%rbx,0x90(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%rbx,0x90\n" );
+ output_cfi( ".cfi_rel_offset %%rbx,0x90" );
output( "\tleaq %u(%%rsp),%%rax\n", STACK_SPACE + 16 );
output( "\tmovq %%rax,0x98(%%rsp)\n" );
output( "\tmovq %%rbp,0xa0(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%rbp,0xa0\n" );
+ output_cfi( ".cfi_rel_offset %%rbp,0xa0" );
output( "\tmovq %%rsi,0xa8(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%rsi,0xa8\n" );
+ output_cfi( ".cfi_rel_offset %%rsi,0xa8" );
output( "\tmovq %%rdi,0xb0(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%rdi,0xb0\n" );
+ output_cfi( ".cfi_rel_offset %%rdi,0xb0" );
output( "\tmovq %%r8,0xb8(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r8,0xb8\n" );
+ output_cfi( ".cfi_rel_offset %%r8,0xb8" );
output( "\tmovq %%r9,0xc0(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r9,0xc0\n" );
+ output_cfi( ".cfi_rel_offset %%r9,0xc0" );
output( "\tmovq %%r10,0xc8(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r10,0xc8\n" );
+ output_cfi( ".cfi_rel_offset %%r10,0xc8" );
output( "\tmovq %%r11,0xd0(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r11,0xd0\n" );
+ output_cfi( ".cfi_rel_offset %%r11,0xd0" );
output( "\tmovq %%r12,0xd8(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r12,0xd8\n" );
+ output_cfi( ".cfi_rel_offset %%r12,0xd8" );
output( "\tmovq %%r13,0xe0(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r13,0xe0\n" );
+ output_cfi( ".cfi_rel_offset %%r13,0xe0" );
output( "\tmovq %%r14,0xe8(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r14,0xe8\n" );
+ output_cfi( ".cfi_rel_offset %%r14,0xe8" );
output( "\tmovq %%r15,0xf0(%%rsp)\n" );
- output( "\t.cfi_rel_offset %%r15,0xf0\n" );
+ output_cfi( ".cfi_rel_offset %%r15,0xf0" );
output( "\tmovq %u(%%rsp),%%rax\n", STACK_SPACE + 8 );
output( "\tmovq %%rax,0xf8(%%rsp)\n" );
@@ -1041,7 +1065,7 @@
for (i = 0; i < 16; i++)
{
output( "\tmovdqa %%xmm%u,0x%x(%%rsp)\n", i, 0x1a0 + 16 * i );
- output( "\t.cfi_rel_offset %%xmm%u,0x%x\n", i, 0x1a0 + 16 * i );
+ output_cfi( ".cfi_rel_offset %%xmm%u,0x%x", i, 0x1a0 + 16 * i );
}
output( "\tmovw %%cs,0x38(%%rsp)\n" );
@@ -1065,7 +1089,7 @@
output( "\tcmpq %%rax,%%rcx\n" );
output( "\tcmovgq %%rcx,%%rax\n" );
output( "\tmovq %%rsp,%%rbx\n" );
- output( "\t.cfi_def_cfa_register %%rbx\n" );
+ output_cfi( ".cfi_def_cfa_register %%rbx" );
output( "\tleaq 16(,%%rax,8),%%rax\n" ); /* add 8 for context arg and 8
for rounding */
output( "\tandq $~15,%%rax\n" );
output( "\tsubq %%rax,%%rsp\n" );
@@ -1087,36 +1111,36 @@
/* restore the context structure */
output( "1:\tmovq 0x80(%%rbx),%%rcx\n" );
- output( "\t.cfi_same_value %%rcx\n" );
+ output_cfi( ".cfi_same_value %%rcx" );
output( "\tmovq 0x88(%%rbx),%%rdx\n" );
- output( "\t.cfi_same_value %%rdx\n" );
+ output_cfi( ".cfi_same_value %%rdx" );
output( "\tmovq 0xa0(%%rbx),%%rbp\n" );
- output( "\t.cfi_same_value %%rbp\n" );
+ output_cfi( ".cfi_same_value %%rbp" );
output( "\tmovq 0xa8(%%rbx),%%rsi\n" );
- output( "\t.cfi_same_value %%rsi\n" );
+ output_cfi( ".cfi_same_value %%rsi" );
output( "\tmovq 0xb0(%%rbx),%%rdi\n" );
- output( "\t.cfi_same_value %%rdi\n" );
+ output_cfi( ".cfi_same_value %%rdi" );
output( "\tmovq 0xb8(%%rbx),%%r8\n" );
- output( "\t.cfi_same_value %%r8\n" );
+ output_cfi( ".cfi_same_value %%r8" );
output( "\tmovq 0xc0(%%rbx),%%r9\n" );
- output( "\t.cfi_same_value %%r9\n" );
+ output_cfi( ".cfi_same_value %%r9" );
output( "\tmovq 0xc8(%%rbx),%%r10\n" );
- output( "\t.cfi_same_value %%r10\n" );
+ output_cfi( ".cfi_same_value %%r10" );
output( "\tmovq 0xd0(%%rbx),%%r11\n" );
- output( "\t.cfi_same_value %%r11\n" );
+ output_cfi( ".cfi_same_value %%r11" );
output( "\tmovq 0xd8(%%rbx),%%r12\n" );
- output( "\t.cfi_same_value %%r12\n" );
+ output_cfi( ".cfi_same_value %%r12" );
output( "\tmovq 0xe0(%%rbx),%%r13\n" );
- output( "\t.cfi_same_value %%r13\n" );
+ output_cfi( ".cfi_same_value %%r13" );
output( "\tmovq 0xe8(%%rbx),%%r14\n" );
- output( "\t.cfi_same_value %%r14\n" );
+ output_cfi( ".cfi_same_value %%r14" );
output( "\tmovq 0xf0(%%rbx),%%r15\n" );
- output( "\t.cfi_same_value %%r15\n" );
+ output_cfi( ".cfi_same_value %%r15" );
for (i = 0; i < 16; i++)
{
output( "\tmovdqa 0x%x(%%rbx),%%xmm%u\n", 0x1a0 + 16 * i, i );
- output( "\t.cfi_same_value %%xmm%u\n", i );
+ output_cfi( ".cfi_same_value %%xmm%u", i );
}
output( "\tfxrstor 0x100(%%rbx)\n" );
output( "\tldmxcsr 0x34(%%rbx)\n" );
@@ -1134,49 +1158,35 @@
output( "\tmovq 0x78(%%rbx),%%rax\n" );
output( "\tmovq 0x90(%%rbx),%%rbx\n" );
output( "\tiretq\n" );
- output( "\t.cfi_endproc\n" );
+ output_cfi( ".cfi_endproc" );
output_function_size( "__wine_call_from_regs" );
function_header( "__wine_restore_regs" );
- output( "\t.cfi_startproc\n" );
+ output_cfi( ".cfi_startproc" );
output( "\tmovq %%rcx,%%rbx\n" );
output( "\tjmp 1b\n" );
- output( "\t.cfi_endproc\n" );
+ output_cfi( ".cfi_endproc" );
output_function_size( "__wine_restore_regs" );
}
/*******************************************************************
- * BuildRelays32
- *
- * Build all the 32-bit relay callbacks
+ * output_asm_relays
+ *
+ * Build all the assembly relay callbacks
*/
-void BuildRelays32(void)
+void output_asm_relays(void)
{
switch (target_cpu)
{
case CPU_x86:
- output( "/* File generated automatically. Do not edit! */\n\n" );
- output( "\t.text\n" );
- output( "%s:\n\n", asm_name("__wine_spec_thunk_text_32") );
-
- /* 32-bit register entry point */
- BuildCallFrom32Regs();
-
- output_function_size( "__wine_spec_thunk_text_32" );
- output_gnu_stack_note();
+ build_call_from_regs_x86();
break;
-
case CPU_x86_64:
- output( "/* File generated automatically. Do not edit! */\n\n" );
- output( "\t.text\n" );
build_call_from_regs_x86_64();
- output_gnu_stack_note();
break;
-
default:
- output( "/* File not used with this architecture. Do not edit! */\n\n"
);
- return;
+ break;
}
}
Modified: branches/cmake-bringup/tools/winebuild/res32.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/r…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/res32.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/res32.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -35,14 +35,12 @@
#include "build.h"
typedef unsigned short WCHAR;
-typedef unsigned short WORD;
-typedef unsigned int DWORD;
/* Unicode string or integer id */
struct string_id
{
WCHAR *str; /* ptr to Unicode string */
- WORD id; /* integer id if str is NULL */
+ unsigned short id; /* integer id if str is NULL */
};
/* descriptor for a resource */
@@ -197,7 +195,7 @@
/* all values must be zero except header size */
static int check_header(void)
{
- DWORD size;
+ unsigned int size;
if (get_dword()) return 0; /* data size */
size = get_dword(); /* header size */
@@ -216,14 +214,18 @@
/* load the next resource from the current file */
static void load_next_resource( DLLSPEC *spec )
{
- DWORD hdr_size;
+ unsigned int hdr_size;
struct resource *res = add_resource( spec );
res->data_size = get_dword();
hdr_size = get_dword();
if (hdr_size & 3) fatal_error( "%s header size not aligned\n",
input_buffer_filename );
-
- res->data = input_buffer + input_buffer_pos - 2*sizeof(DWORD) + hdr_size;
+ if (hdr_size < 32) fatal_error( "%s invalid header size %u\n",
input_buffer_filename, hdr_size );
+
+ res->data = input_buffer + input_buffer_pos - 2*sizeof(unsigned int) + hdr_size;
+ if ((const unsigned char *)res->data < input_buffer ||
+ (const unsigned char *)res->data >= input_buffer + input_buffer_size)
+ fatal_error( "%s invalid header size %u\n", input_buffer_filename,
hdr_size );
get_string( &res->type );
get_string( &res->name );
if (input_buffer_pos & 2) get_word(); /* align to dword boundary */
@@ -654,13 +656,14 @@
if (res_file)
{
- const char *prog = get_windres_command();
+ char *prog = find_tool( "windres", NULL );
char *cmd = xmalloc( strlen(prog) + strlen(res_file) + strlen(output_file_name) +
9 );
sprintf( cmd, "%s -i %s -o %s", prog, res_file, output_file_name );
if (verbose) fprintf( stderr, "%s\n", cmd );
err = system( cmd );
if (err) fatal_error( "%s failed with status %d\n", prog, err );
free( cmd );
+ free( prog );
}
output_file_name = NULL; /* so we don't try to assemble it */
}
Removed: branches/cmake-bringup/tools/winebuild/ros_diff.patch
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/r…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/ros_diff.patch [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/ros_diff.patch (removed)
@@ -1,388 +1,0 @@
-Index: build.h
-===================================================================
---- build.h (Revision 4)
-+++ build.h (Arbeitskopie)
-@@ -38,6 +38,8 @@
- #define min(a,b) (((a) < (b)) ? (a) : (b))
- #endif
-
-+#define EXEEXT ".exe"
-+
- typedef enum
- {
- TYPE_VARIABLE, /* variable */
-@@ -47,6 +49,7 @@
- TYPE_STDCALL, /* stdcall function (Win32) */
- TYPE_CDECL, /* cdecl function (Win32) */
- TYPE_VARARGS, /* varargs function (Win32) */
-+ TYPE_FASTCALL, /* fastcall function (Win32) */
- TYPE_EXTERN, /* external symbol (Win32) */
- TYPE_NBTYPES
- } ORD_TYPE;
-@@ -269,6 +272,7 @@
- extern void BuildSpec16File( DLLSPEC *spec );
- extern void BuildSpec32File( DLLSPEC *spec );
- extern void BuildDef32File( DLLSPEC *spec );
-+extern void BuildPedllFile( DLLSPEC *spec );
-
- extern void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 );
- extern int parse_spec_file( FILE *file, DLLSPEC *spec );
-Index: main.c
-===================================================================
---- main.c (Revision 4)
-+++ main.c (Arbeitskopie)
-@@ -48,9 +48,9 @@
- int link_ext_symbols = 0;
- int force_pointer_size = 0;
-
--#ifdef __i386__
-+#if defined(TARGET_i386)
- enum target_cpu target_cpu = CPU_x86;
--#elif defined(__x86_64__)
-+#elif defined(TARGET_amd64)
- enum target_cpu target_cpu = CPU_x86_64;
- #elif defined(__sparc__)
- enum target_cpu target_cpu = CPU_SPARC;
-@@ -58,7 +58,7 @@
- enum target_cpu target_cpu = CPU_ALPHA;
- #elif defined(__powerpc__)
- enum target_cpu target_cpu = CPU_POWERPC;
--#elif defined(__arm__)
-+#elif defined(TARGET_arm)
- enum target_cpu target_cpu = CPU_ARM;
- #else
- #error Unsupported CPU
-@@ -102,7 +102,8 @@
- MODE_DEF,
- MODE_RELAY16,
- MODE_RELAY32,
-- MODE_RESOURCES
-+ MODE_RESOURCES,
-+ MODE_PEDLL
- };
-
- static enum exec_mode_values exec_mode = MODE_NONE;
-@@ -253,6 +254,7 @@
- " --relay16 Build the 16-bit relay assembly routines\n"
- " --relay32 Build the 32-bit relay assembly routines\n"
- " --resources Build a .o file for the resource files\n\n"
-+" --pedll Build a .c file for PE dll\n\n"
- "The mode options are mutually exclusive; you must specify one and only
one.\n\n";
-
- enum long_options_values
-@@ -272,7 +274,8 @@
- LONG_OPT_RESOURCES,
- LONG_OPT_SAVE_TEMPS,
- LONG_OPT_SUBSYSTEM,
-- LONG_OPT_VERSION
-+ LONG_OPT_VERSION,
-+ LONG_OPT_PEDLL
- };
-
- static const char short_options[] =
"C:D:E:F:H:I:K:L:M:N:b:d:e:f:hi:kl:m:o:r:u:vw";
-@@ -295,6 +298,7 @@
- { "save-temps", 0, 0, LONG_OPT_SAVE_TEMPS },
- { "subsystem", 1, 0, LONG_OPT_SUBSYSTEM },
- { "version", 0, 0, LONG_OPT_VERSION },
-+ { "pedll", 1, 0, LONG_OPT_PEDLL },
- /* aliases for short options */
- { "target", 1, 0, 'b' },
- { "delay-lib", 1, 0, 'd' },
-@@ -497,6 +501,11 @@
- case LONG_OPT_VERSION:
- printf( "winebuild version " PACKAGE_VERSION "\n" );
- exit(0);
-+ case LONG_OPT_PEDLL:
-+ set_exec_mode( MODE_PEDLL );
-+ spec_file_name = xstrdup( optarg );
-+ set_dll_file_name( optarg, spec );
-+ break;
- case '?':
- usage(1);
- break;
-@@ -652,6 +661,11 @@
- if (argv[0]) fatal_error( "file argument '%s' not allowed in this
mode\n", argv[0] );
- BuildRelays32();
- break;
-+ case MODE_PEDLL:
-+ if (argv[0]) fatal_error( "file argument '%s' not allowed in this
mode\n", argv[0] );
-+ if (!parse_input_file( spec )) break;
-+ BuildPedllFile( spec );
-+ break;
- case MODE_RESOURCES:
- load_resources( argv, spec );
- output_res_o_file( spec );
-Index: parser.c
-===================================================================
---- parser.c (Revision 4)
-+++ parser.c (Arbeitskopie)
-@@ -56,6 +56,7 @@
- "stdcall", /* TYPE_STDCALL */
- "cdecl", /* TYPE_CDECL */
- "varargs", /* TYPE_VARARGS */
-+ "fastcall", /* TYPE_FASTCALL */
- "extern" /* TYPE_EXTERN */
- };
-
-@@ -521,6 +522,7 @@
- case TYPE_STDCALL:
- case TYPE_VARARGS:
- case TYPE_CDECL:
-+ case TYPE_FASTCALL:
- if (!parse_spec_export( odp, spec )) goto error;
- break;
- case TYPE_ABS:
-Index: res32.c
-===================================================================
---- res32.c (Revision 4)
-+++ res32.c (Arbeitskopie)
-@@ -35,12 +35,14 @@
- #include "build.h"
-
- typedef unsigned short WCHAR;
-+typedef unsigned short WORD;
-+typedef unsigned int DWORD;
-
- /* Unicode string or integer id */
- struct string_id
- {
- WCHAR *str; /* ptr to Unicode string */
-- unsigned short id; /* integer id if str is NULL */
-+ WORD id; /* integer id if str is NULL */
- };
-
- /* descriptor for a resource */
-@@ -195,7 +197,7 @@
- /* all values must be zero except header size */
- static int check_header(void)
- {
-- unsigned int size;
-+ DWORD size;
-
- if (get_dword()) return 0; /* data size */
- size = get_dword(); /* header size */
-@@ -214,14 +216,14 @@
- /* load the next resource from the current file */
- static void load_next_resource( DLLSPEC *spec )
- {
-- unsigned int hdr_size;
-+ DWORD hdr_size;
- struct resource *res = add_resource( spec );
-
- res->data_size = get_dword();
- hdr_size = get_dword();
- if (hdr_size & 3) fatal_error( "%s header size not aligned\n",
input_buffer_filename );
-
-- res->data = input_buffer + input_buffer_pos - 2*sizeof(unsigned int) + hdr_size;
-+ res->data = input_buffer + input_buffer_pos - 2*sizeof(DWORD) + hdr_size;
- get_string( &res->type );
- get_string( &res->name );
- if (input_buffer_pos & 2) get_word(); /* align to dword boundary */
-Index: spec32.c
-===================================================================
---- spec32.c (Revision 4)
-+++ spec32.c (Arbeitskopie)
-@@ -74,6 +74,28 @@
- }
-
- /*******************************************************************
-+ * make_internal_name
-+ *
-+ * Generate an internal name for an entry point. Used for stubs etc.
-+ */
-+static const char *make_internal_name( const ORDDEF *odp, DLLSPEC *spec, const char
*prefix )
-+{
-+ static char buffer[256];
-+ if (odp->name || odp->export_name)
-+ {
-+ char *p;
-+ sprintf( buffer, "__wine_%s_%s_%s", prefix, spec->file_name,
-+ odp->name ? odp->name : odp->export_name );
-+ /* make sure name is a legal C identifier */
-+ for (p = buffer; *p; p++) if (!isalnum(*p) && *p != '_') break;
-+ if (!*p) return buffer;
-+ }
-+ sprintf( buffer, "__wine_%s_%s_%d", prefix,
make_c_identifier(spec->file_name), odp->ordinal );
-+ return buffer;
-+}
-+
-+
-+/*******************************************************************
- * output_relay_debug
- *
- * Output entry points for relay debugging
-@@ -341,6 +363,44 @@
-
-
- /*******************************************************************
-+ * output_stub_funcs
-+ *
-+ * Output the functions for stub entry points
-+ */
-+static void output_stub_funcs( DLLSPEC *spec )
-+{
-+ int i;
-+
-+#if 0
-+ for (i = 0; i < spec->nb_entry_points; i++)
-+ {
-+ ORDDEF *odp = &spec->entry_points[i];
-+ if (odp->type != TYPE_STUB) continue;
-+ fprintf( outfile, "#ifdef __GNUC__\n" );
-+ fprintf( outfile, "extern void __wine_spec_unimplemented_stub( const char
*module, const char *func ) __attribute__((noreturn));\n" );
-+ fprintf( outfile, "#else\n" );
-+ fprintf( outfile, "extern void __wine_spec_unimplemented_stub( const char
*module, const char *func );\n" );
-+ fprintf( outfile, "#endif\n\n" );
-+ break;
-+ }
-+#endif
-+
-+ for (i = 0; i < spec->nb_entry_points; i++)
-+ {
-+ const ORDDEF *odp = &spec->entry_points[i];
-+ if (odp->type != TYPE_STUB) continue;
-+ output( "void %s(void) ", make_internal_name( odp, spec,
"stub" ) );
-+ if (odp->name)
-+ output( "{ __wine_spec_unimplemented_stub(__wine_spec_file_name,
\"%s\"); }\n", odp->name );
-+ else if (odp->export_name)
-+ output( "{ __wine_spec_unimplemented_stub(__wine_spec_file_name,
\"%s\"); }\n", odp->export_name );
-+ else
-+ output( "{ __wine_spec_unimplemented_stub(__wine_spec_file_name,
\"%d\"); }\n", odp->ordinal );
-+ }
-+}
-+
-+
-+/*******************************************************************
- * output_asm_constructor
- *
- * Output code for calling a dll constructor.
-@@ -795,10 +855,6 @@
-
- if (!(odp->flags & FLAG_PRIVATE)) total++;
-
-- if (odp->type == TYPE_STUB) continue;
--
-- output( " %s", name );
--
- switch(odp->type)
- {
- case TYPE_EXTERN:
-@@ -807,12 +863,14 @@
- case TYPE_VARARGS:
- case TYPE_CDECL:
- /* try to reduce output */
-+ output( " %s", name );
- if(strcmp(name, odp->link_name) || (odp->flags & FLAG_FORWARD))
- output( "=%s", odp->link_name );
- break;
- case TYPE_STDCALL:
- {
- int at_param = strlen(odp->u.func.arg_types) * get_ptr_size();
-+ output( " %s", name );
- if (!kill_at && target_cpu == CPU_x86) output( "@%d",
at_param );
- if (odp->flags & FLAG_FORWARD)
- {
-@@ -825,6 +883,50 @@
- }
- break;
- }
-+ case TYPE_FASTCALL:
-+ {
-+ int at_param = strlen(odp->u.func.arg_types) * get_ptr_size();
-+ output( " " );
-+ if (!kill_at) output( "@" );
-+ output( "%s", name );
-+ if (!kill_at) output( "@%d", at_param );
-+ if (odp->flags & FLAG_FORWARD)
-+ {
-+ output( "=" );
-+ output( "%s", odp->link_name );
-+ }
-+ else if (strcmp(name, odp->link_name)) /* try to reduce output */
-+ {
-+ output( "=" );
-+ if (!kill_at) output( "@" );
-+ output( "%s", odp->link_name );
-+ if (!kill_at) output( "@%d", at_param );
-+ }
-+ break;
-+ }
-+ case TYPE_STUB:
-+ {
-+ output( " %s", name );
-+ if (!kill_at)
-+ {
-+ const char *check = name + strlen(name);
-+ while (name != check &&
-+ '0' <= check[-1] && check[-1] <=
'9')
-+ {
-+ check--;
-+ }
-+ if (name != check && check != name + strlen(name) &&
-+ '@' == check[-1])
-+ {
-+ output("%s", check - 1);
-+ }
-+ }
-+ if (odp->name || odp->export_name)
-+ {
-+ output("=%s", make_internal_name( odp, spec, "stub"
));
-+ }
-+ break;
-+ }
- default:
- assert(0);
- }
-@@ -836,3 +939,52 @@
- }
- if (!total) warning( "%s: Import library doesn't export anything\n",
spec->file_name );
- }
-+
-+
-+/*******************************************************************
-+ * BuildPedllFile
-+ *
-+ * Build a PE DLL C file from a spec file.
-+ */
-+void BuildPedllFile( DLLSPEC *spec )
-+{
-+ int i, has_stubs = 0;
-+
-+ output_standard_file_header();
-+
-+ for (i = 0; i < spec->nb_entry_points; i++)
-+ {
-+ const ORDDEF *odp = &spec->entry_points[i];
-+ if (odp->type == TYPE_STUB)
-+ {
-+ has_stubs = 1;
-+ break;
-+ }
-+ }
-+
-+ if (!has_stubs)
-+ {
-+ output( "/* This file is intentionally left blank */\n");
-+ return;
-+ }
-+
-+ output( "#include <stdarg.h>\n");
-+ output( "#include \"windef.h\"\n");
-+ output( "#include \"winbase.h\"\n");
-+ output( "#include \"wine/config.h\"\n");
-+ output( "#include \"wine/exception.h\"\n\n");
-+
-+ output( "void __wine_spec_unimplemented_stub( const char *module, const char
*function )\n");
-+ output( "{\n");
-+ output( " ULONG_PTR args[2];\n");
-+ output( "\n");
-+ output( " args[0] = (ULONG_PTR)module;\n");
-+ output( " args[1] = (ULONG_PTR)function;\n");
-+ output( " RaiseException( EXCEPTION_WINE_STUB, EH_NONCONTINUABLE, 2, args
);\n");
-+ output( "}\n\n");
-+
-+ output( "static const char __wine_spec_file_name[] =
\"%s\";\n\n", spec->file_name );
-+
-+ /* Output the stub functions */
-+ output_stub_funcs( spec );
-+}
Modified: branches/cmake-bringup/tools/winebuild/spec16.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/s…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/spec16.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/spec16.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -57,26 +57,11 @@
static inline int is_function( const ORDDEF *odp )
{
+ if (odp->flags & FLAG_EXPORT32) return 0;
return (odp->type == TYPE_CDECL ||
odp->type == TYPE_PASCAL ||
odp->type == TYPE_VARARGS ||
odp->type == TYPE_STUB);
-}
-
-static void init_dll_name( DLLSPEC *spec )
-{
- if (!spec->file_name)
- {
- char *p;
- spec->file_name = xstrdup( output_file_name );
- if ((p = strrchr( spec->file_name, '.' ))) *p = 0;
- }
- if (!spec->dll_name) /* set default name from file name */
- {
- char *p;
- spec->dll_name = xstrdup( spec->file_name );
- if ((p = strrchr( spec->dll_name, '.' ))) *p = 0;
- }
}
/*******************************************************************
@@ -130,6 +115,7 @@
int selector = 0;
ORDDEF *odp = spec->ordinals[i];
if (!odp) continue;
+ if (odp->flags & FLAG_EXPORT32) continue;
switch (odp->type)
{
@@ -326,12 +312,17 @@
output( "\t.align %d\n", get_alignment(4) );
output( "\t%s\n", func_declaration(name) );
output( "%s:\n", name );
+ output_cfi( ".cfi_startproc" );
output( "\tpushl %%ebp\n" );
+ output_cfi( ".cfi_adjust_cfa_offset 4" );
+ output_cfi( ".cfi_rel_offset %%ebp,0" );
output( "\tmovl %%esp,%%ebp\n" );
+ output_cfi( ".cfi_def_cfa_register %%ebp" );
stack_words = 2;
if (needs_ldt)
{
output( "\tpushl %%esi\n" );
+ output_cfi( ".cfi_rel_offset %%esi,-4" );
stack_words++;
if (UsePIC)
{
@@ -404,10 +395,16 @@
output( "\tcall *8(%%ebp)\n" );
- if (needs_ldt) output( "\tmovl -4(%%ebp),%%esi\n" );
-
+ if (needs_ldt)
+ {
+ output( "\tmovl -4(%%ebp),%%esi\n" );
+ output_cfi( ".cfi_same_value %%esi" );
+ }
output( "\tleave\n" );
+ output_cfi( ".cfi_def_cfa %%esp,4" );
+ output_cfi( ".cfi_same_value %%ebp" );
output( "\tret\n" );
+ output_cfi( ".cfi_endproc" );
output_function_size( name );
}
@@ -473,81 +470,6 @@
if (compare( &list[j], &list[i] )) list[++j] = list[i];
}
return j + 1;
-}
-
-
-/*******************************************************************
- * output_init_code
- *
- * Output the dll initialization code.
- */
-static void output_init_code( const DLLSPEC *spec )
-{
- char name[80];
-
- sprintf( name, ".L__wine_spec_%s_init",
make_c_identifier(spec->dll_name) );
-
- output( "\n/* dll initialization code */\n\n" );
- output( "\t.text\n" );
- output( "\t.align 4\n" );
- output( "\t%s\n", func_declaration(name) );
- output( "%s:\n", name );
- output( "\tsubl $4,%%esp\n" );
- if (UsePIC)
- {
- output( "\tcall %s\n",
asm_name("__wine_spec_get_pc_thunk_eax") );
- output( "1:\tleal .L__wine_spec_file_name-1b(%%eax),%%ecx\n" );
- output( "\tpushl %%ecx\n" );
- output( "\tleal .L__wine_spec_dos_header-1b(%%eax),%%ecx\n" );
- output( "\tpushl %%ecx\n" );
- }
- else
- {
- output( "\tpushl $.L__wine_spec_file_name\n" );
- output( "\tpushl $.L__wine_spec_dos_header\n" );
- }
- output( "\tcall %s\n", asm_name("__wine_dll_register_16") );
- output( "\taddl $12,%%esp\n" );
- output( "\tret\n" );
- output_function_size( name );
-
- sprintf( name, ".L__wine_spec_%s_fini",
make_c_identifier(spec->dll_name) );
-
- output( "\t.align 4\n" );
- output( "\t%s\n", func_declaration(name) );
- output( "%s:\n", name );
- output( "\tsubl $8,%%esp\n" );
- if (UsePIC)
- {
- output( "\tcall %s\n",
asm_name("__wine_spec_get_pc_thunk_eax") );
- output( "1:\tleal .L__wine_spec_dos_header-1b(%%eax),%%ecx\n" );
- output( "\tpushl %%ecx\n" );
- }
- else
- {
- output( "\tpushl $.L__wine_spec_dos_header\n" );
- }
- output( "\tcall %s\n", asm_name("__wine_dll_unregister_16") );
- output( "\taddl $12,%%esp\n" );
- output( "\tret\n" );
- output_function_size( name );
-
- if (target_platform == PLATFORM_APPLE)
- {
- output( "\t.mod_init_func\n" );
- output( "\t.align %d\n", get_alignment(4) );
- output( "\t.long .L__wine_spec_%s_init\n",
make_c_identifier(spec->dll_name) );
- output( "\t.mod_term_func\n" );
- output( "\t.align %d\n", get_alignment(4) );
- output( "\t.long .L__wine_spec_%s_fini\n",
make_c_identifier(spec->dll_name) );
- }
- else
- {
- output( "\t.section \".init\",\"ax\"\n" );
- output( "\tcall .L__wine_spec_%s_init\n",
make_c_identifier(spec->dll_name) );
- output( "\t.section \".fini\",\"ax\"\n" );
- output( "\tcall .L__wine_spec_%s_fini\n",
make_c_identifier(spec->dll_name) );
- }
}
@@ -704,6 +626,7 @@
{
ORDDEF *odp = spec->ordinals[i];
if (!odp || !odp->name[0]) continue;
+ if (odp->flags & FLAG_EXPORT32) continue;
output_resident_name( odp->name, i );
}
output( "\t.byte 0\n" );
@@ -844,28 +767,6 @@
/*******************************************************************
- * BuildSpec16File
- *
- * Build a Win16 assembly file from a spec file.
- */
-void BuildSpec16File( DLLSPEC *spec )
-{
- init_dll_name( spec );
- output_standard_file_header();
- output_module16( spec );
- output_init_code( spec );
-
- output( "\n\t%s\n", get_asm_string_section() );
- output( ".L__wine_spec_file_name:\n" );
- output( "\t%s \"%s\"\n", get_asm_string_keyword(),
spec->file_name );
-
- output_stubs( spec );
- output_get_pc_thunk();
- output_gnu_stack_note();
-}
-
-
-/*******************************************************************
* output_spec16_file
*
* Output the complete data for a spec 16-bit file.
@@ -873,15 +774,6 @@
void output_spec16_file( DLLSPEC *spec16 )
{
DLLSPEC *spec32 = alloc_dll_spec();
-
- init_dll_name( spec16 );
- spec32->file_name = xstrdup( spec16->file_name );
-
- if (spec16->characteristics & IMAGE_FILE_DLL)
- {
- spec32->characteristics = IMAGE_FILE_DLL;
- spec32->init_func = xstrdup( "__wine_spec_dll_entry" );
- }
resolve_imports( spec16 );
add_16bit_exports( spec32, spec16 );
@@ -892,6 +784,7 @@
output_stubs( spec16 );
output_exports( spec32 );
output_imports( spec16 );
+ if (is_undefined( "__wine_call_from_16" )) output_asm_relays16();
if (spec16->main_module)
{
output( "\n\t%s\n", get_asm_string_section() );
@@ -918,7 +811,6 @@
unsigned int i, rsrctab, restab, namelen, modtab, imptab, enttab, cbenttab, codeseg,
dataseg, rsrcdata;
- init_dll_name( spec );
init_output_buffer();
rsrctab = lfanew;
Modified: branches/cmake-bringup/tools/winebuild/spec32.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/s…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/spec32.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/spec32.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -72,28 +72,6 @@
}
return 0;
}
-
-/*******************************************************************
- * make_internal_name
- *
- * Generate an internal name for an entry point. Used for stubs etc.
- */
-static const char *make_internal_name( const ORDDEF *odp, DLLSPEC *spec, const char
*prefix )
-{
- static char buffer[256];
- if (odp->name || odp->export_name)
- {
- char *p;
- sprintf( buffer, "__wine_%s_%s_%s", prefix, spec->file_name,
- odp->name ? odp->name : odp->export_name );
- /* make sure name is a legal C identifier */
- for (p = buffer; *p; p++) if (!isalnum(*p) && *p != '_') break;
- if (!*p) return buffer;
- }
- sprintf( buffer, "__wine_%s_%s_%d", prefix,
make_c_identifier(spec->file_name), odp->ordinal );
- return buffer;
-}
-
/*******************************************************************
* output_relay_debug
@@ -359,44 +337,6 @@
output( "\t%s .L__wine_spec_relay_arg_types\n", get_asm_ptr_keyword() );
output_relay_debug( spec );
-}
-
-
-/*******************************************************************
- * output_stub_funcs
- *
- * Output the functions for stub entry points
- */
-static void output_stub_funcs( DLLSPEC *spec )
-{
- int i;
-
-#if 0
- for (i = 0; i < spec->nb_entry_points; i++)
- {
- ORDDEF *odp = &spec->entry_points[i];
- if (odp->type != TYPE_STUB) continue;
- fprintf( outfile, "#ifdef __GNUC__\n" );
- fprintf( outfile, "extern void __wine_spec_unimplemented_stub( const char
*module, const char *func ) __attribute__((noreturn));\n" );
- fprintf( outfile, "#else\n" );
- fprintf( outfile, "extern void __wine_spec_unimplemented_stub( const char
*module, const char *func );\n" );
- fprintf( outfile, "#endif\n\n" );
- break;
- }
-#endif
-
- for (i = 0; i < spec->nb_entry_points; i++)
- {
- const ORDDEF *odp = &spec->entry_points[i];
- if (odp->type != TYPE_STUB) continue;
- output( "void %s(void) ", make_internal_name( odp, spec,
"stub" ) );
- if (odp->name)
- output( "{ __wine_spec_unimplemented_stub(__wine_spec_file_name,
\"%s\"); }\n", odp->name );
- else if (odp->export_name)
- output( "{ __wine_spec_unimplemented_stub(__wine_spec_file_name,
\"%s\"); }\n", odp->export_name );
- else
- output( "{ __wine_spec_unimplemented_stub(__wine_spec_file_name,
\"%d\"); }\n", odp->ordinal );
- }
}
@@ -614,6 +554,7 @@
output_stubs( spec );
output_exports( spec );
output_imports( spec );
+ if (is_undefined( "__wine_call_from_regs" )) output_asm_relays();
output_resources( spec );
output_gnu_stack_note();
}
@@ -822,14 +763,22 @@
/*******************************************************************
- * BuildDef32File
+ * output_def_file
*
* Build a Win32 def file from a spec file.
*/
-void BuildDef32File( DLLSPEC *spec )
+void output_def_file( DLLSPEC *spec, int include_private )
{
+ DLLSPEC *spec32 = NULL;
const char *name;
int i, total;
+
+ if (spec->type == SPEC_WIN16)
+ {
+ spec32 = alloc_dll_spec();
+ add_16bit_exports( spec32, spec );
+ spec = spec32;
+ }
if (spec_file_name)
output( "; File generated automatically from %s; do not edit!\n\n",
@@ -854,6 +803,11 @@
else continue;
if (!(odp->flags & FLAG_PRIVATE)) total++;
+ else if (!include_private) continue;
+
+ if (odp->type == TYPE_STUB) continue;
+
+ output( " %s", name );
switch(odp->type)
{
@@ -863,14 +817,12 @@
case TYPE_VARARGS:
case TYPE_CDECL:
/* try to reduce output */
- output( " %s", name );
if(strcmp(name, odp->link_name) || (odp->flags & FLAG_FORWARD))
output( "=%s", odp->link_name );
break;
case TYPE_STDCALL:
{
int at_param = strlen(odp->u.func.arg_types) * get_ptr_size();
- output( " %s", name );
if (!kill_at && target_cpu == CPU_x86) output( "@%d",
at_param );
if (odp->flags & FLAG_FORWARD)
{
@@ -883,50 +835,6 @@
}
break;
}
- case TYPE_FASTCALL:
- {
- int at_param = strlen(odp->u.func.arg_types) * get_ptr_size();
- output( " " );
- if (!kill_at) output( "@" );
- output( "%s", name );
- if (!kill_at) output( "@%d", at_param );
- if (odp->flags & FLAG_FORWARD)
- {
- output( "=" );
- output( "%s", odp->link_name );
- }
- else if (strcmp(name, odp->link_name)) /* try to reduce output */
- {
- output( "=" );
- if (!kill_at) output( "@" );
- output( "%s", odp->link_name );
- if (!kill_at) output( "@%d", at_param );
- }
- break;
- }
- case TYPE_STUB:
- {
- output( " %s", name );
- if (!kill_at)
- {
- const char *check = name + strlen(name);
- while (name != check &&
- '0' <= check[-1] && check[-1] <=
'9')
- {
- check--;
- }
- if (name != check && check != name + strlen(name) &&
- '@' == check[-1])
- {
- output("%s", check - 1);
- }
- }
- if (odp->name || odp->export_name)
- {
- output("=%s", make_internal_name( odp, spec, "stub"
));
- }
- break;
- }
default:
assert(0);
}
@@ -937,53 +845,5 @@
output( "\n" );
}
if (!total) warning( "%s: Import library doesn't export anything\n",
spec->file_name );
+ if (spec32) free_dll_spec( spec32 );
}
-
-
-/*******************************************************************
- * BuildPedllFile
- *
- * Build a PE DLL C file from a spec file.
- */
-void BuildPedllFile( DLLSPEC *spec )
-{
- int i, has_stubs = 0;
-
- output_standard_file_header();
-
- for (i = 0; i < spec->nb_entry_points; i++)
- {
- const ORDDEF *odp = &spec->entry_points[i];
- if (odp->type == TYPE_STUB)
- {
- has_stubs = 1;
- break;
- }
- }
-
- if (!has_stubs)
- {
- output( "/* This file is intentionally left blank */\n");
- return;
- }
-
- output( "#include <stdarg.h>\n");
- output( "#include \"windef.h\"\n");
- output( "#include \"winbase.h\"\n");
- output( "#include \"wine/config.h\"\n");
- output( "#include \"wine/exception.h\"\n\n");
-
- output( "void __wine_spec_unimplemented_stub( const char *module, const char
*function )\n");
- output( "{\n");
- output( " ULONG_PTR args[2];\n");
- output( "\n");
- output( " args[0] = (ULONG_PTR)module;\n");
- output( " args[1] = (ULONG_PTR)function;\n");
- output( " RaiseException( EXCEPTION_WINE_STUB, EH_NONCONTINUABLE, 2, args
);\n");
- output( "}\n\n");
-
- output( "static const char __wine_spec_file_name[] =
\"%s\";\n\n", spec->file_name );
-
- /* Output the stub functions */
- output_stub_funcs( spec );
-}
Modified: branches/cmake-bringup/tools/winebuild/utils.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/u…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/utils.c [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/utils.c [iso-8859-1] Fri Jul 30 22:10:00 2010
@@ -54,6 +54,7 @@
{ "i586", CPU_x86 },
{ "i686", CPU_x86 },
{ "i786", CPU_x86 },
+ { "amd64", CPU_x86_64 },
{ "x86_64", CPU_x86_64 },
{ "sparc", CPU_SPARC },
{ "alpha", CPU_ALPHA },
@@ -199,14 +200,24 @@
}
/* find a build tool in the path, trying the various names */
-static char *find_tool( const char * const *names )
+char *find_tool( const char *name, const char * const *names )
{
static char **dirs;
static unsigned int count, maxlen;
char *p, *file;
+ const char *alt_names[2];
unsigned int i, len;
struct stat st;
+
+ if (target_alias)
+ {
+ file = xmalloc( strlen(target_alias) + strlen(name) + 2 );
+ strcpy( file, target_alias );
+ strcat( file, "-" );
+ strcat( file, name );
+ return file;
+ }
if (!dirs)
{
@@ -230,6 +241,13 @@
for (i = 0; i < count; i++) maxlen = max( maxlen, strlen(dirs[i])+2 );
}
+ if (!names)
+ {
+ alt_names[0] = name;
+ alt_names[1] = NULL;
+ names = alt_names;
+ }
+
while (*names)
{
len = strlen(*names) + sizeof(EXEEXT) + 1;
@@ -249,24 +267,15 @@
free( file );
names++;
}
- return NULL;
+ return xstrdup( name );
}
const char *get_as_command(void)
{
if (!as_command)
{
- if (target_alias)
- {
- as_command = xmalloc( strlen(target_alias) + sizeof("-as") );
- strcpy( as_command, target_alias );
- strcat( as_command, "-as" );
- }
- else
- {
- static const char * const commands[] = { "gas", "as",
NULL };
- if (!(as_command = find_tool( commands ))) as_command =
xstrdup("as");
- }
+ static const char * const commands[] = { "gas", "as", NULL
};
+ as_command = find_tool( "as", commands );
if (force_pointer_size)
{
@@ -284,17 +293,8 @@
{
if (!ld_command)
{
- if (target_alias)
- {
- ld_command = xmalloc( strlen(target_alias) + sizeof("-ld") );
- strcpy( ld_command, target_alias );
- strcat( ld_command, "-ld" );
- }
- else
- {
- static const char * const commands[] = { "ld", "gld",
NULL };
- if (!(ld_command = find_tool( commands ))) ld_command =
xstrdup("ld");
- }
+ static const char * const commands[] = { "ld", "gld", NULL
};
+ ld_command = find_tool( "ld", commands );
if (force_pointer_size)
{
@@ -306,7 +306,7 @@
args = (force_pointer_size == 8) ? " -arch x86_64" : "
-arch i386";
break;
case PLATFORM_FREEBSD:
- args = (force_pointer_size == 8) ? " -m elf_x86_64" : " -m
elf_i386_fbsd";
+ args = (force_pointer_size == 8) ? " -m elf_x86_64_fbsd" :
" -m elf_i386_fbsd";
break;
default:
args = (force_pointer_size == 8) ? " -m elf_x86_64" : " -m
elf_i386";
@@ -323,40 +323,10 @@
{
if (!nm_command)
{
- if (target_alias)
- {
- nm_command = xmalloc( strlen(target_alias) + sizeof("-nm") );
- strcpy( nm_command, target_alias );
- strcat( nm_command, "-nm" );
- }
- else
- {
- static const char * const commands[] = { "nm", "gnm",
NULL };
- if (!(nm_command = find_tool( commands ))) nm_command =
xstrdup("nm");
- }
+ static const char * const commands[] = { "nm", "gnm", NULL
};
+ nm_command = find_tool( "nm", commands );
}
return nm_command;
-}
-
-const char *get_windres_command(void)
-{
- static char *windres_command;
-
- if (!windres_command)
- {
- if (target_alias)
- {
- windres_command = xmalloc( strlen(target_alias) +
sizeof("-windres") );
- strcpy( windres_command, target_alias );
- strcat( windres_command, "-windres" );
- }
- else
- {
- static const char * const commands[] = { "windres", NULL };
- if (!(windres_command = find_tool( commands ))) windres_command =
xstrdup("windres");
- }
- }
- return windres_command;
}
/* get a name for a temp file, automatically cleaned up on exit */
@@ -905,6 +875,19 @@
}
}
+/* output a .cfi directive */
+void output_cfi( const char *format, ... )
+{
+ va_list valist;
+
+ if (!unwind_tables) return;
+ va_start( valist, format );
+ fputc( '\t', output_file );
+ vfprintf( output_file, format, valist );
+ fputc( '\n', output_file );
+ va_end( valist );
+}
+
/* output the GNU note for non-exec stack */
void output_gnu_stack_note(void)
{
Modified: branches/cmake-bringup/tools/winebuild/winebuild.man.in
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/winebuild/w…
==============================================================================
--- branches/cmake-bringup/tools/winebuild/winebuild.man.in [iso-8859-1] (original)
+++ branches/cmake-bringup/tools/winebuild/winebuild.man.in [iso-8859-1] Fri Jul 30
22:10:00 2010
@@ -46,13 +46,9 @@
Build a .def file from a spec file. The .spec file is specified via the
-E option. This is used when building dlls with a PE (Win32) compiler.
.TP
-.B \--relay16
-Generate the assembly code for the 16-bit relay routines. This is for
-Wine internal usage only, you should never need to use this option.
-.TP
-.B \--relay32
-Generate the assembly code for the 32-bit relay routines. This is for
-Wine internal usage only, you should never need to use this option.
+.BI \--implib
+Build a PE import library from a spec file. The .spec file is
+specified via the -E option.
.TP
.B \--resources
Generate a .o file containing all the input resources. This is useful
@@ -105,8 +101,10 @@
.I forward
specification must be used instead).
.TP
-.BI \-f\ flags
-Ignored for compatibility with the C compiler.
+.BI \-f\ option
+Specify a code generation option. Currently \fB\-fPIC\fR and
+\fB\-fasynchronous-unwind-tables\fR are supported. Other options are
+ignored for compatibility with the C compiler.
.TP
.B \--fake-module
Create a fake PE module for a dll or exe, instead of the normal
@@ -159,13 +157,13 @@
\fIlibname.def\fR file in the directories specified with the \fB-L\fR
option.
.TP
-.B \-m32, -m64
-Generate 32-bit, respectively 64-bit code.
+.B \-m16, -m32, -m64
+Generate 16-bit, 32-bit, respectively 64-bit code.
.TP
.BI \-M,\ --main-module= module
-Specify that we are building a 16-bit dll, that will ultimately be
-linked together with the 32-bit dll specified in \fImodule\fR. Only
-meaningful in \fB--dll\fR mode.
+When building a 16-bit dll, set the name of its 32-bit counterpart to
+\fImodule\fR. This is used to enforce that the load order for the
+16-bit dll matches that of the 32-bit one.
.TP
.BI \-N,\ --dll-name= dllname
Set the internal name of the module. It is only used in Win16
@@ -213,10 +211,7 @@
for a graphical executable,
.br
.B native
-for a native-mode dll,
-.br
-.B win16
-for a 16-bit module.
+for a native-mode dll.
.br
The entry point of a command line executable is a normal C \fBmain\fR
function. A \fBwmain\fR function can be used instead if you need the
@@ -303,7 +298,11 @@
name is still exported.
.TP
.BI -arch= cpu[,cpu]
-The entry point is only available on the specified CPU architecture(s).
+The entry point is only available on the specified CPU
+architecture(s). The names \fBwin32\fR and \fBwin64\fR match all
+32-bit, respectively 64-bit, CPU architectures. In 16-bit dlls,
+specifying \fB-arch=win32\fR causes the entry point to be exported
+from the 32-bit wrapper module.
.SS "Function ordinals"
Syntax:
.br