Gabriel Paubert <paub...@iram.es> wrote on 2010/10/06 10:15:26:
>
> On Tue, Oct 05, 2010 at 10:55:36PM +0200, Joakim Tjernlund wrote:
> > Richard Henderson <r...@redhat.com> wrote on 2010/10/05 20:56:55:
> > >
> > > On 10/05/2010 06:54 AM, Joakim Tjernlund wrote:
> > > > Ian Lance Taylor <i...@google.com> wrote on 2010/10/05 15:47:38:
> > > >> Joakim Tjernlund <joakim.tjernl...@transmode.se> writes:

> > You can get at the GOT table using PC relative addressing so why not
> > strings or data in a similar fashion?
>
> Because you access the got with a single (16 bit offset) instructions.
> If you add .rodata, .data and .bss, you will likely overflow it
> quite rapidly.
>
> Did you look at -mrelocatable?

Yes, u-boot currently uses -mrelocatable.

>
> I don't know whether it can solve all your problems (probably not),
> and there are regular threats of removing it, or at least there
> were, since I see that the documentation was much improved in August.

I really wish mrelocatable is added to all archs. The normal ELF relocs
are too big to fit well in u-boot.

>
> Anyway, I used it a decade ago to write a bootloader that:
>
> a) was loaded at an unpredictable and unconfigurable address
> depending on the mood of the firmware (really, it depended at
> least on the media from which you booted, even exactly the
> same binary image)

That is pretty much what I am trying to do.

>
> b) the first thing the bootloader did was to run the relocation code
> for the adress at which it had been loaded by the firmware and
> find the free memory areas from tables provided by the firmware.
> The code in this part could not use any global pointer variable,
> AFAIR, but it was short.

Right, but here u-boot is still in flash and cannot write/relocate
the GOT. Later, when RAM is setup, it moves to RAM and
relocates the GOT.

I have managed to do this but this required each access to
global data(including string literals) to be wrapped by a LINK_OFF(ptr)
function that calculated the offset between link and run address and
adjusted the ptr accordinly. This is unmaintainable though so the patch
wasn't accepted by u-boot.

 Jocke

Reply via email to