Michael Meissner <meiss...@linux.vnet.ibm.com> wrote on 2010/10/07 15:00:25:
>
> On Tue, Oct 05, 2010 at 11:56:55AM -0700, Richard Henderson wrote:
> > 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:
> > >>> While doing relocation work on u-boot I often whish for strings/const 
> > >>> data
> > >>> to be accessible through %pc relative address rather than and ABS 
> > >>> address
> > >>> or through GOT. Has this feature ever been considered by gcc?
> > >>
> > >> The feature can only be supported on processors which are reasonably
> > >> able to support it.  So, what target are you asking about?
> > >
> > > In my case PowerPC but I think most arch's would want this feature.
> > > Is there arch's where this cannot be support at all or just within
> > > some limits? I think within limits could work for small apps
> > > like u-boot.
> >
> > PowerPC doesn't really have the relocations for pc-relative offsets
> > within code -- primarily because it doesn't have pc-relative insns
> > to match.  Nor, unfortunately, does it have got-relative relocations,
> > like some other targets.  These are normally how we get around not
> > having pc-relative relocations and avoiding tables in memory.  C.f.
>
> The new PowerPC medium code model for 64-bit now uses GOT-relative relocations
> for local data: The compiler issues (r2 has the TOC/GOT pointer):
>
>    addis <reg>,r2,la...@toc@ha
>    addi <reg2>,<reg>,la...@toc@l
>
> to load the address in <reg2>.  If the data happens to be within 32K of the 
> TOC
> pointer, the linker will transform this to:
>
>    nop
>    addi <reg2>,r2,la...@toc@l
>
> For non-local loads or the large code model, the compiler issues:
>
>    addis <reg>,r2,la...@got@ha
>    ld <reg2>,la...@got@l(<reg>)
>
> If the address happens to be defined in the current program unit (main program
> or shared librar), the linker can transform this to:
>
>    addis <reg>,r2,la...@toc@ha
>    addi <reg2>,<reg>,la...@toc@l
>
> or:
>
>    nop
>    addi <reg2>,r2,la...@toc@l
>
> or:
>
>    nop
>    ld <reg2>,la...@got@l(r2)

Why not offer some of this on PowerPC32? mcmodel=small would probably be enough.

     Jocke

Reply via email to