Alexandre Julliard : ntdll: Add call frame annotations in x86 assembly code .

Alexandre Julliard julliard at winehq.org
Thu Jun 25 08:13:57 CDT 2009


Module: wine
Branch: master
Commit: 0c463415432769df5bfe295a071380f3eebe6283
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0c463415432769df5bfe295a071380f3eebe6283

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jun 25 12:02:53 2009 +0200

ntdll: Add call frame annotations in x86 assembly code.

---

 dlls/ntdll/loader.c      |    7 +++
 dlls/ntdll/relay.c       |   49 +++++++++++++---------
 dlls/ntdll/signal_i386.c |   99 ++++++++++++++++++++++++++++------------------
 3 files changed, 96 insertions(+), 59 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 166766b..2f9b41e 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -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 );
 __ASM_GLOBAL_FUNC(call_dll_entry_point,
                   "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"
+                  __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
                   "pushl %ebx\n\t"
+                  __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
                   "subl $8,%esp\n\t"
                   "pushl 20(%ebp)\n\t"
                   "pushl 16(%ebp)\n\t"
@@ -158,7 +162,10 @@ __ASM_GLOBAL_FUNC(call_dll_entry_point,
                   "call *%eax\n\t"
                   "leal -4(%ebp),%esp\n\t"
                   "popl %ebx\n\t"
+                  __ASM_CFI(".cfi_same_value %ebx\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 /* __i386__ */
 static inline BOOL call_dll_entry_point( DLLENTRYPROC proc, void *module,
diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c
index 0f74c41..1981e51 100644
--- a/dlls/ntdll/relay.c
+++ b/dlls/ntdll/relay.c
@@ -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 );
 #ifdef __i386__
 __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),%esi\n"
-                   "\tmovl %esp,%edi\n"
-                   "\tcld\n"
-                   "\trep; movsl\n"
-                   "1:\tcall *8(%ebp)\n"
-                   "\tleal -8(%ebp),%esp\n"
-                   "\tpopl %edi\n"
-                   "\tpopl %esi\n"
-                   "\tpopl %ebp\n"
-                   "\tret" )
+                   "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"
+                   __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                   "pushl %esi\n\t"
+                  __ASM_CFI(".cfi_rel_offset %esi,-4\n\t")
+                   "pushl %edi\n\t"
+                  __ASM_CFI(".cfi_rel_offset %edi,-8\n\t")
+                   "movl 12(%ebp),%edx\n\t"
+                   "shll $2,%edx\n\t"
+                   "jz 1f\n\t"
+                   "subl %edx,%esp\n\t"
+                   "andl $~15,%esp\n\t"
+                   "movl 12(%ebp),%ecx\n\t"
+                   "movl 16(%ebp),%esi\n\t"
+                   "movl %esp,%edi\n\t"
+                   "cld\n\t"
+                   "rep; movsl\n"
+                   "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
 __ASM_GLOBAL_FUNC( call_entry_point,
                    "pushq %rbp\n\t"
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index ff251fa..d0e0172 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -137,11 +137,15 @@ void vm86_return(void);
 void vm86_return_end(void);
 __ASM_GLOBAL_FUNC(vm86_enter,
                   "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 8(%ebp),%ecx\n\t" /* vm86_ptr */
                   "movl (%ecx),%ecx\n\t"
-                  "pushl %ebx\n\t"
                   "movl $1,%ebx\n\t"    /*VM86_ENTER*/
                   "pushl %ecx\n\t"      /* put vm86plus_struct ptr somewhere we can find it */
                   "pushl %fs\n\t"
@@ -154,7 +158,10 @@ __ASM_GLOBAL_FUNC(vm86_enter,
                   "popl %fs\n\t"
                   "popl %ecx\n\t"
                   "popl %ebx\n\t"
+                  __ASM_CFI(".cfi_same_value %ebx\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"
                   "jl 0f\n\t"
                   "cmpb $0,%al\n\t" /* VM86_SIGNAL */
@@ -2268,7 +2275,10 @@ DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 1 )
 extern void DECLSPEC_NORETURN call_thread_func( LPTHREAD_START_ROUTINE entry, void *arg );
 __ASM_GLOBAL_FUNC(call_thread_func,
                   "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"
+                  __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
                   "subl $4,%esp\n\t"
                   "pushl 12(%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" )
  * function calling the handler having only 5 parameters (*4).
  */
 __ASM_GLOBAL_FUNC( EXC_CallHandler,
-"	pushl	%ebp\n"
-"	movl	%esp, %ebp\n"
-"	pushl	%ebx\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"
-"	pushl	16(%ebp)\n"
-"	pushl	12(%ebp)\n"
-"	pushl	8(%ebp)\n"
-"	call	" __ASM_NAME("call_exception_handler") "\n"
-"	popl	%ebx\n"
-"	leave\n"
-"	ret\n"
-)
+                  "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"
+                  __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                   "pushl %ebx\n\t"
+                   __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
+                   "movl 28(%ebp), %edx\n\t" /* ugly hack to pass the 6th param needed because of Shrinker */
+                   "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("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,
-"	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"
-"	pushl	(0)\n"            /* nested_handler (passed in edx). */
-"	.byte	0x64\n"
-"	movl	%esp,(0)\n"       /* push the new exception frame onto the exception stack. */
-"	pushl	20(%ebp)\n"
-"	pushl	16(%ebp)\n"
-"	pushl	12(%ebp)\n"
-"	pushl	8(%ebp)\n"
-"	movl	24(%ebp), %ecx\n" /* (*1) */
-"	call	*%ecx\n"          /* call handler. (*2) */
-"	.byte	0x64\n"
-"	movl	(0), %esp\n"      /* restore previous... (*3) */
-"	.byte	0x64\n"
-"	popl	(0)\n"            /* exception frame. */
-"	movl	%ebp, %esp\n"     /* restore saved stack, in case it was corrupted */
-"	popl	%ebp\n"
-"	ret	$20\n"            /* (*4) */
-)
+                  "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"
+                  __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                  "subl $12,%esp\n\t"
+                  "pushl 12(%ebp)\n\t"      /* make any exceptions in this... */
+                  "pushl %edx\n\t"          /* handler be handled by... */
+                  ".byte 0x64\n\t"
+                  "pushl (0)\n\t"           /* nested_handler (passed in edx). */
+                  ".byte 0x64\n\t"
+                  "movl %esp,(0)\n\t"       /* push the new exception frame onto the exception stack. */
+                  "pushl 20(%ebp)\n\t"
+                  "pushl 16(%ebp)\n\t"
+                  "pushl 12(%ebp)\n\t"
+                  "pushl 8(%ebp)\n\t"
+                  "movl 24(%ebp), %ecx\n\t" /* (*1) */
+                  "call *%ecx\n\t"          /* call handler. (*2) */
+                  ".byte 0x64\n\t"
+                  "movl (0), %esp\n\t"      /* restore previous... (*3) */
+                  ".byte 0x64\n\t"
+                  "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__ */




More information about the wine-cvs mailing list