[U-Boot] armv8 relocation questions

Jeroen Hofstee dasuboot at myspectrum.nl
Sun May 18 14:37:45 CEST 2014


Hello Wolfgang,

On za, 2014-05-17 at 18:53 +0200, Wolfgang Denk wrote:
> Dear fenghua,
> 
> In message <B9A956AA-4ED7-488D-B496-90111AA45A5A at phytium.com.cn> you wrote:
> > 
> > 
> > We can not make gcc-aarch64 do not use adrp instruction when
> > constructing address of label.
> > 
> > So, I think the 4kb alignment would be a requirement or restriction.
> > Gcc did not declare it explicitly
> > due to in normal world memory are allocated with page aligned.
> > If u-boot for aarch64 want to be compiled at address not 4kb aligned
> > the relocated address
> > should also be shifted with the same offset.
> 
> Sorry, I don't understand anything here.  At which exact place is
> there any such 4 k alignment restriction?  When we relocate U-Boot, we
> just process a list of addresses.  Even if the start of the image is
> aligned to a 4 k boundary, there are a zillion of other addresses that
> are not, and these can be relocated just fine.
> 

The following document [1] mentions:

"ADRP Xd, label
Address of Page: sign extends a 21-bit offset, shifts it left by 12 and
adds it to the value of the PC with its bottom 12 bits cleared, writing
the result to register Xd. This computes the base address of the 4KiB
aligned memory region containing label, and is designed to be used in
conjunction with a load, store or ADD instruction which supplies the
bottom 12 bits of the label’s address. This permits position-
independent addressing of any location within ±4GiB of the PC using two
instructions, providing that dynamic relocation is done with a minimum
granularity of 4KiB (i.e. the bottom 12 bits of the label’s address are
unaffected by the relocation). The term “page” is short-hand for the
4KiB relocation granule, and is not necessarily related to the virtual
memory page size."

And apparently gcc choose to use it as such. Since the instructions in
question are relative to the most significant bits of the pc it does not
need fixups, so it is not included in the "list of addresses" you
mention. The compiler does create the 4k requirement though by using the
instruction the way it does.

Regards,
Jeroen

[1]
http://www.element14.com/community/servlet/JiveServlet/previewBody/41836-102-1-229511/ARM.Reference_Manual.pdf



More information about the U-Boot mailing list