Commit 1ac92cca9b02ef8d6a769f0de1adccd5c9630355

Landon Fuller 2010-09-18T18:08:14

Add autoconf check for W^X platforms that require a trampoline table. This adds the FFI_EXEC_TRAMPOLINE_TABLE. The flag is enabled for arm-apple-darwin, where PROT_EXEC on writable (or formerly writable) pages is not permitted for sandboxed binaries.

diff --git a/configure.ac b/configure.ac
index 50f24bc..197c319 100644
--- a/configure.ac
+++ b/configure.ac
@@ -316,6 +316,11 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
 fi
 
 case "$target" in
+     *arm*-apple-darwin*)
+       AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
+                 [Cannot use PROT_EXEC on this target, so, we revert to
+                   alternative means])
+     ;;
      *-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
        AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
                  [Cannot use malloc on this target, so, we revert to
diff --git a/fficonfig.h.in b/fficonfig.h.in
index e012ebb..b54b273 100644
--- a/fficonfig.h.in
+++ b/fficonfig.h.in
@@ -17,6 +17,9 @@
 /* Define this if you want extra debugging. */
 #undef FFI_DEBUG
 
+/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
+#undef FFI_EXEC_TRAMPOLINE_TABLE
+
 /* Cannot use malloc on this target, so, we revert to alternative means */
 #undef FFI_MMAP_EXEC_WRIT