[U-Boot] [PATCH] relocation: Do not relocate NULL pointers.

Joakim Tjernlund joakim.tjernlund at transmode.se
Sun Sep 27 18:18:29 CEST 2009


Graeme Russ <graeme.russ at gmail.com> wrote on 27/09/2009 15:52:38:
>
> On Sun, Sep 27, 2009 at 11:15 PM, Joakim Tjernlund
> <joakim.tjernlund at transmode.se> wrote:
> > Wolfgang Denk <wd at denx.de> wrote on 23/09/2009 20:23:14:
> >>
> >> Dear Peter Tyser,
> >>
> >> In message <1253710639.3968.19.camel at ptyser-laptop> you wrote:
> >> >
>
> >>
> >> > Nice!  It'd be great to have the magical 20 lines of assembly put into
> >> > some semi-understandable c.
> >>
> >> :-)
> >
> > I have worked some more on this but all boards need to be converted to use
> > the new C-variants.
> >
> > Anyhow, I have also been thinking/working on making U-boot
> > fully PIC and reached a important conclusion. The GOT holds absolute
> > ptr values and there is not much one can do about it sans modifying gcc.
> > So before u-boot is relocated to RAM one must manually add any offset to
> > all global/static data and string literals. The majority of strings
> > are passed directly to printf and friends so the offset can be added inside
> > printf. The remaining few data accesses needs to be dealt with directly, example:
> > -       for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
> > +       for (init_fnc_ptr = got_off(init_sequence); *init_fnc_ptr; ++init_fnc_ptr) {
> >
> > Only code called before relocation to RAM needs this, mostly the _f() functions.
> > Would this be an acceptable change?
> >
>
> I think you might want to look at the x86 relocation work I have just
> submitted for comment. It processes all relocation sections generated by
> gcc/ld using the ELF data structures defined in elf.h - I generate code at
> a text base equal to the boot flash (0x38004000) so I can easily check if
> the relocation entry is with the executable. After the elf relocation
> processing, there is ZERO need for any offset compensation once I've jumped
> into the relocated code
>
> And its all in C ;)

hmm, I don't know x86 that well, but I did look at your
  [RFC][PATCH 8/8] Final i386 Relocation
and I don't understand it fully. To make sure, is it possible for you
to link at address X and run from address Y directly from flash?

   Jocke



More information about the U-Boot mailing list