From e4b9a501a3ddbbfb2cd8aee6eb9330f6af91fe6d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 12 Mar 2019 10:02:04 +0100 Subject: [PATCH] winebuild: Support generating a .spec.o file for Windows platforms. Signed-off-by: Alexandre Julliard --- tools/winebuild/build.h | 1 + tools/winebuild/main.c | 3 ++- tools/winebuild/res32.c | 9 ++++++--- tools/winebuild/spec32.c | 23 ++++++++++++++++++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 44fa317e8bd..1d4f217ae1d 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -303,6 +303,7 @@ 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_spec32_file( DLLSPEC *spec ); +extern void output_pe_module( DLLSPEC *spec ); 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 ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index d7bc39f8c8f..781d391f830 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -645,7 +645,8 @@ int main(int argc, char **argv) output_spec16_file( spec ); break; case SPEC_WIN32: - output_spec32_file( spec ); + if (target_platform == PLATFORM_WINDOWS) output_pe_module( spec ); + else output_spec32_file( spec ); break; default: assert(0); } diff --git a/tools/winebuild/res32.c b/tools/winebuild/res32.c index 16e5c655515..634c933bfea 100644 --- a/tools/winebuild/res32.c +++ b/tools/winebuild/res32.c @@ -441,7 +441,7 @@ void output_resources( DLLSPEC *spec ) /* output the resource directories */ output( "\n/* resources */\n\n" ); - output( "\t.data\n" ); + output( "\t.section %s\n", target_platform == PLATFORM_WINDOWS ? ".rsrc" : ".data" ); output( "\t.align %d\n", get_alignment(get_ptr_size()) ); output( ".L__wine_spec_resources:\n" ); @@ -498,9 +498,12 @@ void output_resources( DLLSPEC *spec ) output( ".L__wine_spec_res_%d:\n", i ); dump_res_data( res ); } - output( ".L__wine_spec_resources_end:\n" ); - output( "\t.byte 0\n" ); + if (target_platform != PLATFORM_WINDOWS) + { + output( ".L__wine_spec_resources_end:\n" ); + output( "\t.byte 0\n" ); + } free_resource_tree( tree ); } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 7b4d66191ff..d0c147df59b 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -384,7 +384,7 @@ void output_exports( DLLSPEC *spec ) if (!nr_exports) return; output( "\n/* export table */\n\n" ); - output( "\t.data\n" ); + output( "\t.section %s\n", target_platform == PLATFORM_WINDOWS ? ".edata" : ".data" ); output( "\t.align %d\n", get_alignment(4) ); output( ".L__wine_spec_exports:\n" ); @@ -492,6 +492,9 @@ void output_exports( DLLSPEC *spec ) output( "\t%s \"%s\"\n", get_asm_string_keyword(), odp->link_name ); } } + + if (target_platform == PLATFORM_WINDOWS) return; + output( "\t.align %d\n", get_alignment(get_ptr_size()) ); output( ".L__wine_spec_exports_end:\n" ); @@ -707,6 +710,24 @@ void output_spec32_file( DLLSPEC *spec ) } +/******************************************************************* + * output_pe_module + * + * Build a PE from a spec file. + */ +void output_pe_module( DLLSPEC *spec ) +{ + UsePIC = 0; + resolve_imports( spec ); + open_output_file(); + output_standard_file_header(); + output_stubs( spec ); + output_exports( spec ); + output_resources( spec ); + close_output_file(); +} + + /******************************************************************* * output_fake_module *