This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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]

S/390: Fix C aliasing violation in libffi


Hello,

recent compiler changes exposed a C aliasing violation in the s390
part of libffi, causing a miscompilation of ffi_prep_args.  Fixed thus.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux,
fixes numerous ffi testcases.

Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* src/s390/ffi.c (ffi_prep_args): Fix C aliasing violation.
	(ffi_check_float_struct): Remove unused prototype.


Index: libffi/src/s390/ffi.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/s390/ffi.c,v
retrieving revision 1.4
diff -c -p -r1.4 ffi.c
*** libffi/src/s390/ffi.c	5 Feb 2003 23:58:57 -0000	1.4
--- libffi/src/s390/ffi.c	10 Jul 2004 21:36:59 -0000
***************
*** 69,75 ****
  /*====================================================================*/
   
  static void ffi_prep_args (unsigned char *, extended_cif *);
- static int ffi_check_float_struct (ffi_type *);
  void
  #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
  __attribute__ ((visibility ("hidden")))
--- 69,74 ----
*************** ffi_prep_args (unsigned char *stack, ext
*** 222,236 ****
  	    }
  	}
  
!       /* Pointers are passed like UINTs of the same size.  */
!       if (type == FFI_TYPE_POINTER)
! #ifdef __s390x__
! 	type = FFI_TYPE_UINT64;
! #else
! 	type = FFI_TYPE_UINT32;
! #endif
! 
!       /* Now handle all primitive int/float data types.  */
        switch (type) 
  	{
  	  case FFI_TYPE_DOUBLE:
--- 221,227 ----
  	    }
  	}
  
!       /* Now handle all primitive int/pointer/float data types.  */
        switch (type) 
  	{
  	  case FFI_TYPE_DOUBLE:
*************** ffi_prep_args (unsigned char *stack, ext
*** 251,256 ****
--- 242,254 ----
  	    else
  	      p_ov[n_ov++] = *(unsigned int *) arg;
  	    break;
+ 
+ 	  case FFI_TYPE_POINTER:
+ 	    if (n_gpr < MAX_GPRARGS)
+ 	      p_gpr[n_gpr++] = (unsigned long)*(unsigned char **) arg;
+ 	    else
+ 	      p_ov[n_ov++] = (unsigned long)*(unsigned char **) arg;
+ 	    break;
   
  	  case FFI_TYPE_UINT64:
  	  case FFI_TYPE_SINT64:
-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


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