Index: libffi/ChangeLog
===================================================================
--- libffi.orig/ChangeLog
+++ libffi/ChangeLog
@@ -69,6 +69,11 @@
 
 	* configure: Regenerate.
 
+2011-02-11  Anthony Green  <green@moxielogic.com>
+
+	* src/sparc/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
+	just return FFI_BAD_ABI when things are wrong.
+
 2011-02-09  Stuart Shelton  <srcshelton@gmail.com>
 
 	http://bugs.gentoo.org/show_bug.cgi?id=286911
Index: libffi/src/sparc/ffi.c
===================================================================
--- libffi.orig/src/sparc/ffi.c
+++ libffi/src/sparc/ffi.c
@@ -1,6 +1,6 @@
 /* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1996, 2003, 2004, 2007, 2008 Red Hat, Inc.
-           Copyright (c) 2011 Anthony Green
+   ffi.c - Copyright (c) 2011 Anthony Green
+           Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc.
    
    SPARC Foreign Function Interface 
 
@@ -489,7 +489,8 @@ ffi_prep_closure_loc (ffi_closure* closu
 #ifdef SPARC64
   /* Trampoline address is equal to the closure address.  We take advantage
      of that to reduce the trampoline size by 8 bytes. */
-  FFI_ASSERT (cif->abi == FFI_V9);
+  if (cif->abi != FFI_V9)
+    return FFI_BAD_ABI;
   fn = (unsigned long) ffi_closure_v9;
   tramp[0] = 0x83414000;	/* rd	%pc, %g1	*/
   tramp[1] = 0xca586010;	/* ldx	[%g1+16], %g5	*/
@@ -498,7 +499,8 @@ ffi_prep_closure_loc (ffi_closure* closu
   *((unsigned long *) &tramp[4]) = fn;
 #else
   unsigned long ctx = (unsigned long) codeloc;
-  FFI_ASSERT (cif->abi == FFI_V8);
+  if (cif->abi != FFI_V8)
+    return FFI_BAD_ABI;
   fn = (unsigned long) ffi_closure_v8;
   tramp[0] = 0x03000000 | fn >> 10;	/* sethi %hi(fn), %g1	*/
   tramp[1] = 0x05000000 | ctx >> 10;	/* sethi %hi(ctx), %g2	*/
