Blame SOURCES/libffi-3.0.13-ppc64le-2.patch

e9b5f4
Date: Wed, 20 Nov 2013 18:05:21 +1030
e9b5f4
From: Alan Modra <amodra at gmail dot com>
e9b5f4
To: libffi-discuss at sourceware dot org
e9b5f4
Subject: PowerPC64 ELFv2 fix 2 of 2
e9b5f4
Message-ID: <20131120073521.GG22514@bubble.grove.modra.org>
e9b5f4
References: <20131117031650.GR22514@bubble.grove.modra.org> <87eh6e2b4o.fsf@redhat.com> <20131119001430.GX22514@bubble.grove.modra.org>
e9b5f4
MIME-Version: 1.0
e9b5f4
Content-Type: text/plain; charset=us-ascii
e9b5f4
Content-Disposition: inline
e9b5f4
In-Reply-To: <20131119001430 dot GX22514 at bubble dot grove dot modra dot org>
e9b5f4
User-Agent: Mutt/1.5.21 (2010-09-15)
e9b5f4
e9b5f4
Using NUM_FPR_ARG_REGISTERS rather than NUM_FPR_ARG_REGISTERS64 meant
e9b5f4
that a parameter save area could be allocated before it was strictly
e9b5f4
necessary.  Wrong but harmless.  Found when splitting apart ffi.c
e9b5f4
into 32-bit and 64-bit support.
e9b5f4
e9b5f4
	* src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use
e9b5f4
	NUM_FPR_ARG_REGISTERS64 and NUM_GPR_ARG_REGISTERS64 not their
e9b5f4
	32-bit versions for 64-bit code.
e9b5f4
e9b5f4
diff --git a/src/powerpc/ffi.c b/src/powerpc/ffi.c
e9b5f4
index feb2144..6896065 100644
e9b5f4
--- a/src/powerpc/ffi.c
e9b5f4
+++ b/src/powerpc/ffi.c
e9b5f4
@@ -978,7 +978,7 @@ ffi_prep_cif_machdep_core (ffi_cif *cif)
e9b5f4
 	  case FFI_TYPE_LONGDOUBLE:
e9b5f4
 	    fparg_count += 2;
e9b5f4
 	    intarg_count += 2;
e9b5f4
-	    if (fparg_count > NUM_FPR_ARG_REGISTERS)
e9b5f4
+	    if (fparg_count > NUM_FPR_ARG_REGISTERS64)
e9b5f4
 	      flags |= FLAG_ARG_NEEDS_PSAVE;
e9b5f4
 	    break;
e9b5f4
 #endif
e9b5f4
@@ -986,7 +986,7 @@ ffi_prep_cif_machdep_core (ffi_cif *cif)
e9b5f4
 	  case FFI_TYPE_DOUBLE:
e9b5f4
 	    fparg_count++;
e9b5f4
 	    intarg_count++;
e9b5f4
-	    if (fparg_count > NUM_FPR_ARG_REGISTERS)
e9b5f4
+	    if (fparg_count > NUM_FPR_ARG_REGISTERS64)
e9b5f4
 	      flags |= FLAG_ARG_NEEDS_PSAVE;
e9b5f4
 	    break;
e9b5f4
 
e9b5f4
@@ -1007,12 +1007,12 @@ ffi_prep_cif_machdep_core (ffi_cif *cif)
e9b5f4
 	    if (elt)
e9b5f4
 	      {
e9b5f4
 		fparg_count += elnum;
e9b5f4
-		if (fparg_count > NUM_FPR_ARG_REGISTERS)
e9b5f4
+		if (fparg_count > NUM_FPR_ARG_REGISTERS64)
e9b5f4
 		  flags |= FLAG_ARG_NEEDS_PSAVE;
e9b5f4
 	      }
e9b5f4
 	    else
e9b5f4
 	      {
e9b5f4
-		if (intarg_count > NUM_GPR_ARG_REGISTERS)
e9b5f4
+		if (intarg_count > NUM_GPR_ARG_REGISTERS64)
e9b5f4
 		  flags |= FLAG_ARG_NEEDS_PSAVE;
e9b5f4
 	      }
e9b5f4
 	    break;
e9b5f4
@@ -1030,7 +1030,7 @@ ffi_prep_cif_machdep_core (ffi_cif *cif)
e9b5f4
 	    /* Everything else is passed as a 8-byte word in a GPR, either
e9b5f4
 	       the object itself or a pointer to it.  */
e9b5f4
 	    intarg_count++;
e9b5f4
-	    if (intarg_count > NUM_GPR_ARG_REGISTERS)
e9b5f4
+	    if (intarg_count > NUM_GPR_ARG_REGISTERS64)
e9b5f4
 	      flags |= FLAG_ARG_NEEDS_PSAVE;
e9b5f4
 	    break;
e9b5f4
 	  default:
e9b5f4
e9b5f4
-- 
e9b5f4
Alan Modra
e9b5f4
Australia Development Lab, IBM
e9b5f4