Hi,

I know I am a bit late on the party.

But I have a question...

Consider this test case:

$ cat test.c
struct s {
  int a, b;
} __attribute__((aligned(8)));

struct s f0;
int f(int a, int b, int c, int d, int e, struct s f)
{
  f0 = f;
  return __alignof(f);
}

$ arm-linux-gnueabihf-gcc -march=armv5te -O3 -S test.c
$ cat test.s
f:
        @ args = 12, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        push    {r4, r5}
        mov     r0, #8
        ldrd    r4, [sp, #12]
        ldr     r3, .L4
        strd    r4, [r3]
        pop     {r4, r5}
        bx      lr

I am pretty sure, although there is no warning, this ABI changed in GCC 5.2

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473m/dom1361290002364.html
says:

"In ARMv5TE, or in ARMv6 when SCTLR.U is 0, LDRD and STRD doubleword data 
transfers must be
eight-byte aligned.  Use ALIGN 8 before memory allocation directives such as 
DCQ if the data
is to be accessed using LDRD or STRD.  This is not required in ARMv6 when 
SCTLR.U is 1, or in
ARMv7, because in these versions, doubleword data transfers can be 
word-aligned."


So isn't this wrong code, returning 8 for alignof when it is really 4,
and wouldn't it crash on armv5 and armv6 with SCTLR.U=0 ?


Bernd.

Reply via email to