Commit 0c463415 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add call frame annotations in x86 assembly code.

parent 065287ed
...@@ -148,8 +148,12 @@ static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len ) ...@@ -148,8 +148,12 @@ static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
extern BOOL call_dll_entry_point( DLLENTRYPROC proc, void *module, UINT reason, void *reserved ); extern BOOL call_dll_entry_point( DLLENTRYPROC proc, void *module, UINT reason, void *reserved );
__ASM_GLOBAL_FUNC(call_dll_entry_point, __ASM_GLOBAL_FUNC(call_dll_entry_point,
"pushl %ebp\n\t" "pushl %ebp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"movl %esp,%ebp\n\t" "movl %esp,%ebp\n\t"
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
"pushl %ebx\n\t" "pushl %ebx\n\t"
__ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
"subl $8,%esp\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"
...@@ -158,7 +162,10 @@ __ASM_GLOBAL_FUNC(call_dll_entry_point, ...@@ -158,7 +162,10 @@ __ASM_GLOBAL_FUNC(call_dll_entry_point,
"call *%eax\n\t" "call *%eax\n\t"
"leal -4(%ebp),%esp\n\t" "leal -4(%ebp),%esp\n\t"
"popl %ebx\n\t" "popl %ebx\n\t"
__ASM_CFI(".cfi_same_value %ebx\n\t")
"popl %ebp\n\t" "popl %ebp\n\t"
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
__ASM_CFI(".cfi_same_value %ebp\n\t")
"ret" ) "ret" )
#else /* __i386__ */ #else /* __i386__ */
static inline BOOL call_dll_entry_point( DLLENTRYPROC proc, void *module, static inline BOOL call_dll_entry_point( DLLENTRYPROC proc, void *module,
......
...@@ -320,26 +320,35 @@ static inline void RELAY_PrintArgs( const INT_PTR *args, int nb_args, unsigned i ...@@ -320,26 +320,35 @@ static inline void RELAY_PrintArgs( const INT_PTR *args, int nb_args, unsigned i
extern LONGLONG CDECL call_entry_point( void *func, int nb_args, const INT_PTR *args ); extern LONGLONG CDECL call_entry_point( void *func, int nb_args, const INT_PTR *args );
#ifdef __i386__ #ifdef __i386__
__ASM_GLOBAL_FUNC( call_entry_point, __ASM_GLOBAL_FUNC( call_entry_point,
"\tpushl %ebp\n" "pushl %ebp\n\t"
"\tmovl %esp,%ebp\n" __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"\tpushl %esi\n" __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"\tpushl %edi\n" "movl %esp,%ebp\n\t"
"\tmovl 12(%ebp),%edx\n" __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
"\tshll $2,%edx\n" "pushl %esi\n\t"
"\tjz 1f\n" __ASM_CFI(".cfi_rel_offset %esi,-4\n\t")
"\tsubl %edx,%esp\n" "pushl %edi\n\t"
"\tandl $~15,%esp\n" __ASM_CFI(".cfi_rel_offset %edi,-8\n\t")
"\tmovl 12(%ebp),%ecx\n" "movl 12(%ebp),%edx\n\t"
"\tmovl 16(%ebp),%esi\n" "shll $2,%edx\n\t"
"\tmovl %esp,%edi\n" "jz 1f\n\t"
"\tcld\n" "subl %edx,%esp\n\t"
"\trep; movsl\n" "andl $~15,%esp\n\t"
"1:\tcall *8(%ebp)\n" "movl 12(%ebp),%ecx\n\t"
"\tleal -8(%ebp),%esp\n" "movl 16(%ebp),%esi\n\t"
"\tpopl %edi\n" "movl %esp,%edi\n\t"
"\tpopl %esi\n" "cld\n\t"
"\tpopl %ebp\n" "rep; movsl\n"
"\tret" ) "1:\tcall *8(%ebp)\n\t"
"leal -8(%ebp),%esp\n\t"
"popl %edi\n\t"
__ASM_CFI(".cfi_same_value %edi\n\t")
"popl %esi\n\t"
__ASM_CFI(".cfi_same_value %esi\n\t")
"popl %ebp\n\t"
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
__ASM_CFI(".cfi_same_value %ebp\n\t")
"ret" )
#else #else
__ASM_GLOBAL_FUNC( call_entry_point, __ASM_GLOBAL_FUNC( call_entry_point,
"pushq %rbp\n\t" "pushq %rbp\n\t"
......
...@@ -137,11 +137,15 @@ void vm86_return(void); ...@@ -137,11 +137,15 @@ void vm86_return(void);
void vm86_return_end(void); void vm86_return_end(void);
__ASM_GLOBAL_FUNC(vm86_enter, __ASM_GLOBAL_FUNC(vm86_enter,
"pushl %ebp\n\t" "pushl %ebp\n\t"
"movl %esp, %ebp\n\t" __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"movl %esp,%ebp\n\t"
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
"pushl %ebx\n\t"
__ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
"movl $166,%eax\n\t" /*SYS_vm86*/ "movl $166,%eax\n\t" /*SYS_vm86*/
"movl 8(%ebp),%ecx\n\t" /* vm86_ptr */ "movl 8(%ebp),%ecx\n\t" /* vm86_ptr */
"movl (%ecx),%ecx\n\t" "movl (%ecx),%ecx\n\t"
"pushl %ebx\n\t"
"movl $1,%ebx\n\t" /*VM86_ENTER*/ "movl $1,%ebx\n\t" /*VM86_ENTER*/
"pushl %ecx\n\t" /* put vm86plus_struct ptr somewhere we can find it */ "pushl %ecx\n\t" /* put vm86plus_struct ptr somewhere we can find it */
"pushl %fs\n\t" "pushl %fs\n\t"
...@@ -154,7 +158,10 @@ __ASM_GLOBAL_FUNC(vm86_enter, ...@@ -154,7 +158,10 @@ __ASM_GLOBAL_FUNC(vm86_enter,
"popl %fs\n\t" "popl %fs\n\t"
"popl %ecx\n\t" "popl %ecx\n\t"
"popl %ebx\n\t" "popl %ebx\n\t"
__ASM_CFI(".cfi_same_value %ebx\n\t")
"popl %ebp\n\t" "popl %ebp\n\t"
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
__ASM_CFI(".cfi_same_value %ebp\n\t")
"testl %eax,%eax\n\t" "testl %eax,%eax\n\t"
"jl 0f\n\t" "jl 0f\n\t"
"cmpb $0,%al\n\t" /* VM86_SIGNAL */ "cmpb $0,%al\n\t" /* VM86_SIGNAL */
...@@ -2268,7 +2275,10 @@ DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 1 ) ...@@ -2268,7 +2275,10 @@ DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 1 )
extern void DECLSPEC_NORETURN call_thread_func( LPTHREAD_START_ROUTINE entry, void *arg ); extern void DECLSPEC_NORETURN call_thread_func( LPTHREAD_START_ROUTINE entry, void *arg );
__ASM_GLOBAL_FUNC(call_thread_func, __ASM_GLOBAL_FUNC(call_thread_func,
"pushl %ebp\n\t" "pushl %ebp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"movl %esp,%ebp\n\t" "movl %esp,%ebp\n\t"
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
"subl $4,%esp\n\t" "subl $4,%esp\n\t"
"pushl 12(%ebp)\n\t" "pushl 12(%ebp)\n\t"
"call *8(%ebp)\n\t" "call *8(%ebp)\n\t"
...@@ -2329,42 +2339,53 @@ __ASM_STDCALL_FUNC( NtCurrentTeb, 0, ".byte 0x64\n\tmovl 0x18,%eax\n\tret" ) ...@@ -2329,42 +2339,53 @@ __ASM_STDCALL_FUNC( NtCurrentTeb, 0, ".byte 0x64\n\tmovl 0x18,%eax\n\tret" )
* function calling the handler having only 5 parameters (*4). * function calling the handler having only 5 parameters (*4).
*/ */
__ASM_GLOBAL_FUNC( EXC_CallHandler, __ASM_GLOBAL_FUNC( EXC_CallHandler,
" pushl %ebp\n" "pushl %ebp\n\t"
" movl %esp, %ebp\n" __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
" pushl %ebx\n" __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
" movl 28(%ebp), %edx\n" /* ugly hack to pass the 6th param needed because of Shrinker */ "movl %esp,%ebp\n\t"
" pushl 24(%ebp)\n" __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
" pushl 20(%ebp)\n" "pushl %ebx\n\t"
" pushl 16(%ebp)\n" __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
" pushl 12(%ebp)\n" "movl 28(%ebp), %edx\n\t" /* ugly hack to pass the 6th param needed because of Shrinker */
" pushl 8(%ebp)\n" "pushl 24(%ebp)\n\t"
" call " __ASM_NAME("call_exception_handler") "\n" "pushl 20(%ebp)\n\t"
" popl %ebx\n" "pushl 16(%ebp)\n\t"
" leave\n" "pushl 12(%ebp)\n\t"
" ret\n" "pushl 8(%ebp)\n\t"
) "call " __ASM_NAME("call_exception_handler") "\n\t"
"popl %ebx\n\t"
__ASM_CFI(".cfi_same_value %ebx\n\t")
"leave\n"
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
__ASM_CFI(".cfi_same_value %ebp\n\t")
"ret" )
__ASM_GLOBAL_FUNC(call_exception_handler, __ASM_GLOBAL_FUNC(call_exception_handler,
" pushl %ebp\n" "pushl %ebp\n\t"
" movl %esp, %ebp\n" __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
" subl $12,%esp\n" __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
" pushl 12(%ebp)\n" /* make any exceptions in this... */ "movl %esp,%ebp\n\t"
" pushl %edx\n" /* handler be handled by... */ __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
" .byte 0x64\n" "subl $12,%esp\n\t"
" pushl (0)\n" /* nested_handler (passed in edx). */ "pushl 12(%ebp)\n\t" /* make any exceptions in this... */
" .byte 0x64\n" "pushl %edx\n\t" /* handler be handled by... */
" movl %esp,(0)\n" /* push the new exception frame onto the exception stack. */ ".byte 0x64\n\t"
" pushl 20(%ebp)\n" "pushl (0)\n\t" /* nested_handler (passed in edx). */
" pushl 16(%ebp)\n" ".byte 0x64\n\t"
" pushl 12(%ebp)\n" "movl %esp,(0)\n\t" /* push the new exception frame onto the exception stack. */
" pushl 8(%ebp)\n" "pushl 20(%ebp)\n\t"
" movl 24(%ebp), %ecx\n" /* (*1) */ "pushl 16(%ebp)\n\t"
" call *%ecx\n" /* call handler. (*2) */ "pushl 12(%ebp)\n\t"
" .byte 0x64\n" "pushl 8(%ebp)\n\t"
" movl (0), %esp\n" /* restore previous... (*3) */ "movl 24(%ebp), %ecx\n\t" /* (*1) */
" .byte 0x64\n" "call *%ecx\n\t" /* call handler. (*2) */
" popl (0)\n" /* exception frame. */ ".byte 0x64\n\t"
" movl %ebp, %esp\n" /* restore saved stack, in case it was corrupted */ "movl (0), %esp\n\t" /* restore previous... (*3) */
" popl %ebp\n" ".byte 0x64\n\t"
" ret $20\n" /* (*4) */ "popl (0)\n\t" /* exception frame. */
) "movl %ebp, %esp\n\t" /* restore saved stack, in case it was corrupted */
"popl %ebp\n\t"
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
__ASM_CFI(".cfi_same_value %ebp\n\t")
"ret $20" ) /* (*4) */
#endif /* __i386__ */ #endif /* __i386__ */
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