[U-Boot] ARM relocation, question to Heiko
Joakim Tjernlund
joakim.tjernlund at transmode.se
Mon Oct 4 20:43:16 CEST 2010
"J. William Campbell" <jwilliamcampbell at comcast.net> wrote on 2010/10/04 19:59:47:
> On 10/4/2010 10:06 AM, Wolfgang Denk wrote:
> Dear "J. William Campbell",
>
> In message <4CA9F294.8080007 at comcast.net> you wrote:
>
> Yes, I think Wolfgang is correct. This is not going to be easy to do in
> general. To run anywhere, the code must be true Position Independent
> code. If you intend to use any C code in the initialization, this will
> result in needing -fPIC for at least that code. I am not sure you can
> mix -fPIC and non -fPIC code in the same link, but I expect not. I am a
> bit surprised that it is possible to get even the initialization code to
> be Position Independent, but it appears that on at least some PPC it is
> possible/has been done.
>
> Not really. On PowerPC, only the first 20 or 30 lines of assembler
> code in start.S are position independent; then we compute the link
> (resp. execution) address and branch to it. From then, we run from the
> very address range we were linked for (starting at TEXT_BASE).
> Hi Wolfgang,
> You are of course correct. I was referring more to Jocke's (
> joakim.tjernlund at transmode.se) statements regarding:
> Yes, that is there today. I am talking about linking to any TEXT_BASE(say 0)
> but burn and run into another address. I impl. this quite some time
> ago for PPC(search for LINK_OFF)
>
> I understand from his comment that he had achieved total PIC for the
> initialization, that would run at any location regardless
> of TEXT_BASE. I think this code was not accepted into mainline, so it is not a
> problem at present. However, any relocation code
> added would have to be modified by Jocke if he wished to preserve that
> capability. I am amazed that he was able to get the
> rest of u-boot to work under the constraints you pointed out. It must have
> been quite tedious.
:), actually it wasn't that bad. Wolfgang nearly accepted the code even :)
Mainly, I had to wrap code that accessed global data with a LINK_OFF() function
that calculated the offset and only in code that executed before relocation.
And fix a few things in start.S to be PIC.
Jocke
More information about the U-Boot
mailing list