ARM/Thumb 4-byte alignment problem

GERASIMOV, SERGEY (HP-Roseville, ex1) sergey_gerasimov@hp.com
Mon Sep 17 11:09:00 GMT 2001


Jeff,

I think there are couple of things that could be used to overwrite default
DWORD alignment:

1. variable (structure) level, an 'aligned (alignment)' or
'__attribute__(packed)' attributes could be used.  That will force explicit
alignment on the variable or structure (in case of packed it will be 1 byte
alignment).

2. I think there is '#pragma 1' that can be used, although I have never used
it.

3. '-fpack-struct' can be used on the command line to pack structures
without holes (no DWORD alignment again).

We had to struggle with DWORD alignment as it became default with new
version of gcc for arm, and our network packet structures went crazy, until
we packed them explicitly.  I guess you have good reasons on getting rid of
DWORD alignment, but it will slow down the memory access and I think in some
cases may cause bus errors when cpu accesses on certain non aligned
addresses.  There is some logic behind that but I'd advise looking into the
arm manual for details.

Oh, BTW same applies for both arm and thumb.  Although thumb has 16 bit
instruction set, memory fetches are still 32 bit.

Hope that helps,
Sergey

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com



More information about the crossgcc mailing list