On 8/2/05, Dave Korn <[EMAIL PROTECTED]> wrote:
>   In order for anyone to answer your questions about the alignment of
> various types in a struct, don't you think you should perhaps have told us a
> little about what those types actually are and how the struct is laid out?

Of course, my apologies. I was clearly overly terse. I declare the
structure packed as follows:

typedef struct {
        uint16_t a;
        uint32_t b;
} __attribute__((packed)) st;

void foo(st *s, int n)
{
        memcpy(&s->b, &n, sizeof n);
}

This code generates the unaligend store:
$ arm-elf-objdump -d packed.o
...
   0:   e24dd004        sub     sp, sp, #4      ; 0x4
   4:   e5801002        str     r1, [r0, #2]
   8:   e28dd004        add     sp, sp, #4      ; 0x4
   c:   e12fff1e        bx      lr
$ arm-elf-gcc --version | head -1
arm-elf-gcc (GCC) 4.0.1

Cheers,
Shaun

Reply via email to