Date: Fri, 10 Jul 2009 11:28:35 +0100 From: Rui Paulo <rpaulo@freebsd.org> To: M. Warner Losh <imp@bsdimp.com> Cc: svn-src-projects@freebsd.org, des@des.no, kientzle@freebsd.org, src-committers@freebsd.org, brde@optusnet.com.au Subject: Re: svn commit: r195460 - projects/mesh11s/sys/net80211 Message-ID: <8C5DD2ED-C2C2-4101-8FCC-4690A838684B@freebsd.org> In-Reply-To: <20090710.012630.-875846397.imp@bsdimp.com> References: <20090709041145.G46111@delplex.bde.org> <86prc9g8yf.fsf@ds4.des.no> <4A561477.7000508@freebsd.org> <20090710.012630.-875846397.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 NetBSD. This has several side effects that should be considered. 1. Structures will only be aligned to the size of the largest member. 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 longer word aligned. GCC will not be able to use word load/stores to copy short strings. This modification is not encouraged but with the present state of the NetBSD source tree it is currently the only solution that meets the requirements. */ #undef DEFAULT_STRUCTURE_SIZE_BOUNDARY #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8 -- 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8C5DD2ED-C2C2-4101-8FCC-4690A838684B>