diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 91c4734d95a..e600398dcd6 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -529,7 +529,7 @@ static int output_immediate_imports( FILE *outfile ) } pos += 4; } - fprintf( outfile, "\".previous\");\n#ifndef __GNUC__\n}\n#endif\n\n" ); + fprintf( outfile, "\".section\\t\\\".text\\\"\");\n#ifndef __GNUC__\n}\n#endif\n\n" ); done: return nb_imm; @@ -735,7 +735,7 @@ static int output_delayed_imports( FILE *outfile ) fprintf( outfile, "\"\n" ); } } - fprintf( outfile, "\".previous\");\n" ); + fprintf( outfile, "\".section \\\".text\\\"\");\n" ); fprintf( outfile, "#ifndef __GNUC__\n" ); fprintf( outfile, "}\n" ); fprintf( outfile, "#endif\n" ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index daeccdc17d5..5c3134e18cb 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -118,6 +118,7 @@ static void do_warnings(void); static void do_f_flags( const char *arg ); static void do_define( const char *arg ); static void do_include( const char *arg ); +static void do_k_flags( const char *arg ); static void do_exe_mode( const char *arg ); static void do_module( const char *arg ); static void do_spec( const char *arg ); @@ -142,6 +143,7 @@ static const struct option_descr option_table[] = { "-f", 1, do_f_flags, "-f flags Compiler flags (only -fPIC is supported)" }, { "-D", 1, do_define, "-D sym Ignored for C flags compatibility" }, { "-I", 1, do_include, "-I dir Ignored for C flags compatibility" }, + { "-K", 1, do_k_flags, "-K flags Compiler flags (only -KPIC is supported)" }, { "-m", 1, do_exe_mode,"-m mode Set the executable mode (cui|gui|cuiw|guiw)" }, { "-M", 1, do_module, "-M module Set the name of the main (Win32) module for a Win16 dll" }, { "-L", 1, do_lib, "-L directory Look for imports libraries in 'directory'" }, @@ -207,6 +209,13 @@ static void do_include( const char *arg ) /* nothing */ } +static void do_k_flags( const char *arg ) +{ + /* Ignored, because cc generates correct code. */ + /* if (!strcmp( arg, "PIC" )) UsePIC = 1; */ + /* ignore all other flags */ +} + static void do_spec( const char *arg ) { char *p; diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 2756defba69..150bf550afd 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -335,6 +335,8 @@ static int output_exports( FILE *outfile, int nr_exports ) } } + fprintf( outfile, " \"\\t.text\\n\"\n" ); + fprintf( outfile, " \"\\t.align %d\\n\"\n", get_alignment(4) ); fprintf( outfile, ");\n\n" ); return total_size; @@ -439,43 +441,43 @@ void output_dll_init( FILE *outfile, const char *constructor, const char *destru #if defined(__i386__) if (constructor) { - fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "%s\\n\"\n", constructor ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); } if (destructor) { - fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "%s\\n\"\n", destructor ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); } #elif defined(__sparc__) if (constructor) { - fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "%s\\n\"\n", constructor ); fprintf( outfile, " \"\\tnop\\n\"\n" ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); } if (destructor) { - fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "%s\\n\"\n", destructor ); fprintf( outfile, " \"\\tnop\\n\"\n" ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); } #elif defined(__PPC__) if (constructor) { - fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tbl " PREFIX "%s\\n\"\n", constructor ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); } if (destructor) { - fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tbl " PREFIX "%s\\n\"\n", destructor ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); } #else #error You need to define the DLL constructor for your architecture @@ -522,9 +524,15 @@ void BuildSpec32File( FILE *outfile ) /* Reserve some space for the PE header */ fprintf( outfile, "extern char pe_header[];\n" ); - fprintf( outfile, "asm(\".section .text\\n\\t\"\n" ); + fprintf( outfile, "#ifndef __GNUC__\n" ); + fprintf( outfile, "static void __asm__dummy_header(void) {\n" ); + fprintf( outfile, "#endif\n" ); + fprintf( outfile, "asm(\".section \\\".text\\\"\\n\\t\"\n" ); fprintf( outfile, " \".align %d\\n\"\n", get_alignment(page_size) ); - fprintf( outfile, " \"" PREFIX "pe_header:\\t.fill %ld,1,0\\n\\t\");\n", page_size ); + fprintf( outfile, " \"" PREFIX "pe_header:\\t.skip %ld\\n\\t\");\n", page_size ); + fprintf( outfile, "#ifndef __GNUC__\n" ); + fprintf( outfile, "}\n" ); + fprintf( outfile, "#endif\n" ); fprintf( outfile, "static const char dllname[] = \"%s\";\n\n", DLLFileName ); fprintf( outfile, "extern int __wine_spec_exports[];\n\n" ); @@ -891,28 +899,25 @@ void BuildDebugFile( FILE *outfile ) prefix, prefix ); #if defined(__i386__) - fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "__wine_dbg_%s_init\\n\"\n", prefix ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); - fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "__wine_dbg_%s_fini\\n\"\n", prefix ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); #elif defined(__sparc__) - fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "__wine_dbg_%s_init\\n\"\n", prefix ); fprintf( outfile, " \"\\tnop\\n\"\n" ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); - fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "__wine_dbg_%s_fini\\n\"\n", prefix ); fprintf( outfile, " \"\\tnop\\n\"\n" ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\t\\\".text\\\"\\n\");\n" ); #elif defined(__PPC__) - fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tbl " PREFIX "__wine_dbg_%s_init\\n\"\n", prefix ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); - fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".fini\\\" ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tbl " PREFIX "__wine_dbg_%s_fini\\n\"\n", prefix ); - fprintf( outfile, " \"\\t.previous\\n\");\n" ); + fprintf( outfile, " \"\\t.section\\t\\\".text\\\"\\n\");\n" ); #else #error You need to define the DLL constructor for your architecture #endif