Preserve 16-byte stack alignment in the various assembly

functions. Needed for MacOSX.
This commit is contained in:
Alexandre Julliard 2005-11-23 19:55:06 +01:00
parent 5b5a2f320f
commit cc01e8ff05
10 changed files with 51 additions and 24 deletions

View File

@ -285,14 +285,23 @@ extern int call_entry_point( void *func, int nb_args, const int *args );
__ASM_GLOBAL_FUNC( call_entry_point,
"\tpushl %ebp\n"
"\tmovl %esp,%ebp\n"
"\tpushl %esi\n"
"\tpushl %edi\n"
"\tmovl 12(%ebp),%edx\n"
"\tshll $2,%edx\n"
"\tjz 1f\n"
"\tsubl %edx,%esp\n"
"\tandl $~15,%esp\n"
"\tmovl 12(%ebp),%ecx\n"
"\tmovl 16(%ebp),%edx\n"
"\tjecxz 1f\n"
"2:\tpushl -4(%edx,%ecx,4)\n"
"\tloop 2b\n"
"\tmovl 16(%ebp),%esi\n"
"\tmovl %esp,%edi\n"
"\tcld\n"
"\trep; movsl\n"
"1:\tcall *8(%ebp)\n"
"\tmovl %ebp,%esp\n"
"\tleave\n"
"\tleal -8(%ebp),%esp\n"
"\tpopl %edi\n"
"\tpopl %esi\n"
"\tpopl %ebp\n"
"\tret" );

View File

@ -125,6 +125,7 @@ __ASM_GLOBAL_FUNC(_chkesp,
"ret\n"
"1:\tpushl %ebp\n\t"
"movl %esp,%ebp\n\t"
"subl $12,%esp\n\t"
"pushl %eax\n\t"
"pushl %ecx\n\t"
"pushl %edx\n\t"
@ -132,7 +133,7 @@ __ASM_GLOBAL_FUNC(_chkesp,
"popl %edx\n\t"
"popl %ecx\n\t"
"popl %eax\n\t"
"popl %ebp\n\t"
"leave\n\t"
"ret");
void MSVCRT_chkesp_fail(void)

View File

@ -144,6 +144,7 @@ __ASM_GLOBAL_FUNC(call_dll_entry_point,
"pushl %ebp\n\t"
"movl %esp,%ebp\n\t"
"pushl %ebx\n\t"
"subl $8,%esp\n\t"
"pushl 20(%ebp)\n\t"
"pushl 16(%ebp)\n\t"
"pushl 12(%ebp)\n\t"

View File

@ -451,14 +451,23 @@ extern LONGLONG call_entry_point( void *func, int nb_args, const int *args );
__ASM_GLOBAL_FUNC( call_entry_point,
"\tpushl %ebp\n"
"\tmovl %esp,%ebp\n"
"\tpushl %esi\n"
"\tpushl %edi\n"
"\tmovl 12(%ebp),%edx\n"
"\tshll $2,%edx\n"
"\tjz 1f\n"
"\tsubl %edx,%esp\n"
"\tandl $~15,%esp\n"
"\tmovl 12(%ebp),%ecx\n"
"\tmovl 16(%ebp),%edx\n"
"\tjecxz 1f\n"
"2:\tpushl -4(%edx,%ecx,4)\n"
"\tloop 2b\n"
"\tmovl 16(%ebp),%esi\n"
"\tmovl %esp,%edi\n"
"\tcld\n"
"\trep; movsl\n"
"1:\tcall *8(%ebp)\n"
"\tmovl %ebp,%esp\n"
"\tleave\n"
"\tleal -8(%ebp),%esp\n"
"\tpopl %edi\n"
"\tpopl %esi\n"
"\tpopl %ebp\n"
"\tret" );

View File

@ -364,16 +364,17 @@ static inline NTSTATUS access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_
#ifdef __i386__
/* Shrinker depends on the "call access_resource" instruction being there */
__ASM_GLOBAL_FUNC( LdrAccessResource,
"pushl %ebp\n"
"movl %esp, %ebp\n"
"pushl 24(%ebp)\n"
"pushl 20(%ebp)\n"
"pushl 16(%ebp)\n"
"pushl 12(%ebp)\n"
"pushl 8(%ebp)\n"
"call " __ASM_NAME("access_resource") "\n"
"leave\n"
"ret $16\n"
"pushl %ebp\n\t"
"movl %esp, %ebp\n\t"
"subl $4,%esp\n\t"
"pushl 24(%ebp)\n\t"
"pushl 20(%ebp)\n\t"
"pushl 16(%ebp)\n\t"
"pushl 12(%ebp)\n\t"
"pushl 8(%ebp)\n\t"
"call " __ASM_NAME("access_resource") "\n\t"
"leave\n\t"
"ret $16"
);
#else
NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,

View File

@ -1450,6 +1450,7 @@ __ASM_GLOBAL_FUNC( DbgUserBreakPoint, "int $3; ret");
__ASM_GLOBAL_FUNC( EXC_CallHandler,
" pushl %ebp\n"
" movl %esp, %ebp\n"
" subl $4,%esp\n"
" movl 28(%ebp), %edx\n" /* ugly hack to pass the 6th param needed because of Shrinker */
" pushl 24(%ebp)\n"
" pushl 20(%ebp)\n"
@ -1463,6 +1464,7 @@ __ASM_GLOBAL_FUNC( EXC_CallHandler,
__ASM_GLOBAL_FUNC(call_exception_handler,
" pushl %ebp\n"
" movl %esp, %ebp\n"
" subl $12,%esp\n"
" pushl 12(%ebp)\n" /* make any exceptions in this... */
" pushl %edx\n" /* handler be handled by... */
" .byte 0x64\n"

View File

@ -270,6 +270,7 @@ __ASM_GLOBAL_FUNC( WINPROC_wrapper,
"pushl %edi\n\t"
"pushl %esi\n\t"
"pushl %ebx\n\t"
"subl $12,%esp\n\t"
"pushl 24(%ebp)\n\t"
"pushl 20(%ebp)\n\t"
"pushl 16(%ebp)\n\t"

View File

@ -59,6 +59,8 @@ __ASM_GLOBAL_FUNC( wine_switch_to_stack,
"movl 4(%esp),%ecx\n\t" /* func */
"movl 8(%esp),%edx\n\t" /* arg */
"movl 12(%esp),%esp\n\t" /* stack */
"andl $~15,%esp\n\t"
"subl $12,%esp\n\t"
"pushl %edx\n\t"
"xorl %ebp,%ebp\n\t"
"call *%ecx\n\t"

View File

@ -166,7 +166,7 @@ void _start();
extern char _end[];
__ASM_GLOBAL_FUNC(_start,
"\tmovl %esp,%eax\n"
"\tleal -128(%esp),%esp\n" /* allocate some space for extra aux values */
"\tleal -136(%esp),%esp\n" /* allocate some space for extra aux values */
"\tpushl %eax\n" /* orig stack pointer */
"\tpushl %esp\n" /* ptr to orig stack pointer */
"\tcall wld_start\n"

View File

@ -1186,6 +1186,7 @@ void output_stubs( FILE *outfile, DLLSPEC *spec )
fprintf( outfile, "\t.align %d\n", get_alignment(4) );
fprintf( outfile, "\t%s\n", func_declaration(name) );
fprintf( outfile, "%s:\n", asm_name(name) );
fprintf( outfile, "\tsubl $4,%%esp\n" );
if (UsePIC)
{