Subject: Re: structure alignment on arm in NetBSD? (resend without html)
To: None <tech-toolchain@netbsd.org>
From: Valeriy E. Ushakov <uwe@stderr.spb.ru>
List: tech-toolchain
Date: 10/16/2007 15:55:20
On Mon, Oct 15, 2007 at 10:28:04 -0700, Matt Thomas wrote:

> On Oct 15, 2007, at 9:45 AM, Martin Fouts wrote:
> 
> >Deep in the heart of gcc sources,
> >In src/gnu/dist/gcc4/gcc/config/arm/netbsd-elf.h I found the comment
> >
> >/* 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=3Drounded size.  By changing the
> >   structure alignment to 8. GCC will conform to what is expected by
> >   NetBSD.
> >
> >(rest elided...)
> >
> >Is this comment still accurate?
> 
> Yes.  Also, NetBSD does not use short-enums either.

Doesn't AAPCS use "natural" alignment rules for structs (4.3.1 p.12)?
Cf. in arm.c

  /* Override the default structure alignment for AAPCS ABI.  */
  if (TARGET_AAPCS_BASED)
    arm_structure_size_boundary = 8;

It also tells that short enum is a platform choice (7.1.3. p.26)

NetBSD target doesn't seem to declare that it uses AAPCS, but it looks
close enough at a very casual glance.  

Richard Earnshaw is probably the right person to ask for clarification
on that.

SY, Uwe
-- 
uwe@stderr.spb.ru                       |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen