use mprotect on more platforms to make JITted code executable

svn: r2807
This commit is contained in:
Matthew Flatt 2006-04-26 22:07:24 +00:00
parent ae3e61785d
commit fd209ecb58
3 changed files with 15 additions and 3 deletions

View File

@ -660,7 +660,8 @@ void GC_init_inner()
GC_init_linux_data_start();
# endif
# if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
GC_init_netbsd_elf();
if (!GC_no_dls) /* PLTSCHEME: hack */
GC_init_netbsd_elf();
# endif
# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) \
|| defined(GC_WIN32_THREADS)

View File

@ -136,6 +136,7 @@
#ifdef i386
# define MZ_USE_JIT_I386
# define MZ_JIT_USE_MPROTECT
#endif
# define FLAGS_ALREADY_SET
@ -244,9 +245,11 @@
#if defined(i386)
# define MZ_USE_JIT_I386
# define MZ_JIT_USE_MPROTECT
#endif
#if defined(__x86_64__)
# define MZ_USE_JIT_X86_64
# define MZ_JIT_USE_MPROTECT
#endif
#if defined(powerpc)
# define MZ_USE_JIT_PPC
@ -285,6 +288,7 @@
#if defined(i386)
# define MZ_USE_JIT_I386
# define MZ_JIT_USE_MPROTECT
#endif
#if defined(powerpc)
# define MZ_USE_JIT_PPC
@ -324,6 +328,7 @@
# define USE_TM_GMTOFF_FIELD
# define MZ_USE_JIT_I386
# define MZ_JIT_USE_MPROTECT
# define FLAGS_ALREADY_SET
@ -361,6 +366,7 @@
# define REGISTER_POOR_MACHINE
# define MZ_USE_JIT_I386
# define MZ_JIT_USE_MPROTECT
# define FLAGS_ALREADY_SET
@ -1330,8 +1336,13 @@
/* MZ_USE_JIT_I386 enables the JIT for x86 */
/* MZ_USE_JIT_X86_65 enables the JIT for x86_64 */
/* MZ_USE_JIT_PPC enables the JIT for PowerPC */
/* MZ_JIT_USE_MPROTECT uses mprotect on x86 platforms to make code
pages executable */
/***********************/
/* Heap Images */
/***********************/

View File

@ -34,7 +34,7 @@
#ifndef __lightning_funcs_h
#define __lightning_funcs_h
#ifdef __linux__
#ifdef MZ_JIT_USE_MPROTECT
#include <unistd.h>
#include <sys/mman.h>
#endif
@ -51,7 +51,7 @@ jit_flush_code(void *dest, void *end)
execution of the data and stack segment are becoming more
and more common (Fedora, for example), so we implement our
jit_flush_code as an mprotect. */
#ifdef __linux__
#ifdef MZ_JIT_USE_MPROTECT
static unsigned long prev_page = 0, prev_length = 0;
long page, length;
#ifdef PAGESIZE