HP-PA 64 / calls.c crash fix
Jan Hubicka
jh@suse.cz
Thu May 11 11:10:00 GMT 2000
Hi
Iôve finally got around and built cross compiler. Since I donôt have
the binutils I canôt even try to bootstrap, but by throwing random
sources to the compiler I found following testcase trigger calls.c
crash Jeff is complaining about:
typedef struct {
char y;
char x[32];
} X;
int z (void)
{
X xxx;
xxx.x[0] =
xxx.x[31] = '0';
xxx.y = 0xf;
return f (xxx, xxx);
}
int main (void)
{
int val;
val = z ();
if (val != 0x60)
abort ();
exit (0);
}
int f(X x, X y)
{
if (x.y != y.y)
return 'F';
return x.x[0] + y.x[0];
}
The problem is actually latent bug in expr.c/emit_push_insn and has nothing to
do with the alignment code, only the sanity checking caught accidental adjust
of the stack pointer. The problem happends in cases where we preallocate
argblock and use alignment_pad to ensure alignment. The emit_push_insn then
end by anti_adjust_stack (alignment_pad); unconditionally and thats of course
incorrect when we donôt use push instructions.
Avoiding that adjustment makes test above to pass for me.
(the coude ought to be correct, since next argument will be store to the
properly precalculated offset. Whether it is correct for HP-PA64 to
pad arguments is behind my understanding of that architecture).
Jeff: hope this fixes the bootstrap problem you are seeing. If not *please* try
to send me some kind of usefull bugreport (at least testcase). Iôve actually
spend half a day by setting up the crosscompiler and looking for the testcase.
I am just running bootstrap on i386 in case something will go wrong I will
note it on the list, but since i386 donôt precalculate nor pad arguments
I donôt expect so.
Don Mai 11 20:03:00 CEST 2000 Jan Hubicka <jh@suse.cz>
* expr.c (emit_push_insn): Do not adjust stack pointer when
preallocating.
Index: egcs/gcc/expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.239
diff -c -w -c -3 -p -r1.239 expr.c
*** expr.c 2000/05/09 19:55:47 1.239
--- expr.c 2000/05/11 17:59:07
*************** emit_push_insn (x, mode, type, size, ali
*** 3321,3327 ****
if (extra && args_addr == 0 && where_pad == stack_direction)
anti_adjust_stack (GEN_INT (extra));
! if (alignment_pad)
anti_adjust_stack (alignment_pad);
}
--- 3321,3327 ----
if (extra && args_addr == 0 && where_pad == stack_direction)
anti_adjust_stack (GEN_INT (extra));
! if (alignment_pad && !args_addr)
anti_adjust_stack (alignment_pad);
}
More information about the Gcc-patches
mailing list