George France wrote:
> > Run 'info gcc', look up pragmas or alignment in the index.
> >
> > In particular, the main problem we have run into are structs
> > containing
> > shorts getting padded to 4-byte boundaries. Signed vs
> > unsigned char can
> > also be a problem.
>
> And casting of pointers, may cross the 4 byte boundry.
>
> --George
>
> _______________________________________________
> iPAQ mailing list
> iPAQ@handhelds.org
> http://handhelds.org/mailman/listinfo/ipaq
Like when someone tries to overlay a struct onto an array of bytes.
Maybe I've been staring at the problem too long, but it looks like on
the ARM (even compiling natively on a NetWinder), a pointer to a struct
points to the first element of the struct (no surprise there), but this
is actually the highest address of the element.
For example:
struct foo_t { u16 x; };
foo_t foo;
so that:
&foo = 0x204da35
&foo.x = 0x204da35
But if you assign foo.x = 4 you get this in memory:
0x204da34 = 0x04
0x204da35 = 0x00
0x204da36 = 0x00
But the same code compiled on an i386 results in this:
0x204da34 = 0x00
0x204da35 = 0x04
0x204da36 = 0x00
I'm not sure if I can fix this using alignment magic in the compiler.
--Gordon
Received on Thu Sep 14 15:03:15 2000
This archive was generated by hypermail 2.1.8 : Tue May 04 2004 - 09:43:42 EDT