[U-Boot] ARM relocation, question to Heiko

Albert ARIBAUD
2010-10-04T09:10:06Z

Le 04/10/2010 10:52, Joakim Tjernlund a ?crit :
> Albert ARIBAUD<albert.aribaud@free.fr> wrote on 2010/10/04 10:33:05:
>>
>> Le 04/10/2010 10:28, Joakim Tjernlund a ?crit :
>>>>
>>>> Le 04/10/2010 09:36, Joakim Tjernlund a ?crit :
>>>>
>>>>> However, I think we will loose the possibility to add "link once, burn and
>>>> run anywhere"
>>>>> feature I impl. once(but it was at the time deemed to intrusive) if
>>>>> we skip -fPIC and go for the linker -pie relocation.
>>>>
>>>> On ARM at least, I don't think so. From what I see, the -pie ld option
>>>> without the -fPIC/-fPIE compiler option alone builds a .rel.syn table
>>>> that contains all necessary fixes to mve the code anywhere.
>>>
>>> hmm, maybe my memory fails me but doesn't these relocs change the
>>> code to relocate accesses? While in flash you can't do that.
>>> Perhaps this is fixable too with the LINK_OFF method I impl.
>>> but memory fails me as it was quite some time ago.
>>>
>>> Jocke
>>
>> Actually the principle is to link with TEXT_BASE equal to the NOR FLASH
>> location of the image [1] so that relocation is not needed there. Only
>> when you move the code to RAM do you need relocation.
>
> 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 am ultimately looking for same here on ARM.

Note however that linking for base address 0 is not mandatory for
achieving true position independence. What is required is that the code
which runs from power-up until relocation be able to run anywhere, i.e.,
this code should not require any relocation fixup. That can be achieved
on ARM by using only relative branches and accessing data only relative
to pc (e.g. literals) or truly absolute (e.g. HW registers etc).

Amicalement,
--
Albert.