[U-Boot] [PATCH v5] Fix board init code to respect the C runtime environment

Albert ARIBAUD albert.u.boot at aribaud.net
Tue Nov 17 14:39:12 CET 2015


... and of course, I forgot to add a note at '(*)' re the malloc arena
size alignment...

On Tue, 17 Nov 2015 13:59:32 +0100, Albert ARIBAUD
<albert.u.boot at aribaud.net> wrote:

> Hello Simon,
> Indeed, no attempt is made to check that it is aligned (and no attempt
> is made in the original code either) -- all the more since there is no
> strict definition of what it should be aligned to. There is, actually,
> no indication that it should be aligned, although it will probably only
> be used up until the last full 4-byte-word (or 8-byte word for 64-bit
> architectures). In fact, the alignment of CONFIG_SYS_MALLOC_F_LEN does
> not matter much, see (*) below.

> (*)

And, in fact, there is not real need for CONFIG_SYS_MALLOC_F_LEN to be
aligned, whether is is reserved above or below GD.

If the malloc arena is reserved above GD (my preferred scenario, as
explained elsewhere), then what counts is aligning its *base*, not
*size*, in the probable case that it should support word accesses and
some architecture may require word alignment.

If the malloc arena is reserved below GD, then what counts is aligning
*GD's base*, not the malloc arena's size.

(that's a general principle, BTW: each 'chunk' allocation should decrease
the current top address by the chunk size requested then round it further
down by the alignment constraint applicable to that chunk. The chunk size
does not matter much.)

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list