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]

ARM: structure return fix


Hi Guys,

  The ARM port has been broken for a while now, in that when a
  function has to return a large structure it was passing a hidden
  memory pointer in the second argument register (r1) instead of the
  first (r0).  This breaks compatibility with the ARM ABI standard
  (ATPCS) and also interferes with thunk handling which wants to use
  r1.

  Fixed, for now, by applying the following patch.  One day it would
  be good to switch back to using STRUCT_VALUE and fix the backend to
  remove the  special case code.

Cheers
        Nick


2001-12-06  Nick Clifton  <nickc@cambridge.redhat.com>

	* config/arm/arm.h (STRUCT_VALUE): Suppress definition.
	(STRUCT_VALUE_REGNUM): Restore definition.

Index: config/arm/arm.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.123
diff -p -c -r1.123 arm.h
*** arm.h	2001/12/05 20:32:08	1.123
--- arm.h	2001/12/06 15:11:57
*************** extern const char * structure_size_strin
*** 905,912 ****
--- 905,923 ----
  /* Return the regiser number of the N'th (integer) argument.  */
  #define ARG_REGISTER(N) 	(N - 1)
  
+ #if 0 /* FIXME: The ARM backend has special code to handle structure
+ 	 returns, and will reserve its own hidden first argument.  So
+ 	 if this macro is enabled a *second* hidden argument will be
+ 	 reserved, which will break binary compatability with old
+ 	 toolchains and also thunk handling.  One day this should be
+ 	 fixed.  */
  /* RTX for structure returns.  NULL means use a hidden first argument.  */
  #define STRUCT_VALUE		0
+ #else
+ /* Register in which address to store a structure value
+    is passed to a function.  */
+ #define STRUCT_VALUE_REGNUM	ARG_REGISTER (1)
+ #endif
  
  /* Specify the registers used for certain standard purposes.
     The values of these macros are register numbers.  */




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