[U-Boot-Users] struct NS16550 {...} __attribute__ ((packed)) at ns16550.h

Arthur Shipkowski art at videon-central.com
Mon Apr 25 22:15:13 CEST 2005


>> ARM (silently) does the wrong thing i.e. masks out the lower 2 bits.
>> So gcc on ARM generates byte load/stores.
>
> ...which is broken, especially when there is no need to do this since
> the fields are properly aligned.

Based on a quick Google scan of the GCC mailing list, __attribute__
((packed)) also works (partially due to necessity and partially due to
breaking old code) as a mode to allow unaligned access to a given structure.
Some architectures offer no support for doing unaligned long loads and
stores directly (I suspect on ARM it might be due to some sort of
brokenness).  On the other hand, PPC handles it in hardware, while MIPS
invokes an exception handler in the Linux kernel
(arch/mips/kernel/unaligned.c).

There are discussions on this on the GCC mailing list going back a ways; a
notable one (that mentions m68k as another platform that generates byte
accesses besides ARM) is at http://gcc.gnu.org/ml/gcc/1997-10/msg00063.html
while a more recent bug report hinting at this fact is at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12200

Art






More information about the U-Boot mailing list