This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: va_arg and Alignment
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: "D. Towner" <towner at cs dot bris dot ac dot uk>
- Cc: gcc <gcc at gcc dot gnu dot org>
- Date: 09 Mar 2002 12:33:18 +1100
- Subject: Re: va_arg and Alignment
- References: <Pine.GSO.4.33.0203061605060.2724-100000@tao>
>>>>> "D" == D Towner <towner@compsci.bristol.ac.uk> writes:
> The call to `f' is correctly initialised, with the long value being
> aligned on a 32-bit boundary. However, within `f', the va_arg line will
> try to load the long value from a location which isn't on the correct
> boundary (i.e., the 16-bit address of the last named parameter +
> 16-bits).
You probably have to code your own vaarg implementation.
Look in the ppc port at:
rs6000_va_arg
rs6000_va_start
rs6000_build_va_list
particularly this code in va_start:
/* Care for on-stack alignment if needed. */
if (rsize <= 1)
t = ovf;
else
{
int align;
/* Vectors are 16 byte aligned. */
if (TREE_CODE (type) == VECTOR_TYPE)
align = 15;
else
align = 7;
t = build (PLUS_EXPR, TREE_TYPE (ovf), ovf, build_int_2 (align, 0));
t = build (BIT_AND_EXPR, TREE_TYPE (t), t, build_int_2 (-align-1, -1));
}
i just fixed this today :)
cheers
aldy