Commit cc01e8ff authored by Alexandre Julliard's avatar Alexandre Julliard

Preserve 16-byte stack alignment in the various assembly

functions. Needed for MacOSX.
parent 5b5a2f32
...@@ -285,14 +285,23 @@ extern int call_entry_point( void *func, int nb_args, const int *args ); ...@@ -285,14 +285,23 @@ extern int call_entry_point( void *func, int nb_args, const int *args );
__ASM_GLOBAL_FUNC( call_entry_point, __ASM_GLOBAL_FUNC( call_entry_point,
"\tpushl %ebp\n" "\tpushl %ebp\n"
"\tmovl %esp,%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 12(%ebp),%ecx\n"
"\tmovl 16(%ebp),%edx\n" "\tmovl 16(%ebp),%esi\n"
"\tjecxz 1f\n" "\tmovl %esp,%edi\n"
"2:\tpushl -4(%edx,%ecx,4)\n" "\tcld\n"
"\tloop 2b\n" "\trep; movsl\n"
"1:\tcall *8(%ebp)\n" "1:\tcall *8(%ebp)\n"
"\tmovl %ebp,%esp\n" "\tleal -8(%ebp),%esp\n"
"\tleave\n" "\tpopl %edi\n"
"\tpopl %esi\n"
"\tpopl %ebp\n"
"\tret" ); "\tret" );
......
...@@ -125,6 +125,7 @@ __ASM_GLOBAL_FUNC(_chkesp, ...@@ -125,6 +125,7 @@ __ASM_GLOBAL_FUNC(_chkesp,
"ret\n" "ret\n"
"1:\tpushl %ebp\n\t" "1:\tpushl %ebp\n\t"
"movl %esp,%ebp\n\t" "movl %esp,%ebp\n\t"
"subl $12,%esp\n\t"
"pushl %eax\n\t" "pushl %eax\n\t"
"pushl %ecx\n\t" "pushl %ecx\n\t"
"pushl %edx\n\t" "pushl %edx\n\t"
...@@ -132,7 +133,7 @@ __ASM_GLOBAL_FUNC(_chkesp, ...@@ -132,7 +133,7 @@ __ASM_GLOBAL_FUNC(_chkesp,
"popl %edx\n\t" "popl %edx\n\t"
"popl %ecx\n\t" "popl %ecx\n\t"
"popl %eax\n\t" "popl %eax\n\t"
"popl %ebp\n\t" "leave\n\t"
"ret"); "ret");
void MSVCRT_chkesp_fail(void) void MSVCRT_chkesp_fail(void)
......
...@@ -144,6 +144,7 @@ __ASM_GLOBAL_FUNC(call_dll_entry_point, ...@@ -144,6 +144,7 @@ __ASM_GLOBAL_FUNC(call_dll_entry_point,
"pushl %ebp\n\t" "pushl %ebp\n\t"
"movl %esp,%ebp\n\t" "movl %esp,%ebp\n\t"
"pushl %ebx\n\t" "pushl %ebx\n\t"
"subl $8,%esp\n\t"
"pushl 20(%ebp)\n\t" "pushl 20(%ebp)\n\t"
"pushl 16(%ebp)\n\t" "pushl 16(%ebp)\n\t"
"pushl 12(%ebp)\n\t" "pushl 12(%ebp)\n\t"
......
...@@ -451,14 +451,23 @@ extern LONGLONG call_entry_point( void *func, int nb_args, const int *args ); ...@@ -451,14 +451,23 @@ extern LONGLONG call_entry_point( void *func, int nb_args, const int *args );
__ASM_GLOBAL_FUNC( call_entry_point, __ASM_GLOBAL_FUNC( call_entry_point,
"\tpushl %ebp\n" "\tpushl %ebp\n"
"\tmovl %esp,%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 12(%ebp),%ecx\n"
"\tmovl 16(%ebp),%edx\n" "\tmovl 16(%ebp),%esi\n"
"\tjecxz 1f\n" "\tmovl %esp,%edi\n"
"2:\tpushl -4(%edx,%ecx,4)\n" "\tcld\n"
"\tloop 2b\n" "\trep; movsl\n"
"1:\tcall *8(%ebp)\n" "1:\tcall *8(%ebp)\n"
"\tmovl %ebp,%esp\n" "\tleal -8(%ebp),%esp\n"
"\tleave\n" "\tpopl %edi\n"
"\tpopl %esi\n"
"\tpopl %ebp\n"
"\tret" ); "\tret" );
......
...@@ -364,16 +364,17 @@ static inline NTSTATUS access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ ...@@ -364,16 +364,17 @@ static inline NTSTATUS access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_
#ifdef __i386__ #ifdef __i386__
/* Shrinker depends on the "call access_resource" instruction being there */ /* Shrinker depends on the "call access_resource" instruction being there */
__ASM_GLOBAL_FUNC( LdrAccessResource, __ASM_GLOBAL_FUNC( LdrAccessResource,
"pushl %ebp\n" "pushl %ebp\n\t"
"movl %esp, %ebp\n" "movl %esp, %ebp\n\t"
"pushl 24(%ebp)\n" "subl $4,%esp\n\t"
"pushl 20(%ebp)\n" "pushl 24(%ebp)\n\t"
"pushl 16(%ebp)\n" "pushl 20(%ebp)\n\t"
"pushl 12(%ebp)\n" "pushl 16(%ebp)\n\t"
"pushl 8(%ebp)\n" "pushl 12(%ebp)\n\t"
"call " __ASM_NAME("access_resource") "\n" "pushl 8(%ebp)\n\t"
"leave\n" "call " __ASM_NAME("access_resource") "\n\t"
"ret $16\n" "leave\n\t"
"ret $16"
); );
#else #else
NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry, NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
......
...@@ -1450,6 +1450,7 @@ __ASM_GLOBAL_FUNC( DbgUserBreakPoint, "int $3; ret"); ...@@ -1450,6 +1450,7 @@ __ASM_GLOBAL_FUNC( DbgUserBreakPoint, "int $3; ret");
__ASM_GLOBAL_FUNC( EXC_CallHandler, __ASM_GLOBAL_FUNC( EXC_CallHandler,
" pushl %ebp\n" " pushl %ebp\n"
" movl %esp, %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 */ " movl 28(%ebp), %edx\n" /* ugly hack to pass the 6th param needed because of Shrinker */
" pushl 24(%ebp)\n" " pushl 24(%ebp)\n"
" pushl 20(%ebp)\n" " pushl 20(%ebp)\n"
...@@ -1463,6 +1464,7 @@ __ASM_GLOBAL_FUNC( EXC_CallHandler, ...@@ -1463,6 +1464,7 @@ __ASM_GLOBAL_FUNC( EXC_CallHandler,
__ASM_GLOBAL_FUNC(call_exception_handler, __ASM_GLOBAL_FUNC(call_exception_handler,
" pushl %ebp\n" " pushl %ebp\n"
" movl %esp, %ebp\n" " movl %esp, %ebp\n"
" subl $12,%esp\n"
" pushl 12(%ebp)\n" /* make any exceptions in this... */ " pushl 12(%ebp)\n" /* make any exceptions in this... */
" pushl %edx\n" /* handler be handled by... */ " pushl %edx\n" /* handler be handled by... */
" .byte 0x64\n" " .byte 0x64\n"
......
...@@ -270,6 +270,7 @@ __ASM_GLOBAL_FUNC( WINPROC_wrapper, ...@@ -270,6 +270,7 @@ __ASM_GLOBAL_FUNC( WINPROC_wrapper,
"pushl %edi\n\t" "pushl %edi\n\t"
"pushl %esi\n\t" "pushl %esi\n\t"
"pushl %ebx\n\t" "pushl %ebx\n\t"
"subl $12,%esp\n\t"
"pushl 24(%ebp)\n\t" "pushl 24(%ebp)\n\t"
"pushl 20(%ebp)\n\t" "pushl 20(%ebp)\n\t"
"pushl 16(%ebp)\n\t" "pushl 16(%ebp)\n\t"
......
...@@ -59,6 +59,8 @@ __ASM_GLOBAL_FUNC( wine_switch_to_stack, ...@@ -59,6 +59,8 @@ __ASM_GLOBAL_FUNC( wine_switch_to_stack,
"movl 4(%esp),%ecx\n\t" /* func */ "movl 4(%esp),%ecx\n\t" /* func */
"movl 8(%esp),%edx\n\t" /* arg */ "movl 8(%esp),%edx\n\t" /* arg */
"movl 12(%esp),%esp\n\t" /* stack */ "movl 12(%esp),%esp\n\t" /* stack */
"andl $~15,%esp\n\t"
"subl $12,%esp\n\t"
"pushl %edx\n\t" "pushl %edx\n\t"
"xorl %ebp,%ebp\n\t" "xorl %ebp,%ebp\n\t"
"call *%ecx\n\t" "call *%ecx\n\t"
......
...@@ -166,7 +166,7 @@ void _start(); ...@@ -166,7 +166,7 @@ void _start();
extern char _end[]; extern char _end[];
__ASM_GLOBAL_FUNC(_start, __ASM_GLOBAL_FUNC(_start,
"\tmovl %esp,%eax\n" "\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 %eax\n" /* orig stack pointer */
"\tpushl %esp\n" /* ptr to orig stack pointer */ "\tpushl %esp\n" /* ptr to orig stack pointer */
"\tcall wld_start\n" "\tcall wld_start\n"
......
...@@ -1186,6 +1186,7 @@ void output_stubs( FILE *outfile, DLLSPEC *spec ) ...@@ -1186,6 +1186,7 @@ void output_stubs( FILE *outfile, DLLSPEC *spec )
fprintf( outfile, "\t.align %d\n", get_alignment(4) ); fprintf( outfile, "\t.align %d\n", get_alignment(4) );
fprintf( outfile, "\t%s\n", func_declaration(name) ); fprintf( outfile, "\t%s\n", func_declaration(name) );
fprintf( outfile, "%s:\n", asm_name(name) ); fprintf( outfile, "%s:\n", asm_name(name) );
fprintf( outfile, "\tsubl $4,%%esp\n" );
if (UsePIC) if (UsePIC)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment