[arm-gnu] short int parameter passing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[arm-gnu] short int parameter passing



Hi,
I'm using arm-2007q3 (the one distributed with ScratchBox in the
package: scratchbox-toolchain-cs2007q3-glibc2.5-arm7-1.0.8-6-i386.tar.gz)
and I've found something strange regarding the alignment of short ints
during parameter passing.

Looking at the "Procedure Call Standard for the ARM Architecture",
release 2.07, page 11, I see that "signed half-word" (that should be
"short int", in C) has byte size and byte alignment both equal to 2.

But if I execute the following simple test program, step by step, I
see that the short int parameters are passed with a 4 bytes alignment
(v1 in R0, v2 in R1, v3 in R2).

//---------------------------------
int f(void *v1, short int v2, short int v3)
{
        if (v1==1 && v2==2 && v3==3)
        {
                return 0;
        }
        else
        {
                return 1;
        }
}

int main()
{
        return f(1,2,3);
}
//------------------------------------

If I understand the standard in the correct way, the parameters should
be: v1 in R0, v2 in R1 (2 least significant bytes), v3 in R1(two most
significant bytes).

Is this a bug in gcc or is there something I didn't understand?

Thanks
Michele Tartara