installed a workaround for a bug in libffi where it does not mark

executable code with the PROT_EXEC protection flag.
This commit is contained in:
Abdulaziz Ghuloum 2009-09-07 00:04:24 +03:00
parent 7fee24e09e
commit 12f41f4a8a
6 changed files with 39 additions and 19 deletions

2
c32
View File

@ -2,7 +2,7 @@
./configure \ ./configure \
--prefix=$HOME/.opt32 \ --prefix=$HOME/.opt32 \
CFLAGS="-m32 -I$HOME/.opt32/include -I$HOME/.opt32/lib/libffi-3.0.6/include" \ CFLAGS="-m32 -I$HOME/.opt32/include -I$HOME/.opt32/lib/libffi-3.0.8/include" \
LDFLAGS="-m32 -L$HOME/.opt32/lib" \ LDFLAGS="-m32 -L$HOME/.opt32/lib" \
&& make clean \ && make clean \
&& make && make

4
c64
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
./configure --prefix=/Users/ikarus/.opt \ ./configure --prefix=$HOME/.opt64 \
CFLAGS="-m64 -I $HOME/.opt64/include -I $HOME/.opt64/lib/libffi-3.0.6/include" \ CFLAGS="-m64 -I $HOME/.opt64/include -I $HOME/.opt64/lib/libffi-3.0.8/include" \
LDFLAGS="-m64 -L$HOME/.opt64/lib" \ LDFLAGS="-m64 -L$HOME/.opt64/lib" \
&& make clean \ && make clean \
&& make && make

View File

@ -6,6 +6,11 @@
/* use flat segment and dirty vectors (not used yet) */ /* use flat segment and dirty vectors (not used yet) */
#undef FLAT_TABLES #undef FLAT_TABLES
/* Mark code returned by libffi executable because libffi does not do that
yet. This so far is only important on Snow Leopard in 64-bit mode but we
mark it on all darwins anyways. */
#undef HACK_FFI
/* Define to 1 if you have the <assert.h> header file. */ /* Define to 1 if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H #undef HAVE_ASSERT_H
@ -153,9 +158,6 @@
/* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O #undef NO_MINUS_C_MINUS_O
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */ /* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT #undef PACKAGE_BUGREPORT
@ -186,9 +188,6 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */ /* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME #undef TM_IN_SYS_TIME
/* Version number of package */
#undef VERSION
/* Number of bits in a file offset, on hosts where this is settable. */ /* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS #undef _FILE_OFFSET_BITS

14
configure vendored
View File

@ -2996,15 +2996,6 @@ fi
VERSION=0.0.4-rc1 VERSION=0.0.4-rc1
cat >>confdefs.h <<_ACEOF
#define PACKAGE "$PACKAGE"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define VERSION "$VERSION"
_ACEOF
# Some tools Automake needs. # Some tools Automake needs.
ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
@ -4931,6 +4922,11 @@ case "$target_os" in
;; ;;
*cygwin*) *cygwin*)
LDFLAGS="-Wl,-E -Wl,--export-all-symbols $LDFLAGS" LDFLAGS="-Wl,-E -Wl,--export-all-symbols $LDFLAGS"
;;
*darwin*)
$as_echo "#define HACK_FFI 1" >>confdefs.h
;; ;;
esac esac

View File

@ -4,7 +4,7 @@
AC_PREREQ(2.59) AC_PREREQ(2.59)
AC_INIT(ikarus, 0.0.4-rc1, aghuloum@cs.indiana.edu) AC_INIT(ikarus, 0.0.4-rc1, aghuloum@cs.indiana.edu)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(ikarus, 0.0.4-rc1) AM_INIT_AUTOMAKE(ikarus, 0.0.4-rc1, gnu)
AC_CONFIG_SRCDIR([src/]) AC_CONFIG_SRCDIR([src/])
@ -26,6 +26,13 @@ case "$target_os" in
*cygwin*) *cygwin*)
LDFLAGS="-Wl,-E -Wl,--export-all-symbols $LDFLAGS" LDFLAGS="-Wl,-E -Wl,--export-all-symbols $LDFLAGS"
;; ;;
*darwin*)
AC_DEFINE(HACK_FFI, 1,
[Mark code returned by libffi executable because
libffi does not do that yet. This so far is only
important on Snow Leopard in 64-bit mode but we
mark it on all darwins anyways.])
;;
esac esac
AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(void *)

View File

@ -10,6 +10,10 @@
#undef DEBUG_FFI #undef DEBUG_FFI
#ifdef HACK_FFI
#include <sys/mman.h>
#endif
static void* static void*
alloc(size_t n, int m) { alloc(size_t n, int m) {
void* x = calloc(n, m); void* x = calloc(n, m);
@ -435,6 +439,20 @@ ikrt_prepare_callback(ikptr data, ikpcb* pcb){
ikptr cifptr = ref(data, off_vector_data + 0 * wordsize); ikptr cifptr = ref(data, off_vector_data + 0 * wordsize);
void* codeloc; void* codeloc;
ffi_closure* closure = ffi_closure_alloc(sizeof(ffi_closure), &codeloc); ffi_closure* closure = ffi_closure_alloc(sizeof(ffi_closure), &codeloc);
#ifdef HACK_FFI
{
long code_start = align_to_prev_page(codeloc);
long code_end =
align_to_next_page(FFI_TRAMPOLINE_SIZE+(-1)+(long)codeloc);
int rv = mprotect((void*)code_start, code_end - code_start,
PROT_READ|PROT_WRITE|PROT_EXEC);
if(rv) {
fprintf(stderr, "Error mprotecting code page!\n");
}
}
#endif
ffi_cif* cif = (ffi_cif*) ref(cifptr, off_pointer_data); ffi_cif* cif = (ffi_cif*) ref(cifptr, off_pointer_data);
callback_locative* loc = malloc(sizeof(callback_locative)); callback_locative* loc = malloc(sizeof(callback_locative));