svn commit: r195460 - projects/mesh11s/sys/net80211

Rui Paulo rpaulo at
Fri Jul 10 10:28:39 UTC 2009

On 10 Jul 2009, at 08:26, M. Warner Losh wrote:
> It isn't a compiler bug.  It is an ABI requirement for ARM.  At least
> for the ABI we use.  there are others that might be better, and not
> suffer from this surprise.  We[*] should investigate them.

Verbatim copy from gcc/config/arm/netbsd-elf.h:

/* VERY BIG NOTE: Change of structure alignment for NetBSD/arm.
    There are consequences you should be aware of...

    Normally GCC/arm uses a structure alignment of 32 for compatibility
    with armcc.  This means that structures are padded to a word
    boundary.  However this causes problems with bugged NetBSD kernel
    code (possibly userland code as well - I have not checked every
    binary).  The nature of this bugged code is to rely on sizeof()
    returning the correct size of various structures rounded to the
    nearest byte (SCSI and ether code are two examples, the vm system
    is another).  This code breaks when the structure alignment is 32
    as sizeof() will report a word=rounded size.  By changing the
    structure alignment to 8. GCC will conform to what is expected by

    This has several side effects that should be considered.
    1. Structures will only be aligned to the size of the largest  
       i.e. structures containing only bytes will be byte aligned.
            structures containing shorts will be half word aligned.
            structures containing ints will be word aligned.

       This means structures should be padded to a word boundary if
       alignment of 32 is required for byte structures etc.

    2. A potential performance penalty may exist if strings are no  
       word aligned.  GCC will not be able to use word load/stores to  
       short strings.

    This modification is not encouraged but with the present state of  
    NetBSD source tree it is currently the only solution that meets the
    requirements.  */



So, this is how NetBSD avoided it, don't know if it's the best way to  
do it. We have DEFAULT_STRUCTURE_SIZE_BOUNDARY equal to 32 (the  
default), so our case is different and this is the reason why  
alignment will always be done on a word basis.

Rui Paulo

More information about the svn-src-projects mailing list