[U-Boot] [PATCH v4 3/4] generic board patch of manual reloc and zero gd_t
Scott Wood
scottwood at freescale.com
Tue Oct 1 03:43:46 CEST 2013
On Mon, 2013-09-09 at 20:54 -0500, Scott Wood wrote:
> It seems the problem is that when rela is used, the linker *only* puts
> the symbol in the rela struct. The value in the data section itself is
> zero, which means we can't run without relocation even if the address
> hasn't changed.
>
> Unless there's some way to change this linker behavior, the options I
> can think of are:
>
> 1. Write a utility to apply the relocations (for the pre-relocation
> address) at build time, or
>
> 2. Use SPL. The SPL itself would not use -pie and would not relocate.
> The main U-Boot would know that it has been loaded into RAM, and apply
> relocations prior to entering C code. Interactions with SPL being used
> for other purposes could be awkward.
>
> Any preferences, or other suggestions? I think either of these options
> is preferable to CONFIG_NEEDS_MANUAL_RELOC. I'm inclined toward option
> #1 as it avoids interactions with other SPL uses and in general doesn't
> change the runtime flow.
#1 is easier to do on the u-boot.bin rather than on the ELF file[1], but
apparently that doesn't do us any good with the model because it wants
an ELF file. Shouldn't the model be applying the relocations if it's an
ELF loader? Is there any way to get the foundation model to load a raw
binary? I tried --data and --nsdata at 0x80000000 (alone or in
combination with --image) and wasn't able to do a write to the LEDs
immediately after reset (which works when I load it as ELF).
It works when I convert the binary back into an ELF using objcopy and
ld, but it would be nice to avoid that...
-Scott
[1] I tried using libelf -- it made getting the relocations easy, but it
wasn't obvious how to go about poking the actual image data by address
(or even by segment), rather than by section. Other than use libelf to
read out the translated relas and phdrs, then close the libelf handle
and do the rest manually. :-P
More information about the U-Boot
mailing list