Improve a bit the assembly generated for import thunks.

This commit is contained in:
Alexandre Julliard 2005-07-01 15:49:39 +00:00
parent 623e272c06
commit 47286920b6
2 changed files with 11 additions and 16 deletions

View File

@ -722,12 +722,11 @@ static BOOL is_register_entry_point( const BYTE *addr )
}
else /* check for import thunk */
{
if (addr[0] != 0x50) return FALSE; /* pushl %%eax */
if (addr[1] != 0x9c) return FALSE; /* pushfl */
if (addr[2] != 0xe8 || addr[3] || addr[4] || addr[5] || addr[6]) return FALSE; /* call .+0 */
if (addr[7] != 0x58) return FALSE; /* popl %%eax */
if (addr[8] != 0x05) return FALSE; /* addl offset,%%eax */
ptr = addr + 7 + *(const int *)(addr + 9);
if (addr[0] != 0x50) return FALSE; /* pushl %eax */
if (addr[1] != 0xe8 || addr[2] || addr[3] || addr[4] || addr[5]) return FALSE; /* call .+0 */
if (addr[6] != 0x58) return FALSE; /* popl %eax */
if (addr[7] != 0x8b || addr[8] != 0x80) return FALSE; /* movl offset(%eax),%eax */
ptr = addr + 6 + *(const int *)(addr + 9);
}
return (*(const char * const*)ptr == (char *)__wine_call_from_32_regs);
}

View File

@ -688,7 +688,7 @@ int resolve_imports( DLLSPEC *spec )
/* output a single import thunk */
static void output_import_thunk( FILE *outfile, const char *name, const char *table, int pos )
{
fprintf( outfile, " \"\\t.align %d\\n\"\n", get_alignment(8) );
fprintf( outfile, " \"\\t.align %d\\n\"\n", get_alignment(4) );
fprintf( outfile, " \"\\t%s\\n\"\n", func_declaration(name) );
fprintf( outfile, " \"\\t.globl %s\\n\"\n", asm_name(name) );
fprintf( outfile, " \"%s:\\n\"\n", asm_name(name) );
@ -708,17 +708,14 @@ static void output_import_thunk( FILE *outfile, const char *name, const char *ta
{
/* special case: need to preserve all registers */
fprintf( outfile, " \"\\tpushl %%eax\\n\"\n" );
fprintf( outfile, " \"\\tpushfl\\n\"\n" );
fprintf( outfile, " \"\\tcall .L__wine_spec_%s\\n\"\n", name );
fprintf( outfile, " \".L__wine_spec_%s:\\n\"\n", name );
fprintf( outfile, " \"\\tpopl %%eax\\n\"\n" );
fprintf( outfile, " \"\\taddl $%d+%s-.L__wine_spec_%s,%%eax\\n\"\n",
pos, asm_name(table), name );
if (!strcmp( name, "__wine_call_from_16_regs" ))
fprintf( outfile, " \"\\t.byte 0x2e\\n\"\n" );
fprintf( outfile, " \"\\tmovl 0(%%eax),%%eax\\n\"\n" );
fprintf( outfile, " \"\\txchgl 4(%%esp),%%eax\\n\"\n" );
fprintf( outfile, " \"\\tpopfl\\n\"\n" );
fprintf( outfile, " \"\\tmovl %s+%d-.L__wine_spec_%s(%%eax),%%eax\\n\"\n",
asm_name(table), pos, name );
fprintf( outfile, " \"\\txchgl %%eax,(%%esp)\\n\"\n" );
fprintf( outfile, " \"\\tret\\n\"\n" );
}
else
@ -726,11 +723,10 @@ static void output_import_thunk( FILE *outfile, const char *name, const char *ta
fprintf( outfile, " \"\\tcall .L__wine_spec_%s\\n\"\n", name );
fprintf( outfile, " \".L__wine_spec_%s:\\n\"\n", name );
fprintf( outfile, " \"\\tpopl %%eax\\n\"\n" );
fprintf( outfile, " \"\\taddl $%d+%s-.L__wine_spec_%s,%%eax\\n\"\n",
pos, asm_name(table), name );
if (strstr( name, "__wine_call_from_16" ))
fprintf( outfile, " \"\\t.byte 0x2e\\n\"\n" );
fprintf( outfile, " \"\\tjmp *0(%%eax)\\n\"\n" );
fprintf( outfile, " \"\\tjmp *%s+%d-.L__wine_spec_%s(%%eax)\\n\"\n",
asm_name(table), pos, name );
}
}
break;