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]

re: Fix argument pushes to unaligned stack slots


hi folks.

i'm having a problem with GCC 4.5.3 on netbsd-m68k target.  i've tracked
it down to this change from several years ago:

> 2007-02-06  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* expr.c (emit_push_insn): If STRICT_ALIGNMENT, copy to an
> 	unaligned stack slot via a suitably aligned slot.

the problem is that emit_library_call_value_1() calls emit_push_insn()
with TYPE_NULL which ends up triggering a NULL deref when emit_push_insn()
calls assign_temp() with type = TYPE_NULL, and assign_temp() crashes.

this simple change seems to be sufficient to avoid the crash and the
generated code appears to run OK.  if it is OK, could someone please
commit it?  thanks.  (feel free to update my log message if it could
be clearer or more correct.)


.mrg.


2011-07-10  matthew green  <mrg@eterna.com.au>

	* expr.c (emit_push_insn): Don't copy a TYPE_NULL expression
	to the stack for correct alignment.

Index: external/gpl3/gcc/dist/gcc/expr.c
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/dist/gcc/expr.c,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 expr.c
--- external/gpl3/gcc/dist/gcc/expr.c	21 Jun 2011 01:20:17 -0000	1.1.1.1
+++ external/gpl3/gcc/dist/gcc/expr.c	12 Jul 2011 04:17:00 -0000
@@ -3764,7 +3764,8 @@ emit_push_insn (rtx x, enum machine_mode
   xinner = x;
 
   if (mode == BLKmode
-      || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode)))
+      || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode)
+          && type != NULL_TREE))
     {
       /* Copy a block into the stack, entirely or partially.  */
 


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