Re: ptrace single-stepping change breaks Wine

From: Mike Hearn
Date: Thu Dec 30 2004 - 08:02:51 EST


On Thu, 2004-12-30 at 11:09 +0100, Thomas Sailer wrote:
> On Wed, 2004-12-29 at 20:15 -0800, Andrew Morton wrote:
> > You can globally disable flex-mmap with
> >
> > echo 1 > /proc/sys/vm/legacy_va_layout
> >
> > Does it fix things?
>
> Haven't tried. But setarch i386 -L /usr/bin/wine ... did fix it.
>
> Tom

Tom, does this patch against Wine help? It should do the same thing as
the setarch program, so if that fixes it then this should also (if I've
understood how this mechanism works of course).

Mike Hearn <mh@xxxxxxxxxxxxxxx>
Set the Linux ABI personality to get a legacy VM layout
--- configure.ac (revision 14)
+++ configure.ac (local)
@@ -188,6 +188,7 @@ AC_CHECK_HEADERS(\
linux/joystick.h \
linux/major.h \
linux/param.h \
+ linux/personality.h \
linux/serial.h \
linux/ucdrom.h \
machine/cpu.h \
--- libs/wine/loader.c (revision 14)
+++ libs/wine/loader.c (local)
@@ -41,6 +41,11 @@
#include "winbase.h"
#include "wine/library.h"

+#ifdef HAVE_LINUX_PERSONALITY_H
+#include <sys/syscall.h>
+#include <linux/personality.h>
+#endif
+
#ifdef __APPLE__
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
@@ -515,6 +520,22 @@ static void debug_usage(void)


/***********************************************************************
+ * linux_personality_init
+ *
+ * Sets the "please unbreak me" mmap flag to disable things like
+ * flex-mmap. Note that this will also disable exec-shield
+ * randomization for any ELF DLLs loaded after this point but the
+ * initial libraries (libc etc) linked in automatically will be
+ * randomized.
+ */
+static void linux_personality_init(void)
+{
+#if defined(HAVE_LINUX_PERSONALITY_H) && defined(__i386__)
+ syscall(SYS_personality, PER_LINUX32 | 0x0200000 /* ADDR_COMPAT_LAYOUT */);
+#endif
+}
+
+/***********************************************************************
* wine_init
*
* Main Wine initialisation.
@@ -526,6 +547,7 @@ void wine_init( int argc, char *argv[],
void *ntdll;
void (*init_func)(void);

+ linux_personality_init();
build_dll_path();
wine_init_argv0_path( argv[0] );
__wine_main_argc = argc;