diff options
Diffstat (limited to 'src/pal/src/arch/i386/exceptionhelper.S')
-rw-r--r-- | src/pal/src/arch/i386/exceptionhelper.S | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/pal/src/arch/i386/exceptionhelper.S b/src/pal/src/arch/i386/exceptionhelper.S index b7b34ace41..2061be26f8 100644 --- a/src/pal/src/arch/i386/exceptionhelper.S +++ b/src/pal/src/arch/i386/exceptionhelper.S @@ -8,35 +8,36 @@ ////////////////////////////////////////////////////////////////////////// // -// This function creates a stack frame right below the target frame, restores all callee -// saved registers from the passed in context, sets the RSP to that frame and sets the -// return address to the target frame's RIP. -// Then it uses the ThrowExceptionHelper to throw the passed in exception from that context. // EXTERN_C void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex); +// +// This function creates a stack frame right below the target frame, restores all callee +// saved registers from the passed in context, sets the SP to that frame and sets the +// return address to the target frame's IP. +// Then it uses the ThrowExceptionHelper to throw the passed in exception from that context. +// +////////////////////////////////////////////////////////////////////////// + LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT - // Save the RBP to the stack so that the unwind can work at the instruction after - // loading the RBP from the context, but before loading the RSP from the context. - push_nonvol_reg rbp - mov r12, [rdi + CONTEXT_R12] - mov r13, [rdi + CONTEXT_R13] - mov r14, [rdi + CONTEXT_R14] - mov r15, [rdi + CONTEXT_R15] - mov rbx, [rdi + CONTEXT_Rbx] - mov rbp, [rdi + CONTEXT_Rbp] - mov rsp, [rdi + CONTEXT_Rsp] - // The RSP was set to the target frame's value, so the current function's - // CFA is now right at the RSP. + push ebp + mov eax, [esp + 12] // ebx: PAL_SEHException * + mov ebx, [esp + 8] // eax: CONTEXT * + + mov ebp, [ebx + CONTEXT_Ebp] + mov esp, [ebx + CONTEXT_Esp] + + // The ESP is re-initialized as the target frame's value, so the current function's + // CFA is now right at the ESP. .cfi_def_cfa_offset 0 - // Indicate that now that we have moved the RSP to the target address, - // the RBP is no longer saved in the current stack frame. - .cfi_restore rbp + // Indicate that now that we have moved the RSP to the target address, + // the EBP is no longer saved in the current stack frame. + .cfi_restore ebp - mov rax, [rdi + CONTEXT_Rip] + // Store PAL_SEHException as the first argument + push eax // Store return address to the stack - push_register rax - // The PAL_SEHException pointer - mov rdi, rsi + mov ebx, [ebx + CONTEXT_Eip] + push ebx jmp EXTERNAL_C_FUNC(ThrowExceptionHelper) LEAF_END ThrowExceptionFromContextInternal, _TEXT |