[U-Boot] [PATCH] arm: Allow u-boot to run from offset base address

Wolfgang Denk
2014-06-11T21:16:51Z

Dear Steve,

In message <5398A640.3050105@broadcom.com> you wrote:
>
> So if I add a "your_header.c" as above, then
>
> (1) I need to modify "arch/arm/cpu/armv8/u-boot.lds":
> . = 0x00000000;
>
> + . = ALIGN(8);
> + .your_hdr : {
> + KEEP(*(.your_hdr*));
> + }
> +
> . = ALIGN(8);
> .text :
> {

ALIGN(8) looks pretty much bogus to me?

Quoting the "ld" docs:

'ALIGN(ALIGN)'
'ALIGN(EXP,ALIGN)'
Return the location counter ('.') or arbitrary expression aligned
to the next ALIGN boundary. The single operand 'ALIGN' doesn't
change the value of the location counter--it just does arithmetic
on it. The two operand 'ALIGN' allows an arbitrary expression to
be aligned upwards ('ALIGN(ALIGN)' is equivalent to 'ALIGN(.,
ALIGN)').

Here is an example which aligns the output '.data' section to the
next '0x2000' byte boundary after the preceding section and sets a
variable within the section to the next '0x8000' boundary after the
input sections:
SECTIONS { ...
.data ALIGN(0x2000): {
*(.data)
variable = ALIGN(0x8000);
}
... }
The first use of 'ALIGN' in this example specifies the location of
a section because it is used as the optional ADDRESS attribute of a
section definition (*note Output Section Address::). The second
use of 'ALIGN' is used to defines the value of a symbol.

Are you sure you do not ant to hae an ALIGN(4096) there?

> (2) then (I believe) I need to modify the "Makefile" to define the start
> address of this new section:
> +LDFLAGS_u-boot += --section-start=".your_hdr"=CONFIG_YOUR_HEADER_ADDR

Why?

> (3) and (I believe) I need to modify the OBJCOPYFLAGS (somewhere) in
> order to include this new section in the u-boot.bin:
> +OBJCOPYFLAGS += -j .your_hdr

Why?

> And in the end, (I believe) I am just going to have a block (likely 4096
> bytes) prepended to the "original" u-boot.bin; which I can do today with
> no code changes at all....

Well, we don't chaneg any code here, right? Just the linker script.
It's this, or some other script. But the linker is the standard way
to create a linked image with the correct memory map, so this is the
right place...

> Remember that original design request was effectively a two line change:

Yes, indeed But a pretty much bogus one.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Wisdom is one of the few things that looks bigger the further away it
is. - Terry Pratchett, _Witches Abroad_