diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index a4b9bc97e3e..4fb6e23700e 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -153,6 +153,7 @@ enum target_platform PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_FREEBSD, + PLATFORM_MINGW, PLATFORM_SOLARIS, PLATFORM_WINDOWS }; @@ -161,6 +162,11 @@ extern char *target_alias; extern enum target_cpu target_cpu; extern enum target_platform target_platform; +static inline int is_pe(void) +{ + return target_platform == PLATFORM_MINGW || target_platform == PLATFORM_WINDOWS; +} + struct strarray { const char **str; diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 2ff63c2265d..827a875e5df 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -1742,7 +1742,7 @@ void output_syscalls( DLLSPEC *spec ) output( "\t.byte 0xc3\n" ); /* ret */ output( "\tjmp 1f\n" ); output( "\t.byte 0xc3\n" ); /* ret */ - if (target_platform == PLATFORM_WINDOWS) + if (is_pe()) { output( "1:\t.byte 0xff,0x14,0x25\n" ); /* 1: callq *(0x7ffe1000) */ output( "\t.long 0x7ffe1000\n" ); @@ -1803,7 +1803,7 @@ void output_syscalls( DLLSPEC *spec ) /* output the import and delayed import tables of a Win32 module */ void output_imports( DLLSPEC *spec ) { - if (target_platform == PLATFORM_WINDOWS) return; + if (is_pe()) return; output_immediate_imports(); output_delayed_imports( spec ); output_immediate_import_thunks(); @@ -1958,7 +1958,7 @@ static void build_unix_import_lib( DLLSPEC *spec ) /* output an import library for a Win32 module and additional object files */ void output_static_lib( DLLSPEC *spec, char **argv ) { - if (target_platform == PLATFORM_WINDOWS) + if (is_pe()) { if (spec) build_windows_import_lib( spec ); if (argv[0] || !spec) build_library( output_file_name, argv, !spec ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index abb94e27c03..1477df7f259 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -71,7 +71,7 @@ enum target_platform target_platform = PLATFORM_FREEBSD; #elif defined(__sun) enum target_platform target_platform = PLATFORM_SOLARIS; #elif defined(_WIN32) -enum target_platform target_platform = PLATFORM_WINDOWS; +enum target_platform target_platform = PLATFORM_MINGW; #else enum target_platform target_platform = PLATFORM_UNSPECIFIED; #endif @@ -129,13 +129,14 @@ static const struct enum target_platform platform; } platform_names[] = { - { "macos", PLATFORM_APPLE }, - { "darwin", PLATFORM_APPLE }, - { "freebsd", PLATFORM_FREEBSD }, - { "solaris", PLATFORM_SOLARIS }, - { "mingw32", PLATFORM_WINDOWS }, - { "windows", PLATFORM_WINDOWS }, - { "winnt", PLATFORM_WINDOWS } + { "macos", PLATFORM_APPLE }, + { "darwin", PLATFORM_APPLE }, + { "freebsd", PLATFORM_FREEBSD }, + { "solaris", PLATFORM_SOLARIS }, + { "mingw32", PLATFORM_MINGW }, + { "windows-gnu", PLATFORM_MINGW }, + { "windows", PLATFORM_WINDOWS }, + { "winnt", PLATFORM_MINGW } }; /* set the dll file name from the input file name */ @@ -245,7 +246,7 @@ static void set_target( const char *target ) free( spec ); - if (target_cpu == CPU_ARM && target_platform == PLATFORM_WINDOWS) thumb_mode = 1; + if (target_cpu == CPU_ARM && is_pe()) thumb_mode = 1; } /* cleanup on program exit */ @@ -710,7 +711,7 @@ int main(int argc, char **argv) else output_fake_module( spec ); break; } - if (target_platform != PLATFORM_WINDOWS) + if (!is_pe()) { load_import_libs( argv ); read_undef_symbols( spec, argv ); diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c index dc0960761a5..0544aa6cbe9 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -379,7 +379,7 @@ static void BuildCallFrom16Core( int reg_func, int thunk ) static void BuildCallTo16Core( int reg_func ) { const char *name = reg_func ? "wine_call_to_16_regs" : "wine_call_to_16"; - const char *func_name = (target_platform == PLATFORM_WINDOWS ? strmake( "%s@12", name ) : name); + const char *func_name = is_pe() ? strmake( "%s@12", name ) : name; /* Function header */ function_header( func_name ); diff --git a/tools/winebuild/res32.c b/tools/winebuild/res32.c index bd55bb2fa5c..f2bbbe0d794 100644 --- a/tools/winebuild/res32.c +++ b/tools/winebuild/res32.c @@ -499,7 +499,7 @@ void output_resources( DLLSPEC *spec ) dump_res_data( res ); } - if (target_platform != PLATFORM_WINDOWS) + if (!is_pe()) { output( ".L__wine_spec_resources_end:\n" ); output( "\t.byte 0\n" ); diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index cf1dd353ae5..678f104c555 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -410,7 +410,7 @@ void output_exports( DLLSPEC *spec ) int needs_imports = 0; int needs_relay = has_relays( spec ); int nr_exports = get_exports_count( spec ); - const char *func_ptr = (target_platform == PLATFORM_WINDOWS) ? ".rva" : get_asm_ptr_keyword(); + const char *func_ptr = is_pe() ? ".rva" : get_asm_ptr_keyword(); const char *name; if (!nr_exports) return; @@ -447,8 +447,7 @@ void output_exports( DLLSPEC *spec ) for (i = spec->base; i <= spec->limit; i++) { ORDDEF *odp = spec->ordinals[i]; - if (!odp) output( "\t%s 0\n", - (target_platform == PLATFORM_WINDOWS) ? ".long" : get_asm_ptr_keyword() ); + if (!odp) output( "\t%s 0\n", is_pe() ? ".long" : get_asm_ptr_keyword() ); else switch(odp->type) { case TYPE_EXTERN: @@ -513,7 +512,7 @@ void output_exports( DLLSPEC *spec ) if (needs_relay) { output( "\t.long 0xdeb90002\n" ); /* magic */ - if (target_platform == PLATFORM_WINDOWS) output_rva( ".L__wine_spec_relay_descr" ); + if (is_pe()) output_rva( ".L__wine_spec_relay_descr" ); else output( "\t.long 0\n" ); } @@ -542,7 +541,7 @@ void output_exports( DLLSPEC *spec ) if (needs_relay) { - if (target_platform == PLATFORM_WINDOWS) + if (is_pe()) { output( "\t.data\n" ); output( "\t.align %d\n", get_alignment(get_ptr_size()) ); @@ -563,7 +562,7 @@ void output_exports( DLLSPEC *spec ) output_relay_debug( spec ); } - else if (target_platform != PLATFORM_WINDOWS) + else if (!is_pe()) { output( "\t.align %d\n", get_alignment(get_ptr_size()) ); output( ".L__wine_spec_exports_end:\n" ); @@ -628,6 +627,7 @@ void output_module( DLLSPEC *spec ) switch (target_platform) { + case PLATFORM_MINGW: case PLATFORM_WINDOWS: return; /* nothing to do */ case PLATFORM_APPLE: @@ -1010,7 +1010,7 @@ void output_def_file( DLLSPEC *spec, int import_only ) if (!is_private) total++; if (import_only && odp->type == TYPE_STUB) continue; - if ((odp->flags & FLAG_FASTCALL) && target_platform == PLATFORM_WINDOWS) + if ((odp->flags & FLAG_FASTCALL) && is_pe()) name = strmake( "@%s", name ); output( " %s", name ); diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 1a11d275cb3..928a2460aa1 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -462,6 +462,7 @@ struct strarray get_ld_command(void) case PLATFORM_FREEBSD: strarray_add( &args, "-m", (force_pointer_size == 8) ? "elf_x86_64_fbsd" : "elf_i386_fbsd", NULL ); break; + case PLATFORM_MINGW: case PLATFORM_WINDOWS: strarray_add( &args, "-m", (force_pointer_size == 8) ? "i386pep" : "i386pe", NULL ); break; @@ -479,7 +480,7 @@ struct strarray get_ld_command(void) } } - if (target_cpu == CPU_ARM && target_platform != PLATFORM_WINDOWS) + if (target_cpu == CPU_ARM && !is_pe()) strarray_add( &args, "--no-wchar-size-warning", NULL ); return args; @@ -931,7 +932,7 @@ const char *get_link_name( const ORDDEF *odp ) switch (odp->type) { case TYPE_STDCALL: - if (target_platform == PLATFORM_WINDOWS) + if (is_pe()) { if (odp->flags & FLAG_THISCALL) return odp->link_name; if (odp->flags & FLAG_FASTCALL) ret = strmake( "@%s@%u", odp->link_name, get_args_size( odp )); @@ -947,7 +948,7 @@ const char *get_link_name( const ORDDEF *odp ) break; case TYPE_PASCAL: - if (target_platform == PLATFORM_WINDOWS && !kill_at) + if (is_pe() && !kill_at) { int args = get_args_size( odp ); if (odp->flags & FLAG_REGISTER) args += get_ptr_size(); /* context argument */ @@ -1099,6 +1100,7 @@ const char *asm_name( const char *sym ) switch (target_platform) { + case PLATFORM_MINGW: case PLATFORM_WINDOWS: if (target_cpu != CPU_x86) return sym; if (sym[0] == '@') return sym; /* fastcall */ @@ -1122,6 +1124,7 @@ const char *func_declaration( const char *func ) { case PLATFORM_APPLE: return ""; + case PLATFORM_MINGW: case PLATFORM_WINDOWS: free( buffer ); buffer = strmake( ".def %s\n\t.scl 2\n\t.type 32\n\t.endef%s", asm_name(func), @@ -1153,6 +1156,7 @@ void output_function_size( const char *name ) switch (target_platform) { case PLATFORM_APPLE: + case PLATFORM_MINGW: case PLATFORM_WINDOWS: break; default: @@ -1182,6 +1186,7 @@ void output_rva( const char *format, ... ) va_start( valist, format ); switch (target_platform) { + case PLATFORM_MINGW: case PLATFORM_WINDOWS: output( "\t.rva " ); vfprintf( output_file, format, valist ); @@ -1201,6 +1206,7 @@ void output_gnu_stack_note(void) { switch (target_platform) { + case PLATFORM_MINGW: case PLATFORM_WINDOWS: case PLATFORM_APPLE: break; @@ -1230,6 +1236,7 @@ const char *asm_globl( const char *func ) case PLATFORM_APPLE: buffer = strmake( "\t.globl _%s\n\t.private_extern _%s\n_%s:", func, func, func ); break; + case PLATFORM_MINGW: case PLATFORM_WINDOWS: buffer = strmake( "\t.globl %s%s\n%s%s:", target_cpu == CPU_x86 ? "_" : "", func, target_cpu == CPU_x86 ? "_" : "", func ); @@ -1268,6 +1275,7 @@ const char *get_asm_export_section(void) switch (target_platform) { case PLATFORM_APPLE: return ".data"; + case PLATFORM_MINGW: case PLATFORM_WINDOWS: return ".section .edata"; default: return ".section .data"; } @@ -1287,6 +1295,7 @@ const char *get_asm_rsrc_section(void) switch (target_platform) { case PLATFORM_APPLE: return ".data"; + case PLATFORM_MINGW: case PLATFORM_WINDOWS: return ".section .rsrc"; default: return ".section .data"; }