[U-Boot] armv8 relocation questions

Wolfgang Denk wd at denx.de
Mon May 26 16:38:14 CEST 2014


Dear David,

In message <CBDD3537-16F3-41C8-9929-6C30F56C36DF at phytium.com.cn> you wrote:
> 
>      I am will glad to share my understanding.

Thanks.

> > I wonder how "adrp" would work in any code that is supposed to be
> > position-independent?
> In my understanding, with adrp the program is still relocatable except that
> the text base should be 4KB aligned or the relocated address has the same
> offset with text base. Darwin want CONFIG_SYS_TEXT_BASE to be not 4KB aligned, so the
> relocated address should be offsetted in the same manner.

We should be careful here to use precise terms.  CONFIG_SYS_TEXT_BASE
is just the start address of the text segment, and if I understand
correctly, it is NOT required that this is in any way aligned to a
4 KB boundary - we have to keep in mind here that the start of the
text segment is not the same as the start address of the code; it can
be the same, but often it is not - often other blocks of date preceed
the actual program code (things like HRCW [hard reset configuration
word], or strings with ID information etc., exception vector tables
and/or code, etc.).

> Position-independent code is usually page aligned, so gcc-aarch64 implicitly apply
> the restriction of text base.
>
> Actually, u-boot for aarch64 apply another align requirement that 
> is interrupt vector. The interrupt vector should be 2KB aligned. 
> So, even without adrp CONFIG_SYS_TEXT_BASE should be 2KB aligned yet
> or relocated with the same offset, otherwise bug exist.

CONFIG_SYS_TEXT_BASE is just one number here, and it cannot be
considered alone.  We must also include into our considerations the
linker script, because this is where actually alignments are enforced.

I think we do not need to add specific code to deal with these
alignment requireents.  It should be sufficient to implement these in
the aarch64 linker script.  This also applies for the alignment of the
exception vector table.

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
You don't have to stay up nights to succeed; you have to  stay  awake
days.


More information about the U-Boot mailing list