[MPlayer-dev-eng] [PATCH] EH_prolog docu/simplification

Reimar D?ffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Nov 27 23:09:12 CET 2006


Hello,
On Mon, Nov 27, 2006 at 10:30:34PM +0100, Reimar D?ffinger wrote:
> the attached patch simplifies and documents the exp_EH_prolog function.
> I'm not sure if the change is a good idea, on the one hand this new
> version IMO is much easier to understand, on the other hand the old
> version is closer to the MSVCRT original...
> Unfortunately I see no way to convert this into proper inline asm, at
> least not without some hackishness :-(

And this is the somewhat-proper inline asm variant, which also gets rid
of stubs.S...

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: loader/Makefile
===================================================================
--- loader/Makefile	(revision 21339)
+++ loader/Makefile	(working copy)
@@ -8,7 +8,7 @@
 SRCS= driver.c afl.c vfl.c
 ifneq ($(TARGET_WIN32),yes)
 SRCS+= ldt_keeper.c pe_image.c module.c ext.c win32.c \
-       pe_resource.c resource.c registry.c elfdll.c stubs.S
+       pe_resource.c resource.c registry.c elfdll.c
 # QTX emulation is not supported in Darwin
 ifneq ($(TARGET_OS),Darwin)
 SRCS+= wrapper.S
Index: loader/stubs.S
===================================================================
--- loader/stubs.S	(revision 21339)
+++ loader/stubs.S	(working copy)
@@ -1,17 +0,0 @@
-#if defined(__APPLE__) || defined(__OpenBSD__)
-# define SYM(x) _ ## x
-#else
-# define SYM(x) x
-#endif
-	.data
-.globl SYM(exp_EH_prolog)
-SYM(exp_EH_prolog):
-	pushl $0xff
-	pushl %eax
-	pushl %fs:0
-	movl  %esp, %fs:0
-	movl  12(%esp), %eax
-	movl  %ebp, 12(%esp)
-	leal  12(%esp), %ebp
-	pushl %eax
-	ret
Index: loader/win32.c
===================================================================
--- loader/win32.c	(revision 21339)
+++ loader/win32.c	(working copy)
@@ -18,6 +18,7 @@
  */
 
 #include "config.h"
+#include "mangle.h"
 
 #ifdef MPLAYER
 #ifdef USE_QTX_CODECS
@@ -4587,8 +4588,25 @@
 
 /* these are needed for mss1 */
 
-/* defined in stubs.s */
-void exp_EH_prolog(void);
+/**
+ * \brief this symbol is defined within exp_EH_prolog_dummy
+ * \param dest jump target
+ */
+void exp_EH_prolog(void *dest);
+//! just a dummy function that acts a container for the asm section
+void exp_EH_prolog_dummy(void) {
+  asm volatile (
+// take care, this "function" may not change flags or
+// registers besides eax (which is also why we can't use
+// exp_EH_prolog_dummy directly)
+MANGLE(exp_EH_prolog)":    \n\t"
+    "pop   %eax            \n\t"
+    "push  %ebp            \n\t"
+    "mov   %esp, %ebp      \n\t"
+    "lea   -12(%esp), %esp \n\t"
+    "jmp   *%eax           \n\t"
+  );
+}
 
 #include <netinet/in.h>
 static WINAPI inline unsigned long int exphtonl(unsigned long int hostlong)


More information about the MPlayer-dev-eng mailing list