This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Fix 64-bit libffi testsuite on Solaris 10+ (PR libffi/40700)


As described in the PR, many 64-bit libffi testcases started to fail on
Solaris 10 and 11 between 20090612 and 20090622.  Core dump logging
revealed the cause:

Nov 27 14:45:24 cumaru genunix: [ID 269049 kern.notice] NOTICE: cls_ushort.exe[21514] attempt to execute non-executable data at 0x600fd0 by uid 2110

I could track this to the following patch:

2009-06-11  Timothy Wall  <twall@users.sf.net>
[...]
        * testsuite/libffi.call/closure_fn0.c,
[...]
        testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead
        of checking for MMAP.  Use intptr_t instead of long casts.

While before the patch, the testsuite would have used allocate_mmap to
allocate ffi_closure's, afterwards src/closures.c (ffi_closure_alloc)
without FFI_MMAP_EXEC_WRIT defined would simply use malloc instead,
leading to the observed failure.

So the fix is obvious: just define FFI_MMAP_EXEC_WRIT for 64-bit
Solaris/x86.  The following patch does just that and allows the libffi
testsuite to complete almost successfully (the remaining failures are
unrelated) for both 32 and 64 bit on i386-pc-solaris2.11.

Ok for mainline?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2009-12-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR libffi/40700
	* src/closures.c [X86_64 && __sun__ && __svr4__]
	(FFI_MMAP_EXEC_WRIT): Define.

Index: libffi/src/closures.c
===================================================================
--- libffi/src/closures.c	(revision 155092)
+++ libffi/src/closures.c	(working copy)
@@ -1,6 +1,6 @@
 /* -----------------------------------------------------------------------
    closures.c - Copyright (c) 2007  Red Hat, Inc.
-   Copyright (C) 2007 Free Software Foundation, Inc
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc
 
    Code to allocate and deallocate memory for closures.
 
@@ -50,6 +50,11 @@
    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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]