1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
--- src/closures.c
+++ src/closures.c
@@ -50,11 +50,6 @@
executable memory. */
# define FFI_MMAP_EXEC_WRIT 1
# endif
-# if defined(X86_64) && defined(__sun__) && defined(__svr4__)
-/* The data segment on 64-bit Solaris/x86 isn't executable, so use mmap
- instead. */
-# define FFI_MMAP_EXEC_WRIT 1
-# endif
#endif
#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
@@ -214,6 +209,8 @@
#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
+#if FFI_MMAP_EXEC_SELINUX
+
/* A mutex used to synchronize access to *exec* variables in this file. */
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -483,6 +480,27 @@
return dlmmap_locked (start, length, prot, flags, offset);
}
+#else
+
+static void *
+dlmmap (void *start, size_t length, int prot,
+ int flags, int fd, off_t offset)
+{
+
+ assert (start == NULL && length % malloc_getpagesize == 0
+ && prot == (PROT_READ | PROT_WRITE)
+ && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
+ && fd == -1 && offset == 0);
+
+#if FFI_CLOSURE_TEST
+ printf ("mapping in %zi\n", length);
+#endif
+
+ return mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
+}
+
+#endif
+
/* Release memory at the given address, as well as the corresponding
executable page if it's separate. */
static int