This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC/TileGX 1/6] fix args alignment bug
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Jiong Wang <jiwang at tilera dot com>
- Cc: gdb-patches at sourceware dot org, Walter Lee <walt at tilera dot com>
- Date: Fri, 18 Jan 2013 17:13:58 +0400
- Subject: Re: [RFC/TileGX 1/6] fix args alignment bug
- References: <50F9148F.3010602@tilera.com>
> gdb/ChangeLog:
>
> * tilegx-tdep.c (tilegx_push_dummy_call): args pushed on stack
> should be aligned to 64bit.
Some questions below...
> - /* Loop backwards through arguments to determine stack alignment. */
> - alignlen = 0;
> -
> - for (j = nargs - 1; j >= i; j--)
> - {
> - typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
> - alignlen += (typelen + 3) & (~3);
> - }
> -
> - if (alignlen & 0x4)
> - stack_dest -= 4;
Do you have any hint as to why this code was written the way it was?
It doesn't seem like the type of code that would be added by accident.
Did Jeff (the apparent author) misunderstand the ABI?
> typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
> - slacklen = ((typelen + 3) & (~3)) - typelen;
> + slacklen = ((typelen + 7) & (~7)) - typelen;
This is a detail, but can you use utils.c:align_up, in this case?
(I find those midly more readable than these incantations, but
it's OK if you prefer the code to stay as is).
> /* Add 2 words for linkage space to the stack. */
> - stack_dest = stack_dest - 8;
> - write_memory (stack_dest, two_zero_words, 8);
> + stack_dest = stack_dest - 16;
> + write_memory (stack_dest, four_zero_words, 16);
It looks like you need to adjust the comment as well.
--
Joel