ChangeSet ID: 21507 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/28 14:11:02
Modified files: tools/winebuild: spec16.c
Log message: Preserve 16-byte stack alignment in 16-bit relays.
Patch: http://cvs.winehq.org/patch.py?id=21507
Old revision New revision Changes Path 1.64 1.65 +14 -6 wine/tools/winebuild/spec16.c
Index: wine/tools/winebuild/spec16.c diff -u -p wine/tools/winebuild/spec16.c:1.64 wine/tools/winebuild/spec16.c:1.65 --- wine/tools/winebuild/spec16.c:1.64 28 Nov 2005 20:11: 2 -0000 +++ wine/tools/winebuild/spec16.c 28 Nov 2005 20:11: 2 -0000 @@ -286,7 +286,7 @@ static int get_function_argsize( const O static void output_call16_function( FILE *outfile, ORDDEF *odp ) { char name[256]; - int i, pos; + int i, pos, stack_words; const char *args = odp->u.func.arg_types; int argsize = get_function_argsize( odp ); int needs_ldt = strchr( args, 'p' ) || strchr( args, 't' ); @@ -298,19 +298,25 @@ static void output_call16_function( FILE fprintf( outfile, "%s:\n", name ); fprintf( outfile, "\tpushl %%ebp\n" ); fprintf( outfile, "\tmovl %%esp,%%ebp\n" ); + stack_words = 2; if (needs_ldt) { fprintf( outfile, "\tpushl %%esi\n" ); + stack_words++; if (UsePIC) { - fprintf( outfile, "\tcall 1f\n" ); - fprintf( outfile, "1:\tpopl %%eax\n" ); - fprintf( outfile, "\tmovl wine_ldt_copy_ptr-1b(%%eax),%%esi\n" ); + fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") ); + fprintf( outfile, "1:\tmovl wine_ldt_copy_ptr-1b(%%eax),%%esi\n" ); } else fprintf( outfile, "\tmovl $%s,%%esi\n", asm_name("wine_ldt_copy") ); }
+ /* preserve 16-byte stack alignment */ + stack_words += strlen(args); + if ((odp->flags & FLAG_REGISTER) || (odp->type == TYPE_VARARGS)) stack_words++; + if (stack_words % 4) fprintf( outfile, "\tsubl $%d,%%esp\n", 16 - 4 * (stack_words % 4) ); + if (args[0] || odp->type == TYPE_VARARGS) fprintf( outfile, "\tmovl 12(%%ebp),%%ecx\n" ); /* args */
@@ -456,6 +462,7 @@ static void output_init_code( FILE *outf fprintf( outfile, "\t.align 4\n" ); fprintf( outfile, "\t%s\n", func_declaration(name) ); fprintf( outfile, "%s:\n", name ); + fprintf( outfile, "subl $4,%%esp\n" ); if (UsePIC) { fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") ); @@ -470,7 +477,7 @@ static void output_init_code( FILE *outf fprintf( outfile, "\tpushl $%s\n", header_name ); } fprintf( outfile, "\tcall %s\n", asm_name("__wine_dll_register_16") ); - fprintf( outfile, "\taddl $8,%%esp\n" ); + fprintf( outfile, "\taddl $12,%%esp\n" ); fprintf( outfile, "\tret\n" ); output_function_size( outfile, name );
@@ -479,6 +486,7 @@ static void output_init_code( FILE *outf fprintf( outfile, "\t.align 4\n" ); fprintf( outfile, "\t%s\n", func_declaration(name) ); fprintf( outfile, "%s:\n", name ); + fprintf( outfile, "subl $8,%%esp\n" ); if (UsePIC) { fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") ); @@ -490,7 +498,7 @@ static void output_init_code( FILE *outf fprintf( outfile, "\tpushl $%s\n", header_name ); } fprintf( outfile, "\tcall %s\n", asm_name("__wine_dll_unregister_16") ); - fprintf( outfile, "\taddl $4,%%esp\n" ); + fprintf( outfile, "\taddl $12,%%esp\n" ); fprintf( outfile, "\tret\n" ); output_function_size( outfile, name );