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

Joakim Tjernlund joakim.tjernlund at transmode.se
Wed Sep 23 14:30:39 CEST 2009


Peter Tyser <ptyser at xes-inc.com> wrote on 23/09/2009 14:17:51:
>
> On Wed, 2009-09-23 at 13:51 +0200, Joakim Tjernlund wrote:
> > NULL is an absolute value and should not be relocated.
> > After this correction code like:
> >  void weak_fun(void) __attribute__((weak));
> >  printf("weak_fun:%p\n", weak_fun);
> > will still print null after relocation.
> >
> > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
> > ---
> >
> > I have only tested this on 83xx and on a somewhat older u-boot.
> > The change is exactly the same on all PowerPC platforms though.
>
> Hi Jocke,
> I made the same changes recently, but ran into an "issue" that prevented
> me from sending the change upstream.  Some boards/arches have the bss at
> address 0 and later relocate it, unlike every other NULL pointer.  If
> you don't fix up the bss address, the board will not function.   If you
> run readelf on an 83xx u-boot image vs a 85xx u-boot image it should be
> more clear what's going on.  I was doing my testing on the XPedite5370
> fwiw.

Ouch, the horror continues :(

>
> In any case, the change as is would break some other arches.  Seems like
> the proper workaround would be to "fix" the 85xx (and other arches) link
> script to locate the bss similar to the 83xx boards.

Yes, something should be done. Does it work for you with a "fixed" linker script?

>
> It might be nice to consolidate all the ppc relocate code into 1
> function while we were at it.

Played around a little and this is what I got sofar, possibly
WS damged and fixups untested:



More information about the U-Boot mailing list