Author: tkreuzer
Date: Sat Sep 13 13:31:20 2014
New Revision: 64132
URL:
http://svn.reactos.org/svn/reactos?rev=64132&view=rev
Log:
[PSEH3]
- Unregister frame before calling finally funtion in _SEH3$_AutoCleanup
- Restore full volatile register context for clang
- Don't clobber ebx in __SEH3$_RegisterFrameWithNonVolatiles (noticed by Thomas)
- Improve __SEH3$_InvokeEmbeddedFilterFromRegistration
Modified:
trunk/reactos/lib/pseh/i386/pseh3.c
trunk/reactos/lib/pseh/i386/pseh3_i386.S
Modified: trunk/reactos/lib/pseh/i386/pseh3.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/pseh3.c?rev=…
==============================================================================
--- trunk/reactos/lib/pseh/i386/pseh3.c [iso-8859-1] (original)
+++ trunk/reactos/lib/pseh/i386/pseh3.c [iso-8859-1] Sat Sep 13 13:31:20 2014
@@ -145,16 +145,17 @@
_SEH3$_AutoCleanup(
volatile SEH3$_REGISTRATION_FRAME *Frame)
{
+ if (Frame->Handler)
+ _SEH3$_UnregisterFrame(Frame);
+ else
+ _SEH3$_UnregisterTryLevel(Frame);
+
/* Check for __finally frames */
if (Frame->ScopeTable->Target == NULL)
{
_SEH3$_InvokeFilter(Frame, Frame->ScopeTable->Filter);
}
- if (Frame->Handler)
- _SEH3$_UnregisterFrame(Frame);
- else
- _SEH3$_UnregisterTryLevel(Frame);
}
static inline
@@ -209,6 +210,10 @@
/* Load the registers */
"movl 24(%%ecx), %%esp\n\t"
"movl 28(%%ecx), %%ebp\n\t"
+
+ "movl 36(%%ecx), %%ebx\n\t"
+ "movl 40(%%ecx), %%esi\n\t"
+ "movl 44(%%ecx), %%edi\n\t"
/* Stack pointer is 4 off from the call to __SEH3$_RegisterFrame */
"addl $4, %%esp\n\t"
Modified: trunk/reactos/lib/pseh/i386/pseh3_i386.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/pseh3_i386.S…
==============================================================================
--- trunk/reactos/lib/pseh/i386/pseh3_i386.S [iso-8859-1] (original)
+++ trunk/reactos/lib/pseh/i386/pseh3_i386.S [iso-8859-1] Sat Sep 13 13:31:20 2014
@@ -20,7 +20,7 @@
* _SEH3$_RegisterFrame[WithNonVolatiles](
* PSEH3$_REGISTRATION_FRAME RegistrationFrame<eax>,
* PSEH3$_SCOPE_TABLE ScopeTable<edx>,
- * PVOID AllocaFrame);
+ * PVOID AllocaFrame<ecx>);
*/
.global __SEH3$_RegisterFrameWithNonVolatiles
__SEH3$_RegisterFrameWithNonVolatiles:
@@ -33,6 +33,7 @@
/* Safe the return address */
mov ebx, [esp]
mov [eax + SEH3_REGISTRATION_FRAME_ReturnAddress], ebx
+ mov ebx, [eax + SEH3_REGISTRATION_FRAME_Ebx]
.global __SEH3$_RegisterFrameWithStackLayout
__SEH3$_RegisterFrameWithStackLayout:
@@ -71,9 +72,9 @@
* __attribute__((regparm(3)))
* __attribute__((returns_twice))
* _SEH3$_RegisterTryLevel[WithNonVolatiles](
- * PSEH3$_REGISTRATION_FRAME RegistrationFrame<edx>,
- * PSEH3$_SCOPE_TABLE ScopeTable<eax>,
- * PVOID AllocaFrame);
+ * PSEH3$_REGISTRATION_FRAME RegistrationFrame<eax>,
+ * PSEH3$_SCOPE_TABLE ScopeTable<edx>,
+ * PVOID AllocaFrame<ecx>);
*/
.global __SEH3$_RegisterTryLevelWithNonVolatiles
__SEH3$_RegisterTryLevelWithNonVolatiles:
@@ -130,6 +131,9 @@
push esi
push edi
+ /* Save the registration frame pointer */
+ push eax
+
/* Load the non-volatiles from the registration invocation */
mov ebx, [eax + SEH3_REGISTRATION_FRAME_Ebx]
mov esi, [eax + SEH3_REGISTRATION_FRAME_Esi]
@@ -141,7 +145,7 @@
sub ecx, [eax + SEH3_REGISTRATION_FRAME_Esp]
/* Put the return address on the stack */
- push offset __SEH3$_InvokeEmbeddedFilterReturn
+ push offset __SEH3$_InvokeEmbeddedFilterReturnClang
/* Save the current stack pointer in the AllocaFrame member */
mov [eax + SEH3_REGISTRATION_FRAME_AllocaFrame], esp
@@ -156,6 +160,26 @@
xor eax, eax
inc eax
jmp edx
+
+ /* We return to this label with a cleaned up stack */
+__SEH3$_InvokeEmbeddedFilterReturnClang:
+
+ /* Restore the registration frame pointer */
+ pop ecx
+
+ /* Save the non-volatiles back in the registration frame */
+ mov [ecx + SEH3_REGISTRATION_FRAME_Ebx], ebx
+ mov [ecx + SEH3_REGISTRATION_FRAME_Esi], esi
+ mov [ecx + SEH3_REGISTRATION_FRAME_Edi], edi
+ mov [ecx + SEH3_REGISTRATION_FRAME_Ebp], ebp
+
+ /* Restore the current non-volatiles */
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+
+ ret
.global __SEH3$_InvokeEmbeddedFilter