This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[LIBFFI] Re: Re: [PATCH] Add support for PaX enable kernels (MPROTECT)
- From: Dave Korn <dave dot korn dot cygwin at gmail dot com>
- To: libffi-discuss at sourceware dot org
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 21 Feb 2013 19:22:18 +0000
- Subject: [LIBFFI] Re: Re: [PATCH] Add support for PaX enable kernels (MPROTECT)
- References: <30737390.tlL1EbtGQR@laptop1.gw.ume.nu>
On 07/11/2012 00:14, Magnus Granberg wrote:
> 2012-11-07 Magnus Granberg <zorry@gentoo...
> Pavel Labushev <pavel.labushev@runbox...
>
> * configure.ac: Add --enable-pax_emutramp for PaX enable kernels.
> * src/closures.c: Add emutramp_enabled_check. Don't mmap with PROT_EXEC
> on PaX enable Kernels.
> * README: Add description for --enable-pax_emutramp.
> * fficonfig.h.in: Rebuilt.
> * configure.ac: Rebuilt.
Hi lists,
There was a small problem with this (upstream relative to gcc) libffi
patch(*). The entire #ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX clause is contained
within an outer #if !defined(X86_WIN32) && !defined(X86_WIN64) clause. That
means that Windows platforms don't get the default definition of
is_emutramp_enabled() supplied by the #else clause. However,
is_emutramp_enabled() is unconditionally referenced in dlmmap(), and without
this default definition Windows targets fail to compile.
The attached patch fixes this by moving the #else clause with the default
is_emutramp_enabled() definition to a standalone #ifndef clause outside any
enclosing conditional compilation test. I couldn't think of a better way to
do it; the #if !(windows) clause is followed by a #elif (cygwin/interix)
clause, so I'd have had to put a default definition in there and also a second
one in a subsequent unconditional #else if I didn't move it out of the
enclosing #if scope altogether.
Gcc-patches: Assuming AG approves, can we commit this without waiting for an
upstream libffi release and doing a full merge? Currently GCC HEAD won't
build libffi (and hence libjava) without it.
2013-02-21 Dave Korn <dave.korn.cygwin@gmail.com>
* src/closures.c (is_emutramp_enabled [!FFI_MMAP_EXEC_EMUTRAMP_PAX]):
Move default definition outside enclosing #if scope.
cheers,
DaveK
--
(*) - Patch: http://sourceware.org/ml/libffi-discuss/2012/msg00269.html
- Thread: http://sourceware.org/ml/libffi-discuss/2012/threads.html#00247
Index: src/closures.c
===================================================================
--- src/closures.c (revision 196167)
+++ src/closures.c (working copy)
@@ -189,8 +189,6 @@ emutramp_enabled_check (void)
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
: (emutramp_enabled = emutramp_enabled_check ()))
-#else
-#define is_emutramp_enabled() 0
#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
#elif defined (__CYGWIN__) || defined(__INTERIX)
@@ -202,6 +200,10 @@ emutramp_enabled_check (void)
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
+#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
+#define is_emutramp_enabled() 0
+#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
/* Declare all functions defined in dlmalloc.c as static. */
static void *dlmalloc(size_t);
static void dlfree(void*);