Add trampoline check (backported).

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/stable@24766 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2007-03-05 16:04:25 +00:00
parent af8f42e9c0
commit f1b01b0c25
4 changed files with 5186 additions and 7520 deletions

View file

@ -1,3 +1,8 @@
2007-03-05 Adam Fedor <fedor@gnu.org>
* configure.ac, config/config.trampoline.c: Add trampoline test.
(backported).
2007-03-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSHTTPURLHandle.m:

103
config/config.trampoline.c Normal file
View file

@ -0,0 +1,103 @@
/* Trampoline test */
/*
* Copyright 1995-1999, 2001-2002, 2004-2006 Bruno Haible, <bruno@clisp.org>
*
* This is free software distributed under the GNU General Public Licence
* described in the file COPYING. Contact the author if you don't have this
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
* on this software.
*/
#include <stdio.h>
#include <stdlib.h>
#include "trampoline_r.h"
#define MAGIC1 0x9db9af42
#define MAGIC2 0x614a13c9
#define MAGIC3 0x7aff3cb4
#define MAGIC4 0xa2f9d045
#ifdef __cplusplus
typedef int (*function)(...);
#else
typedef int (*function)();
#endif
#if defined(__i386__)
int f (void* env, int x)
#else
int f (int x)
#endif
{
#ifdef __GNUC__
#ifdef __m68k__
#ifdef __NetBSD__
register void* env __asm__("a1");
#else
register void* env __asm__("a0");
#endif
#endif
#ifdef __mips__
register void* env __asm__("$2");
#endif
#ifdef __mips64__
register void* env __asm__("$2");
#endif
#if defined(__sparc__) && !defined(__sparc64__)
register void* env __asm__("%g2");
#endif
#ifdef __sparc64__
register void* env __asm__("%g5");
#endif
#ifdef __alpha__
register void* env __asm__("$1");
#endif
#ifdef __hppa__
register void* env __asm__("%r29");
#endif
#ifdef __arm__
register void* env __asm__("r12");
#endif
#ifdef __powerpc__
#ifdef __NetBSD__
register void* env __asm__("r13");
#else
register void* env __asm__("r11");
#endif
#endif
#ifdef __m88k__
register void* env __asm__("r11");
#endif
#ifdef __convex__
register void* env __asm__("s0");
#endif
#ifdef __ia64__
register void* env __asm__("r15");
#endif
#ifdef __x86_64__
register void* env __asm__("r10");
#endif
#ifdef __s390__
register void* env __asm__("r0");
#endif
return x + (int)((long*)env)[0] + (int)((long*)env)[1] + MAGIC3;
#else
return x + MAGIC3;
#endif
}
int main ()
{
function cf = alloc_trampoline_r((function)&f, (void*)MAGIC1, (void*)MAGIC2);
#ifdef __GNUC__
if ((*cf)(MAGIC4) == MAGIC1+MAGIC2+MAGIC3+MAGIC4)
#else
if ((*cf)(MAGIC4) == MAGIC3+MAGIC4)
#endif
{ free_trampoline_r(cf); printf("Works, test1 passed.\n"); exit(0); }
else
{ printf("Doesn't work!\n"); exit(1); }
}

12578
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1146,7 +1146,7 @@ case "$target_os" in
cygwin*) PASS_ARG=yes;;
esac
AC_MSG_CHECKING("use of pass-through arguments")
AC_MSG_CHECKING(use of pass-through arguments)
AC_ARG_ENABLE(pass-arguments,
[ --enable-pass-arguments Force user main call to NSProcessInfo initialize],,
enable_pass_arguments=$PASS_ARG)
@ -1159,7 +1159,7 @@ fi
AC_SUBST(GS_PASS_ARGUMENTS)
AC_MSG_RESULT($enable_pass_arguments)
AC_MSG_CHECKING("use of fake-main definition")
AC_MSG_CHECKING(use of fake-main definition)
AC_ARG_ENABLE(fake-main,
[ --enable-fake-main Force redefine of user main function],,
enable_fake_main=no)
@ -1268,7 +1268,7 @@ fi
have_forward_hook=yes
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
AC_MSG_CHECKING("for forwarding callback in runtime")
AC_MSG_CHECKING(for forwarding callback in runtime)
AC_COMPILE_IFELSE([#include "$srcdir/config/config.forward.m"],
have_forward_hook=yes, have_forward_hook=no)
AC_MSG_RESULT($have_forward_hook)
@ -1278,7 +1278,7 @@ if test $have_forward_hook = no; then
fi
CPPFLAGS="$saved_CPPFLAGS"
AC_MSG_CHECKING("FFI library usage")
AC_MSG_CHECKING(FFI library usage)
WITH_FFI=none
if test $enable_libffi = yes; then
AC_DEFINE(USE_LIBFFI,1,
@ -1298,6 +1298,14 @@ elif test $enable_ffcall = yes; then
if test $ffi_ok = yes; then
AC_MSG_RESULT(ffcall)
fi
AC_MSG_CHECKING(if ffcall trampolines work)
AC_RUN_IFELSE([#include "$srcdir/config/config.trampoline.c"],
have_working_trampoline=yes, have_working_trampoline=no,
have_working_trampoline=yes)
AC_MSG_RESULT($have_working_trampoline)
if test $have_working_trampoline = no; then
ffi_ok=no
fi
else
ffi_ok=no
fi
@ -1307,6 +1315,10 @@ if test $ffi_ok = no; then
echo
if test $have_forward_hook = no; then
echo "You do not have an up-to-date libobjc library installed"
elif test "$have_working_trampoline" = no; then
echo "You have ffcall, but it does not work properly. Most likely because"
echo "your're system's security policy is blocking some parts of ffcall"
echo "we recommend installing libffi instead."
else
echo "You do not have either ffcall or libffi installed, or configure needs"
echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them"