[U-Boot] [PATCH] mpc83xx: Add -fpic relocation support

Joakim Tjernlund joakim.tjernlund at transmode.se
Wed Oct 13 10:37:27 CEST 2010


> 
>   On 10/12/2010 11:30 PM, Albert ARIBAUD wrote:
> > Le 12/10/2010 23:00, Joakim Tjernlund a écrit :
> >
> >> Yes, but the difference isn't really the arch. It is the 
-mrelocatable
> >> flag that is the big difference.
> > Not only: obviously, implementing GOT relocation is not done the same 
on
> > both archs, and it simply is not beneficial on ARM wrt PPC in terms of
> > instructions. I did a pretty extensive run of tests with and without
> > -fPIC and -fPIE on ARM, and GOT relocation clearly makes code bigger,
> > whereas it does not PPC.
> >
> > This simply implies that -fPIC is a better choice for PPC (and hence
> > -mrelocatable) while -fpie is a better one for ARM.
> Hi All,
>       In particular, the PPC takes two 32 bit instructions to load the 
> known address of a variable into a register. If the GOT is used, a 
> single 32 bit instruction can load the address of a variable from the 
> GOT table (pointed to by a "fixed" register) into a register. In both 
> cases, there are two memory cycles, but in the GOT case, only one 
> instruction is required. This is why the GOT based code is smaller. 
> However, the GOT cannot be used to address constants and some other 
> items that are not "variables". I do think that -fPIC and -fpie are not 
> mutually incompatible. On the PPC, the GOT references would be relocated 

> in the loop that updates the GOT and the references to constants would 
> be relocated by the ELF relocation code. That is how shared libraries 
> are relocated.

hmm, what constants and why would you relocate these?

Curious, what other data that are not "variables" are
you thinking about? Could such data be present in
u-boot too? Possibly the fixup's(initialized static ptrs)?
Relocs for these are emitted with -mrelocatable for ppc and
u-boot has a small routine to relocate these too.

      Jocke



More information about the U-Boot mailing list