diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 35cbfbcf41b..fb765bc4e9b 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -23,7 +23,7 @@ The following build tools are shared with Wine. reactos/tools/unicode # Synced to Wine-20081105 (~Wine-1.1.7) reactos/tools/wpp # Synced to Wine-20081105 (~Wine-1.1.7) -reactos/tools/winebuild # Synced to Wine-20071217 +reactos/tools/winebuild # Synced to Wine-20081105 (~Wine-1.1.7) reactos/tools/wmc # Synced to Wine-20071201 reactos/tools/wrc # Synced to Wine-0_9_53 reactos/tools/widl # Synced to Wine-0_9_59 diff --git a/reactos/tools/winebuild/build.h b/reactos/tools/winebuild/build.h index 1aff91b9841..e14b1ae9304 100644 --- a/reactos/tools/winebuild/build.h +++ b/reactos/tools/winebuild/build.h @@ -117,7 +117,7 @@ enum target_cpu enum target_platform { - PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_WINDOWS + PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_SOLARIS, PLATFORM_WINDOWS }; extern enum target_cpu target_cpu; @@ -144,14 +144,22 @@ extern enum target_platform target_platform; #define __attribute__(X) #endif +#ifndef DECLSPEC_NORETURN +# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS) +# define DECLSPEC_NORETURN __declspec(noreturn) +# else +# define DECLSPEC_NORETURN __attribute__((noreturn)) +# endif +#endif + extern void *xmalloc (size_t size); extern void *xrealloc (void *ptr, size_t size); extern char *xstrdup( const char *str ); extern char *strupper(char *s); extern int strendswith(const char* str, const char* end); -extern void fatal_error( const char *msg, ... ) +extern DECLSPEC_NORETURN void fatal_error( const char *msg, ... ) __attribute__ ((__format__ (__printf__, 1, 2))); -extern void fatal_perror( const char *msg, ... ) +extern DECLSPEC_NORETURN void fatal_perror( const char *msg, ... ) __attribute__ ((__format__ (__printf__, 1, 2))); extern void error( const char *msg, ... ) __attribute__ ((__format__ (__printf__, 1, 2))); diff --git a/reactos/tools/winebuild/import.c b/reactos/tools/winebuild/import.c index 5c54527ccf2..e5223ecfe4d 100644 --- a/reactos/tools/winebuild/import.c +++ b/reactos/tools/winebuild/import.c @@ -698,30 +698,20 @@ static void output_import_thunk( const char *name, const char *table, int pos ) output( "\tjmp $31,($0)\n" ); break; case CPU_POWERPC: - output( "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tstw %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) ); - output( "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tstw %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) ); - output( "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tstw %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) ); + output( "\tmr %s, %s\n", ppc_reg(0), ppc_reg(31) ); if (target_platform == PLATFORM_APPLE) { - output( "\tlis %s, ha16(%s+%d)\n", ppc_reg(9), table, pos ); - output( "\tla %s, lo16(%s+%d)(%s)\n", ppc_reg(8), table, pos, ppc_reg(9) ); + output( "\tlis %s, ha16(%s+%d+32768)\n", ppc_reg(31), table, pos ); + output( "\tla %s, lo16(%s+%d)(%s)\n", ppc_reg(31), table, pos, ppc_reg(31) ); } else { - output( "\tlis %s, (%s+%d)@h\n", ppc_reg(9), table, pos ); - output( "\tla %s, (%s+%d)@l(%s)\n", ppc_reg(8), table, pos, ppc_reg(9) ); + output( "\tlis %s, (%s+%d+32768)@h\n", ppc_reg(31), table, pos ); + output( "\tla %s, (%s+%d)@l(%s)\n", ppc_reg(31), table, pos, ppc_reg(31) ); } - output( "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(8) ); - output( "\tmtctr %s\n", ppc_reg(7) ); - output( "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) ); - output( "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tlwz %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) ); - output( "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tlwz %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) ); - output( "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) ); + output( "\tlwz %s, 0(%s)\n", ppc_reg(31), ppc_reg(31) ); + output( "\tmtctr %s\n", ppc_reg(31) ); + output( "\tmr %s, %s\n", ppc_reg(31), ppc_reg(0) ); output( "\tbctr\n" ); break; } diff --git a/reactos/tools/winebuild/main.c b/reactos/tools/winebuild/main.c index f588132950d..e80b08e402d 100644 --- a/reactos/tools/winebuild/main.c +++ b/reactos/tools/winebuild/main.c @@ -58,6 +58,8 @@ enum target_cpu target_cpu = CPU_x86_64; #ifdef __APPLE__ enum target_platform target_platform = PLATFORM_APPLE; +#elif defined(__sun) +enum target_platform target_platform = PLATFORM_SOLARIS; #elif defined(_WINDOWS) enum target_platform target_platform = PLATFORM_WINDOWS; #else @@ -118,6 +120,7 @@ static const struct { { "macos", PLATFORM_APPLE }, { "darwin", PLATFORM_APPLE }, + { "solaris", PLATFORM_SOLARIS }, { "windows", PLATFORM_WINDOWS }, { "winnt", PLATFORM_WINDOWS } }; @@ -598,10 +601,12 @@ int main(int argc, char **argv) case MODE_DLL: if (spec->subsystem != IMAGE_SUBSYSTEM_NATIVE) spec->characteristics |= IMAGE_FILE_DLL; + if (!spec_file_name) fatal_error( "missing .spec file\n" ); + /* fall through */ + case MODE_EXE: load_resources( argv, spec ); load_import_libs( argv ); - if (!spec_file_name) fatal_error( "missing .spec file\n" ); - if (!parse_input_file( spec )) break; + if (spec_file_name && !parse_input_file( spec )) break; switch (spec->type) { case SPEC_WIN16: @@ -614,15 +619,6 @@ int main(int argc, char **argv) default: assert(0); } break; - case MODE_EXE: - if (spec->type == SPEC_WIN16) fatal_error( "Cannot build 16-bit exe files\n" ); - if (!spec->file_name) fatal_error( "executable must be named via the -F option\n" ); - load_resources( argv, spec ); - load_import_libs( argv ); - if (spec_file_name && !parse_input_file( spec )) break; - read_undef_symbols( spec, argv ); - BuildSpec32File( spec ); - 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" ); diff --git a/reactos/tools/winebuild/relay.c b/reactos/tools/winebuild/relay.c index 0ddcc55f51e..4ec0dbfb2f3 100644 --- a/reactos/tools/winebuild/relay.c +++ b/reactos/tools/winebuild/relay.c @@ -26,8 +26,10 @@ #include "wine/port.h" #include +#include -#include "thread.h" +#define __WINESRC__ /* FIXME: for WINE_VM86_TEB_INFO */ +#include "winternl.h" #include "wine/winbase16.h" #include "build.h" @@ -383,7 +385,7 @@ static void BuildCallFrom16Core( int reg_func, int thunk ) * All routines expect that the 16-bit stack contents (arguments) and the * return address (segptr to CallTo16_Ret) were already set up by the * caller; nb_args must contain the number of bytes to be conserved. The - * 16-bit SS:SP will be set accordinly. + * 16-bit SS:SP will be set accordingly. * * All other registers are either taken from the CONTEXT86 structure * or else set to default values. The target routine address is either @@ -891,9 +893,11 @@ static void BuildPendingEventCheck(void) /* Check for pending events. */ - output( "\t.byte 0x64\n\ttestl $0xffffffff,(%d)\n", STRUCTOFFSET(TEB,vm86_pending) ); + output( "\t.byte 0x64\n\ttestl $0xffffffff,(%d)\n", + STRUCTOFFSET(TEB,GdiTebBatch) + STRUCTOFFSET(WINE_VM86_TEB_INFO,vm86_pending) ); output( "\tje %s\n", asm_name("DPMI_PendingEventCheck_Cleanup") ); - output( "\t.byte 0x64\n\ttestl $0xffffffff,(%d)\n", STRUCTOFFSET(TEB,dpmi_vif) ); + output( "\t.byte 0x64\n\ttestl $0xffffffff,(%d)\n", + STRUCTOFFSET(TEB,GdiTebBatch) + STRUCTOFFSET(WINE_VM86_TEB_INFO,dpmi_vif) ); output( "\tje %s\n", asm_name("DPMI_PendingEventCheck_Cleanup") ); /* Process pending events. */ diff --git a/reactos/tools/winebuild/res32.c b/reactos/tools/winebuild/res32.c index fad3429b721..82e938c7332 100644 --- a/reactos/tools/winebuild/res32.c +++ b/reactos/tools/winebuild/res32.c @@ -207,7 +207,7 @@ static void load_next_resource( DLLSPEC *spec ) res->data = file_pos - 2*sizeof(DWORD) + hdr_size; get_string( &res->type ); get_string( &res->name ); - if ((ULONG_PTR)file_pos & 2) get_word(); /* align to dword boundary */ + if ((UINT_PTR)file_pos & 2) get_word(); /* align to dword boundary */ get_dword(); /* skip data version */ get_word(); /* skip mem options */ res->lang = get_word(); diff --git a/reactos/tools/winebuild/spec16.c b/reactos/tools/winebuild/spec16.c index dc86b1b40ae..8fda97806a9 100644 --- a/reactos/tools/winebuild/spec16.c +++ b/reactos/tools/winebuild/spec16.c @@ -435,6 +435,7 @@ static int sort_func_list( ORDDEF **list, int count, { int i, j; + if (!count) return 0; qsort( list, count, sizeof(*list), compare ); for (i = j = 0; i < count; i++) @@ -461,7 +462,7 @@ static void output_init_code( const DLLSPEC *spec, const char *header_name ) output( "\t.align 4\n" ); output( "\t%s\n", func_declaration(name) ); output( "%s:\n", name ); - output( "subl $4,%%esp\n" ); + output( "\tsubl $4,%%esp\n" ); if (UsePIC) { output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") ); @@ -485,7 +486,7 @@ static void output_init_code( const DLLSPEC *spec, const char *header_name ) output( "\t.align 4\n" ); output( "\t%s\n", func_declaration(name) ); output( "%s:\n", name ); - output( "subl $8,%%esp\n" ); + output( "\tsubl $8,%%esp\n" ); if (UsePIC) { output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") ); @@ -528,6 +529,7 @@ static void output_init_code( const DLLSPEC *spec, const char *header_name ) void BuildSpec16File( DLLSPEC *spec ) { ORDDEF **typelist; + ORDDEF *entry_point = NULL; int i, j, nb_funcs; char header_name[256]; @@ -535,6 +537,12 @@ void BuildSpec16File( DLLSPEC *spec ) output_standard_file_header(); + 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; @@ -542,6 +550,28 @@ void BuildSpec16File( DLLSPEC *spec ) if ((p = strrchr( spec->dll_name, '.' ))) *p = 0; } + /* store the main entry point as ordinal 0 */ + + if (!spec->ordinals) + { + spec->ordinals = xmalloc( sizeof(spec->ordinals[0]) ); + spec->ordinals[0] = NULL; + } + if (spec->init_func && !(spec->characteristics & IMAGE_FILE_DLL)) + { + entry_point = xmalloc( sizeof(*entry_point) ); + entry_point->type = TYPE_PASCAL; + entry_point->ordinal = 0; + entry_point->lineno = 0; + entry_point->flags = FLAG_REGISTER; + entry_point->name = NULL; + entry_point->link_name = xstrdup( spec->init_func ); + entry_point->export_name = NULL; + entry_point->u.func.arg_types[0] = 0; + assert( !spec->ordinals[0] ); + spec->ordinals[0] = entry_point; + } + /* Build sorted list of all argument types, without duplicates */ typelist = xmalloc( (spec->limit + 1) * sizeof(*typelist) ); @@ -594,12 +624,15 @@ void BuildSpec16File( DLLSPEC *spec ) get_asm_short_keyword() ); output( "\t.long 0\n" ); /* ne_crc */ output( "\t%s 0x%04x\n", get_asm_short_keyword(), /* ne_flags */ - NE_FFLAGS_SINGLEDATA | NE_FFLAGS_LIBMODULE ); + NE_FFLAGS_SINGLEDATA | + ((spec->characteristics & IMAGE_FILE_DLL) ? NE_FFLAGS_LIBMODULE : 0) ); output( "\t%s 2\n", get_asm_short_keyword() ); /* ne_autodata */ output( "\t%s %u\n", get_asm_short_keyword(), spec->heap_size ); /* ne_heap */ output( "\t%s 0\n", get_asm_short_keyword() ); /* ne_stack */ - output( "\t.long 0\n" ); /* ne_csip */ - output( "\t.long 0\n" ); /* ne_sssp */ + if (!entry_point) output( "\t.long 0\n" ); /* ne_csip */ + else output( "\t%s .L__wine_%s_0-.L__wine_spec_code_segment,1\n", + get_asm_short_keyword(), make_c_identifier(spec->dll_name) ); + output( "\t%s 0,2\n", get_asm_short_keyword() ); /* ne_sssp */ output( "\t%s 2\n", get_asm_short_keyword() ); /* ne_cseg */ output( "\t%s 0\n", get_asm_short_keyword() ); /* ne_cmod */ output( "\t%s 0\n", get_asm_short_keyword() ); /* ne_cbnrestab */ diff --git a/reactos/tools/winebuild/spec32.c b/reactos/tools/winebuild/spec32.c index 07c5026dd8e..afbeb0583fd 100644 --- a/reactos/tools/winebuild/spec32.c +++ b/reactos/tools/winebuild/spec32.c @@ -417,13 +417,38 @@ void BuildSpec32File( DLLSPEC *spec ) /* Reserve some space for the PE header */ - output( "\t.text\n" ); - output( "\t.align %d\n", get_alignment(page_size) ); - output( "__wine_spec_pe_header:\n" ); - if (target_platform == PLATFORM_APPLE) + switch (target_platform) + { + case PLATFORM_APPLE: + output( "\t.text\n" ); + output( "\t.align %d\n", get_alignment(page_size) ); + output( "__wine_spec_pe_header:\n" ); output( "\t.space 65536\n" ); - else - output( "\t.skip 65536\n" ); + break; + case PLATFORM_SOLARIS: + output( "\n\t.section \".text\",\"ax\"\n" ); + output( "__wine_spec_pe_header:\n" ); + output( "\t.skip %u\n", 65536 + page_size ); + break; + default: + output( "\n\t.section \".init\",\"ax\"\n" ); + switch(target_cpu) + { + case CPU_x86: + case CPU_x86_64: + case CPU_ALPHA: + case CPU_SPARC: + output( "\tjmp 1f\n" ); + break; + case CPU_POWERPC: + output( "\tb 1f\n" ); + break; + } + output( "__wine_spec_pe_header:\n" ); + output( "\t.skip %u\n", 65536 + page_size ); + output( "1:\n" ); + break; + } /* Output the NT header */