mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
modified lib/pseh/framebased-gcchack.c
modified lib/pseh/i386/framebased-gcchack.S For some reason, "call _RtlUnwind@16" is being linked as "call 0" (very likely a linker bug). Reimplementing _SEH2GlobalUnwind in C and taking the address of RtlUnwind from C code seems to work Annotate functions implemented in assembler with .func/.endfunc, so the symbols are more correct svn path=/trunk/; revision=38208
This commit is contained in:
parent
aaf7ad6a2b
commit
e5a9f1615f
2 changed files with 42 additions and 25 deletions
|
@ -38,7 +38,6 @@
|
|||
#endif
|
||||
|
||||
extern _SEH2Registration_t * __cdecl _SEH2CurrentRegistration(void);
|
||||
extern void _SEH2GlobalUnwind(void *);
|
||||
|
||||
extern int __SEH2Except(void *, void *);
|
||||
extern void __SEH2Finally(void *, void *);
|
||||
|
@ -50,6 +49,24 @@ extern void __cdecl __SEH2LeaveFrame(void);
|
|||
extern int __cdecl __SEH2FrameHandler(struct _EXCEPTION_RECORD *, void *, struct _CONTEXT *, void *);
|
||||
extern int __cdecl __SEH2NestedHandler(struct _EXCEPTION_RECORD *, void *, struct _CONTEXT *, void *);
|
||||
|
||||
FORCEINLINE
|
||||
void _SEH2GlobalUnwind(void * target)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"push %%ebp\n"
|
||||
"push $0\n"
|
||||
"push $0\n"
|
||||
"push $Return%=\n"
|
||||
"push %[target]\n"
|
||||
"call %c[RtlUnwind]\n"
|
||||
"Return%=: pop %%ebp\n" :
|
||||
:
|
||||
[target] "g" (target), [RtlUnwind] "g" (&RtlUnwind) :
|
||||
"eax", "ebx", "ecx", "edx", "esi", "edi", "flags", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
int _SEH2Except(_SEH2Frame_t * frame, volatile _SEH2TryLevel_t * trylevel)
|
||||
{
|
||||
|
|
|
@ -21,11 +21,14 @@
|
|||
.text
|
||||
.intel_syntax noprefix
|
||||
|
||||
.func _SEH2CurrentRegistration
|
||||
.globl __SEH2CurrentRegistration
|
||||
__SEH2CurrentRegistration:
|
||||
mov eax, [fs:0]
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func __SEH2EnterFrame
|
||||
.globl ___SEH2EnterFrame
|
||||
___SEH2EnterFrame:
|
||||
mov eax, [esp+4]
|
||||
|
@ -33,24 +36,39 @@ ___SEH2EnterFrame:
|
|||
mov [eax], ecx
|
||||
mov [fs:0], eax
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func __SEH2LeaveFrame
|
||||
.globl ___SEH2LeaveFrame
|
||||
___SEH2LeaveFrame:
|
||||
mov eax, [fs:0]
|
||||
mov eax, [eax]
|
||||
mov [fs:0], eax
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func __SEH2Handle
|
||||
.globl ___SEH2Handle
|
||||
___SEH2Handle:
|
||||
mov eax, [esp+4]
|
||||
mov ebp, [esp+8]
|
||||
mov esp, [esp+12]
|
||||
jmp eax
|
||||
.endfunc
|
||||
|
||||
.func __SEH2Except
|
||||
.globl ___SEH2Except
|
||||
.globl ___SEH2Finally
|
||||
___SEH2Except:
|
||||
mov eax, [esp+4]
|
||||
mov ecx, [esp+8]
|
||||
|
||||
call eax
|
||||
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func __SEH2Finally
|
||||
.globl ___SEH2Finally
|
||||
___SEH2Finally:
|
||||
mov eax, [esp+4]
|
||||
mov ecx, [esp+8]
|
||||
|
@ -58,30 +76,9 @@ ___SEH2Finally:
|
|||
call eax
|
||||
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.globl __SEH2GlobalUnwind
|
||||
__SEH2GlobalUnwind:
|
||||
|
||||
.extern _RtlUnwind@16
|
||||
|
||||
push ebx
|
||||
mov ebx, [esp+8]
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push 0 // ReturnValue
|
||||
push 0 // ExceptionRecord
|
||||
push .RestoreRegisters // TargetIp
|
||||
push ebx // TargetFrame
|
||||
call _RtlUnwind@16
|
||||
|
||||
.RestoreRegisters:
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
|
||||
ret
|
||||
|
||||
.func __SEH2FrameHandler
|
||||
.globl ___SEH2FrameHandler
|
||||
___SEH2FrameHandler:
|
||||
|
||||
|
@ -89,7 +86,9 @@ ___SEH2FrameHandler:
|
|||
|
||||
cld
|
||||
jmp __SEH2FrameHandler
|
||||
.endfunc
|
||||
|
||||
.func __SEH2NestedHandler
|
||||
.globl ___SEH2NestedHandler
|
||||
___SEH2NestedHandler:
|
||||
|
||||
|
@ -97,5 +96,6 @@ ___SEH2NestedHandler:
|
|||
|
||||
cld
|
||||
jmp __SEH2NestedHandler
|
||||
.endfunc
|
||||
|
||||
// EOF
|
||||
|
|
Loading…
Reference in a new issue