[sodaville] [PATCH 3/4] of/dtc: force dtb size to modulo 32 bytes

David Gibson david at gibson.dropbear.id.au
Fri Nov 12 12:16:17 EST 2010


On Thu, Nov 11, 2010 at 05:01:16PM -0800, Dirk Brandewie wrote:
> On 11/11/2010 04:47 PM, H. Peter Anvin wrote:
> >On 11/11/2010 04:03 PM, dirk.brandewie at gmail.com wrote:
> >>From: Dirk Brandewie<dirk.brandewie at gmail.com>
> >>
> >>This patch forces the size of the DTB to be modulo 32 bytes. This is
> >>needed to support linking multiple DTB's into a single section in the
> >>image. GCC wants structures to be 32 byte aligned without this change
> >>DTB's after the first in the section may not be properly aligned so
> >>the flat tree parsing code will fall over.
> >>
> >>Signed-off-by: Dirk Brandewie<dirk.brandewie at gmail.com>
> >
> >I don't think 32 is a universal number; it should depend on the ABI.  On
> >x86, for one thing, I'm pretty sure that there is no particular
> >alignment requirements beyond the natural alignment of the data items,
> >for example.
> >
> >Although 32 is probably conservative on any platform, please flag the
> >origin of this with a comment, or make it a constant defined in a header
> >file... otherwise, if this breaks for whatever reason it'll be near
> >impossible to find.
> >
> 
> I will change . = ALIGN(32); to STRUCT_ALIGN();
> 
> from vmlinux.lds.h:
> /*
>  * Align to a 32 byte boundary equal to the
>  * alignment gcc 4.5 uses for a struct
>  */
> #define STRUCT_ALIGN() . = ALIGN(32)

I also think this is the wrong place to do this.  scripts/dtc is a
mirror of copy of upstream dtc, designed for making dtb images for
general purposes.  I think the alignment should instead go into the
linker script fragments you generate to incbin the dtbs.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson


More information about the devicetree-discuss mailing list