[PATCH] PPC SVR4 va_arg PR target/19491

David Edelsohn dje@watson.ibm.com
Fri Jan 21 22:37:00 GMT 2005


	rs6000_va_start assigns the gpr and fpr members of the PPC SVR4
valist structure to the total number of integer and floating point
arguments, respectively.  The members are of type unsigned char and may
overflow.  The members are intended to index into the argument GPRs and
FPRs, not all arguments.  This patch limits the values to the maximum
number of GPR arguments and FPR arguments.  This appears to fix the
problem reported in the PR and work correctly.

	Does anyone with more knowledge about the PPC SVR4 ABI have any
comments? 

Thanks, David


2005-01-20  David Edelsohn  <edelsohn@gnu.org>
	    Andrew Pinski  <pinskia@physics.uc.edu>

	* config/rs6000/rs6000.c (rs6000_va_start): Saturate n_gpr at
	maximum number of GPRs.  Saturate n_fpr at maximum number of FPRs.

Index: rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.780
diff -c -p -r1.780 rs6000.c
*** rs6000.c	18 Jan 2005 12:01:37 -0000	1.780
--- rs6000.c	21 Jan 2005 21:50:33 -0000
*************** rs6000_va_start (tree valist, rtx nextar
*** 5995,6002 ****
  
    /* Count number of gp and fp argument registers used.  */
    words = current_function_args_info.words;
!   n_gpr = current_function_args_info.sysv_gregno - GP_ARG_MIN_REG;
!   n_fpr = current_function_args_info.fregno - FP_ARG_MIN_REG;
  
    if (TARGET_DEBUG_ARG)
      fprintf (stderr, "va_start: words = "HOST_WIDE_INT_PRINT_DEC", n_gpr = "
--- 5995,6004 ----
  
    /* Count number of gp and fp argument registers used.  */
    words = current_function_args_info.words;
!   n_gpr = MIN (current_function_args_info.sysv_gregno - GP_ARG_MIN_REG,
! 	       GP_ARG_NUM_REG);
!   n_fpr = MIN (current_function_args_info.fregno - FP_ARG_MIN_REG,
! 	       FP_ARG_NUM_REG);
  
    if (TARGET_DEBUG_ARG)
      fprintf (stderr, "va_start: words = "HOST_WIDE_INT_PRINT_DEC", n_gpr = "



More information about the Gcc-patches mailing list