Fix argument pushes to unaligned stack slots

Joseph S. Myers joseph@codesourcery.com
Thu Jul 21 19:47:00 GMT 2011


On Tue, 12 Jul 2011, matthew green wrote:

> 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

I don't see how it can be safe; if the stack slot is insufficiently 
aligned, the special handling will be needed.  Maybe the alignment being 
passed to this code is wrong, but if it's correct then you need a way to 
handle the unaligned move properly; I don't know if it would be possible 
or safe to pass a non-NULL type here, for example.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list