Author: hyperion
Date: Sat Dec 20 17:27:17 2008
New Revision: 38208
URL:
http://svn.reactos.org/svn/reactos?rev=38208&view=rev
Log:
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
Modified:
trunk/reactos/lib/pseh/framebased-gcchack.c
trunk/reactos/lib/pseh/i386/framebased-gcchack.S
Modified: trunk/reactos/lib/pseh/framebased-gcchack.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/framebased-gcchac…
==============================================================================
--- trunk/reactos/lib/pseh/framebased-gcchack.c [iso-8859-1] (original)
+++ trunk/reactos/lib/pseh/framebased-gcchack.c [iso-8859-1] Sat Dec 20 17:27:17 2008
@@ -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 *);
@@ -49,6 +48,24 @@
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)
Modified: trunk/reactos/lib/pseh/i386/framebased-gcchack.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/framebased-g…
==============================================================================
--- trunk/reactos/lib/pseh/i386/framebased-gcchack.S [iso-8859-1] (original)
+++ trunk/reactos/lib/pseh/i386/framebased-gcchack.S [iso-8859-1] Sat Dec 20 17:27:17
2008
@@ -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 @@
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
+___SEH2Except:
+ mov eax, [esp+4]
+ mov ecx, [esp+8]
+
+ call eax
+
+ ret
+.endfunc
+
+.func __SEH2Finally
.globl ___SEH2Finally
-___SEH2Except:
___SEH2Finally:
mov eax, [esp+4]
mov ecx, [esp+8]
@@ -58,30 +76,9 @@
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 @@
cld
jmp __SEH2FrameHandler
+.endfunc
+.func __SEH2NestedHandler
.globl ___SEH2NestedHandler
___SEH2NestedHandler:
@@ -97,5 +96,6 @@
cld
jmp __SEH2NestedHandler
+.endfunc
// EOF