makefiles: Explicitly create destination dirs when installing symlinks.
[wine/zf.git] / dlls / ntdll / signal_i386.c
blobddc2bf6adbd6d4ed099e3a28bf1f5120be30a439
1 /*
2 * i386 signal handling routines
4 * Copyright 1999 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifdef __i386__
23 #include <errno.h>
24 #include <signal.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <sys/types.h>
30 #include "ntstatus.h"
31 #define WIN32_NO_STATUS
32 #include "windef.h"
33 #include "ntdll_misc.h"
34 #include "wine/exception.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(seh);
39 struct x86_thread_data
41 DWORD fs; /* 1d4 TEB selector */
42 DWORD gs; /* 1d8 libc selector; update winebuild if you move this! */
43 DWORD dr0; /* 1dc debug registers */
44 DWORD dr1; /* 1e0 */
45 DWORD dr2; /* 1e4 */
46 DWORD dr3; /* 1e8 */
47 DWORD dr6; /* 1ec */
48 DWORD dr7; /* 1f0 */
49 void *exit_frame; /* 1f4 exit frame pointer */
52 C_ASSERT( sizeof(struct x86_thread_data) <= 16 * sizeof(void *) );
53 C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, gs ) == 0x1d8 );
54 C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, exit_frame ) == 0x1f4 );
56 static inline struct x86_thread_data *x86_thread_data(void)
58 return (struct x86_thread_data *)&NtCurrentTeb()->GdiTebBatch;
61 struct ldt_copy *__wine_ldt_copy = NULL;
63 /* Exception record for handling exceptions happening inside exception handlers */
64 typedef struct
66 EXCEPTION_REGISTRATION_RECORD frame;
67 EXCEPTION_REGISTRATION_RECORD *prevFrame;
68 } EXC_NESTED_FRAME;
70 extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
71 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher,
72 PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler );
74 /*******************************************************************
75 * is_valid_frame
77 static inline BOOL is_valid_frame( void *frame )
79 if ((ULONG_PTR)frame & 3) return FALSE;
80 return (frame >= NtCurrentTeb()->Tib.StackLimit &&
81 (void **)frame < (void **)NtCurrentTeb()->Tib.StackBase - 1);
84 /*******************************************************************
85 * raise_handler
87 * Handler for exceptions happening inside a handler.
89 static DWORD raise_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
90 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
92 if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
93 return ExceptionContinueSearch;
94 /* We shouldn't get here so we store faulty frame in dispatcher */
95 *dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
96 return ExceptionNestedException;
100 /*******************************************************************
101 * unwind_handler
103 * Handler for exceptions happening inside an unwind handler.
105 static DWORD unwind_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
106 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
108 if (!(rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
109 return ExceptionContinueSearch;
110 /* We shouldn't get here so we store faulty frame in dispatcher */
111 *dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
112 return ExceptionCollidedUnwind;
116 /**********************************************************************
117 * call_stack_handlers
119 * Call the stack handlers chain.
121 static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
123 EXCEPTION_REGISTRATION_RECORD *frame, *dispatch, *nested_frame;
124 DWORD res;
126 frame = NtCurrentTeb()->Tib.ExceptionList;
127 nested_frame = NULL;
128 while (frame != (EXCEPTION_REGISTRATION_RECORD*)~0UL)
130 /* Check frame address */
131 if (!is_valid_frame( frame ))
133 rec->ExceptionFlags |= EH_STACK_INVALID;
134 break;
137 /* Call handler */
138 TRACE( "calling handler at %p code=%x flags=%x\n",
139 frame->Handler, rec->ExceptionCode, rec->ExceptionFlags );
140 res = EXC_CallHandler( rec, frame, context, &dispatch, frame->Handler, raise_handler );
141 TRACE( "handler at %p returned %x\n", frame->Handler, res );
143 if (frame == nested_frame)
145 /* no longer nested */
146 nested_frame = NULL;
147 rec->ExceptionFlags &= ~EH_NESTED_CALL;
150 switch(res)
152 case ExceptionContinueExecution:
153 if (!(rec->ExceptionFlags & EH_NONCONTINUABLE)) return STATUS_SUCCESS;
154 return STATUS_NONCONTINUABLE_EXCEPTION;
155 case ExceptionContinueSearch:
156 break;
157 case ExceptionNestedException:
158 if (nested_frame < dispatch) nested_frame = dispatch;
159 rec->ExceptionFlags |= EH_NESTED_CALL;
160 break;
161 default:
162 return STATUS_INVALID_DISPOSITION;
164 frame = frame->Prev;
166 return STATUS_UNHANDLED_EXCEPTION;
170 /*******************************************************************
171 * KiUserExceptionDispatcher (NTDLL.@)
173 NTSTATUS WINAPI dispatch_exception( EXCEPTION_RECORD *rec, CONTEXT *context )
175 NTSTATUS status;
176 DWORD c;
178 TRACE( "code=%x flags=%x addr=%p ip=%08x tid=%04x\n",
179 rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
180 context->Eip, GetCurrentThreadId() );
181 for (c = 0; c < rec->NumberParameters; c++)
182 TRACE( " info[%d]=%08lx\n", c, rec->ExceptionInformation[c] );
184 if (rec->ExceptionCode == EXCEPTION_WINE_STUB)
186 if (rec->ExceptionInformation[1] >> 16)
187 MESSAGE( "wine: Call from %p to unimplemented function %s.%s, aborting\n",
188 rec->ExceptionAddress,
189 (char*)rec->ExceptionInformation[0], (char*)rec->ExceptionInformation[1] );
190 else
191 MESSAGE( "wine: Call from %p to unimplemented function %s.%ld, aborting\n",
192 rec->ExceptionAddress,
193 (char*)rec->ExceptionInformation[0], rec->ExceptionInformation[1] );
195 else
197 TRACE(" eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n",
198 context->Eax, context->Ebx, context->Ecx,
199 context->Edx, context->Esi, context->Edi );
200 TRACE(" ebp=%08x esp=%08x cs=%04x ds=%04x es=%04x fs=%04x gs=%04x flags=%08x\n",
201 context->Ebp, context->Esp, context->SegCs, context->SegDs,
202 context->SegEs, context->SegFs, context->SegGs, context->EFlags );
205 if (call_vectored_handlers( rec, context ) == EXCEPTION_CONTINUE_EXECUTION)
206 NtContinue( context, FALSE );
208 if ((status = call_stack_handlers( rec, context )) == STATUS_SUCCESS)
209 NtContinue( context, FALSE );
211 if (status != STATUS_UNHANDLED_EXCEPTION) RtlRaiseStatus( status );
212 return NtRaiseException( rec, context, FALSE );
215 __ASM_STDCALL_FUNC( KiUserExceptionDispatcher, 8,
216 "pushl 4(%esp)\n\t"
217 "pushl 4(%esp)\n\t"
218 "call " __ASM_STDCALL("dispatch_exception", 8) "\n\t"
219 "int3" )
221 /***********************************************************************
222 * save_fpu
224 * Save the thread FPU context.
226 static inline void save_fpu( CONTEXT *context )
228 #ifdef __GNUC__
229 struct
231 DWORD ControlWord;
232 DWORD StatusWord;
233 DWORD TagWord;
234 DWORD ErrorOffset;
235 DWORD ErrorSelector;
236 DWORD DataOffset;
237 DWORD DataSelector;
239 float_status;
241 context->ContextFlags |= CONTEXT_FLOATING_POINT;
242 __asm__ __volatile__( "fnsave %0; fwait" : "=m" (context->FloatSave) );
244 /* Reset unmasked exceptions status to avoid firing an exception. */
245 memcpy(&float_status, &context->FloatSave, sizeof(float_status));
246 float_status.StatusWord &= float_status.ControlWord | 0xffffff80;
248 __asm__ __volatile__( "fldenv %0" : : "m" (float_status) );
249 #endif
253 /***********************************************************************
254 * save_fpux
256 * Save the thread FPU extended context.
258 static inline void save_fpux( CONTEXT *context )
260 #ifdef __GNUC__
261 /* we have to enforce alignment by hand */
262 char buffer[sizeof(XSAVE_FORMAT) + 16];
263 XSAVE_FORMAT *state = (XSAVE_FORMAT *)(((ULONG_PTR)buffer + 15) & ~15);
265 context->ContextFlags |= CONTEXT_EXTENDED_REGISTERS;
266 __asm__ __volatile__( "fxsave %0" : "=m" (*state) );
267 memcpy( context->ExtendedRegisters, state, sizeof(*state) );
268 #endif
272 /***********************************************************************
273 * RtlCaptureContext (NTDLL.@)
275 __ASM_STDCALL_FUNC( RtlCaptureContext, 4,
276 "pushl %eax\n\t"
277 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
278 "movl 8(%esp),%eax\n\t" /* context */
279 "movl $0x10007,(%eax)\n\t" /* context->ContextFlags */
280 "movw %gs,0x8c(%eax)\n\t" /* context->SegGs */
281 "movw %fs,0x90(%eax)\n\t" /* context->SegFs */
282 "movw %es,0x94(%eax)\n\t" /* context->SegEs */
283 "movw %ds,0x98(%eax)\n\t" /* context->SegDs */
284 "movl %edi,0x9c(%eax)\n\t" /* context->Edi */
285 "movl %esi,0xa0(%eax)\n\t" /* context->Esi */
286 "movl %ebx,0xa4(%eax)\n\t" /* context->Ebx */
287 "movl %edx,0xa8(%eax)\n\t" /* context->Edx */
288 "movl %ecx,0xac(%eax)\n\t" /* context->Ecx */
289 "movl 0(%ebp),%edx\n\t"
290 "movl %edx,0xb4(%eax)\n\t" /* context->Ebp */
291 "movl 4(%ebp),%edx\n\t"
292 "movl %edx,0xb8(%eax)\n\t" /* context->Eip */
293 "movw %cs,0xbc(%eax)\n\t" /* context->SegCs */
294 "pushfl\n\t"
295 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
296 "popl 0xc0(%eax)\n\t" /* context->EFlags */
297 __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
298 "leal 8(%ebp),%edx\n\t"
299 "movl %edx,0xc4(%eax)\n\t" /* context->Esp */
300 "movw %ss,0xc8(%eax)\n\t" /* context->SegSs */
301 "popl 0xb0(%eax)\n\t" /* context->Eax */
302 __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
303 "ret $4" )
306 /*******************************************************************
307 * RtlUnwind (NTDLL.@)
309 void WINAPI DECLSPEC_HIDDEN __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID targetIp,
310 PEXCEPTION_RECORD pRecord, PVOID retval, CONTEXT *context )
312 EXCEPTION_RECORD record;
313 EXCEPTION_REGISTRATION_RECORD *frame, *dispatch;
314 DWORD res;
316 context->Eax = (DWORD)retval;
318 /* build an exception record, if we do not have one */
319 if (!pRecord)
321 record.ExceptionCode = STATUS_UNWIND;
322 record.ExceptionFlags = 0;
323 record.ExceptionRecord = NULL;
324 record.ExceptionAddress = (void *)context->Eip;
325 record.NumberParameters = 0;
326 pRecord = &record;
329 pRecord->ExceptionFlags |= EH_UNWINDING | (pEndFrame ? 0 : EH_EXIT_UNWIND);
331 TRACE( "code=%x flags=%x\n", pRecord->ExceptionCode, pRecord->ExceptionFlags );
332 TRACE( "eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n",
333 context->Eax, context->Ebx, context->Ecx, context->Edx, context->Esi, context->Edi );
334 TRACE( "ebp=%08x esp=%08x eip=%08x cs=%04x ds=%04x fs=%04x gs=%04x flags=%08x\n",
335 context->Ebp, context->Esp, context->Eip, LOWORD(context->SegCs), LOWORD(context->SegDs),
336 LOWORD(context->SegFs), LOWORD(context->SegGs), context->EFlags );
338 /* get chain of exception frames */
339 frame = NtCurrentTeb()->Tib.ExceptionList;
340 while ((frame != (EXCEPTION_REGISTRATION_RECORD*)~0UL) && (frame != pEndFrame))
342 /* Check frame address */
343 if (pEndFrame && (frame > pEndFrame))
344 raise_status( STATUS_INVALID_UNWIND_TARGET, pRecord );
346 if (!is_valid_frame( frame )) raise_status( STATUS_BAD_STACK, pRecord );
348 /* Call handler */
349 TRACE( "calling handler at %p code=%x flags=%x\n",
350 frame->Handler, pRecord->ExceptionCode, pRecord->ExceptionFlags );
351 res = EXC_CallHandler( pRecord, frame, context, &dispatch, frame->Handler, unwind_handler );
352 TRACE( "handler at %p returned %x\n", frame->Handler, res );
354 switch(res)
356 case ExceptionContinueSearch:
357 break;
358 case ExceptionCollidedUnwind:
359 frame = dispatch;
360 break;
361 default:
362 raise_status( STATUS_INVALID_DISPOSITION, pRecord );
363 break;
365 frame = __wine_pop_frame( frame );
367 NtContinue( context, FALSE );
369 __ASM_STDCALL_FUNC( RtlUnwind, 16,
370 "pushl %ebp\n\t"
371 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
372 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
373 "movl %esp,%ebp\n\t"
374 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
375 "leal -(0x2cc+8)(%esp),%esp\n\t" /* sizeof(CONTEXT) + alignment */
376 "pushl %eax\n\t"
377 "leal 4(%esp),%eax\n\t" /* context */
378 "xchgl %eax,(%esp)\n\t"
379 "call " __ASM_STDCALL("RtlCaptureContext",4) "\n\t"
380 "leal 24(%ebp),%eax\n\t"
381 "movl %eax,0xc4(%esp)\n\t" /* context->Esp */
382 "pushl %esp\n\t"
383 "pushl 20(%ebp)\n\t"
384 "pushl 16(%ebp)\n\t"
385 "pushl 12(%ebp)\n\t"
386 "pushl 8(%ebp)\n\t"
387 "call " __ASM_STDCALL("__regs_RtlUnwind",20) "\n\t"
388 "leave\n\t"
389 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
390 __ASM_CFI(".cfi_same_value %ebp\n\t")
391 "ret $16" ) /* actually never returns */
394 /*******************************************************************
395 * raise_exception_full_context
397 * Raise an exception with the full CPU context.
399 void raise_exception_full_context( EXCEPTION_RECORD *rec, CONTEXT *context )
401 save_fpu( context );
402 save_fpux( context );
403 /* FIXME: xstate */
404 context->Dr0 = x86_thread_data()->dr0;
405 context->Dr1 = x86_thread_data()->dr1;
406 context->Dr2 = x86_thread_data()->dr2;
407 context->Dr3 = x86_thread_data()->dr3;
408 context->Dr6 = x86_thread_data()->dr6;
409 context->Dr7 = x86_thread_data()->dr7;
410 context->ContextFlags |= CONTEXT_DEBUG_REGISTERS;
412 RtlRaiseStatus( NtRaiseException( rec, context, TRUE ));
416 /***********************************************************************
417 * RtlRaiseException (NTDLL.@)
419 __ASM_STDCALL_FUNC( RtlRaiseException, 4,
420 "pushl %ebp\n\t"
421 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
422 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
423 "movl %esp,%ebp\n\t"
424 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
425 "leal -0x2cc(%esp),%esp\n\t" /* sizeof(CONTEXT) */
426 "pushl %esp\n\t" /* context */
427 "call " __ASM_STDCALL("RtlCaptureContext",4) "\n\t"
428 "movl 4(%ebp),%eax\n\t" /* return address */
429 "movl 8(%ebp),%ecx\n\t" /* rec */
430 "movl %eax,12(%ecx)\n\t" /* rec->ExceptionAddress */
431 "leal 12(%ebp),%eax\n\t"
432 "movl %eax,0xc4(%esp)\n\t" /* context->Esp */
433 "movl %esp,%eax\n\t"
434 "pushl %eax\n\t"
435 "pushl %ecx\n\t"
436 "call " __ASM_NAME("raise_exception_full_context") "\n\t"
437 "leave\n\t"
438 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
439 __ASM_CFI(".cfi_same_value %ebp\n\t")
440 "ret $4" ) /* actually never returns */
443 /*************************************************************************
444 * RtlCaptureStackBackTrace (NTDLL.@)
446 USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash )
448 CONTEXT context;
449 ULONG i;
450 ULONG *frame;
452 RtlCaptureContext( &context );
453 if (hash) *hash = 0;
454 frame = (ULONG *)context.Ebp;
456 while (skip--)
458 if (!is_valid_frame( frame )) return 0;
459 frame = (ULONG *)*frame;
462 for (i = 0; i < count; i++)
464 if (!is_valid_frame( frame )) break;
465 buffer[i] = (void *)frame[1];
466 if (hash) *hash += frame[1];
467 frame = (ULONG *)*frame;
469 return i;
473 /***********************************************************************
474 * signal_start_thread
476 __ASM_GLOBAL_FUNC( signal_start_thread,
477 "movl 4(%esp),%esi\n\t" /* context */
478 "leal -12(%esi),%ecx\n\t"
479 /* clear the thread stack */
480 "andl $~0xfff,%ecx\n\t" /* round down to page size */
481 "movl %fs:8,%edi\n\t" /* NtCurrentTeb()->Tib.StackLimit */
482 "addl $0x1000,%edi\n\t"
483 "movl %edi,%esp\n\t"
484 "subl %edi,%ecx\n\t"
485 "xorl %eax,%eax\n\t"
486 "shrl $2,%ecx\n\t"
487 "rep; stosl\n\t"
488 /* switch to the initial context */
489 "leal -12(%esi),%esp\n\t"
490 "movl $1,4(%esp)\n\t"
491 "movl %esi,(%esp)\n\t"
492 "call " __ASM_STDCALL("NtContinue", 8) )
494 /**********************************************************************
495 * DbgBreakPoint (NTDLL.@)
497 __ASM_STDCALL_FUNC( DbgBreakPoint, 0, "int $3; ret"
498 "\n\tnop; nop; nop; nop; nop; nop; nop; nop"
499 "\n\tnop; nop; nop; nop; nop; nop" );
501 /**********************************************************************
502 * DbgUserBreakPoint (NTDLL.@)
504 __ASM_STDCALL_FUNC( DbgUserBreakPoint, 0, "int $3; ret"
505 "\n\tnop; nop; nop; nop; nop; nop; nop; nop"
506 "\n\tnop; nop; nop; nop; nop; nop" );
508 /**********************************************************************
509 * NtCurrentTeb (NTDLL.@)
511 __ASM_STDCALL_FUNC( NtCurrentTeb, 0, ".byte 0x64\n\tmovl 0x18,%eax\n\tret" )
514 /**************************************************************************
515 * _chkstk (NTDLL.@)
517 __ASM_GLOBAL_FUNC( _chkstk,
518 "negl %eax\n\t"
519 "addl %esp,%eax\n\t"
520 "xchgl %esp,%eax\n\t"
521 "movl 0(%eax),%eax\n\t" /* copy return address from old location */
522 "movl %eax,0(%esp)\n\t"
523 "ret" )
525 /**************************************************************************
526 * _alloca_probe (NTDLL.@)
528 __ASM_GLOBAL_FUNC( _alloca_probe,
529 "negl %eax\n\t"
530 "addl %esp,%eax\n\t"
531 "xchgl %esp,%eax\n\t"
532 "movl 0(%eax),%eax\n\t" /* copy return address from old location */
533 "movl %eax,0(%esp)\n\t"
534 "ret" )
537 /**********************************************************************
538 * EXC_CallHandler (internal)
540 * Some exception handlers depend on EBP to have a fixed position relative to
541 * the exception frame.
542 * Shrinker depends on (*1) doing what it does,
543 * (*2) being the exact instruction it is and (*3) beginning with 0x64
544 * (i.e. the %fs prefix to the movl instruction). It also depends on the
545 * function calling the handler having only 5 parameters (*4).
547 __ASM_GLOBAL_FUNC( EXC_CallHandler,
548 "pushl %ebp\n\t"
549 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
550 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
551 "movl %esp,%ebp\n\t"
552 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
553 "pushl %ebx\n\t"
554 __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
555 "movl 28(%ebp), %edx\n\t" /* ugly hack to pass the 6th param needed because of Shrinker */
556 "pushl 24(%ebp)\n\t"
557 "pushl 20(%ebp)\n\t"
558 "pushl 16(%ebp)\n\t"
559 "pushl 12(%ebp)\n\t"
560 "pushl 8(%ebp)\n\t"
561 "call " __ASM_NAME("call_exception_handler") "\n\t"
562 "popl %ebx\n\t"
563 __ASM_CFI(".cfi_same_value %ebx\n\t")
564 "leave\n"
565 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
566 __ASM_CFI(".cfi_same_value %ebp\n\t")
567 "ret" )
568 __ASM_GLOBAL_FUNC(call_exception_handler,
569 "pushl %ebp\n\t"
570 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
571 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
572 "movl %esp,%ebp\n\t"
573 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
574 "subl $12,%esp\n\t"
575 "pushl 12(%ebp)\n\t" /* make any exceptions in this... */
576 "pushl %edx\n\t" /* handler be handled by... */
577 ".byte 0x64\n\t"
578 "pushl (0)\n\t" /* nested_handler (passed in edx). */
579 ".byte 0x64\n\t"
580 "movl %esp,(0)\n\t" /* push the new exception frame onto the exception stack. */
581 "pushl 20(%ebp)\n\t"
582 "pushl 16(%ebp)\n\t"
583 "pushl 12(%ebp)\n\t"
584 "pushl 8(%ebp)\n\t"
585 "movl 24(%ebp), %ecx\n\t" /* (*1) */
586 "call *%ecx\n\t" /* call handler. (*2) */
587 ".byte 0x64\n\t"
588 "movl (0), %esp\n\t" /* restore previous... (*3) */
589 ".byte 0x64\n\t"
590 "popl (0)\n\t" /* exception frame. */
591 "movl %ebp, %esp\n\t" /* restore saved stack, in case it was corrupted */
592 "popl %ebp\n\t"
593 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
594 __ASM_CFI(".cfi_same_value %ebp\n\t")
595 "ret $20" ) /* (*4) */
597 #endif /* __i386__ */