This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: new ppc32 GOT/PLT support
On Thu, May 19, 2005 at 11:37:14PM -0700, Richard Henderson wrote:
> On Wed, May 18, 2005 at 12:03:53AM +0930, Alan Modra wrote:
> > /* Get address of the 'b _DYNAMIC@local'... */
> > + asm ("bcl 20,31,0f;"
> > "b _DYNAMIC@local;"
> > "0:"
> > + : "=l" (branchaddr));
> >
> > /* So now work out the difference between where the branch actually points,
> > and the offset of that location in memory from the start of the file. */
> > + runtime_dynamic = ((Elf32_Addr) branchaddr
> > + + ((Elf32_Sword) (*branchaddr << 6 & 0xffffff00) >> 6));
>
> This is simply
>
> asm ("bcl 20,31,0f\n"
> "0: mflr %0\n"
> " addis %0,%0,_DYNAMIC-0b@ha\n"
> " addi %0,%0,_DYNAMIC-0b@l"
> : "=b"(runtime_dynamic) : : "lr");
Only if you have R_PPC_REL16 relocs. I didn't think it worth optimizing
this code for HAVE_ASM_PPC_REL16.
> > +# ifdef HAVE_ASM_PPC_REL16
> > + bcl 20,31,1f
> > +1: mflr r7
> > + addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha
> > + addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l
> > +# else
> > bl _GLOBAL_OFFSET_TABLE_@local-4
> > mflr r7
> > +# endif
>
> All this ifdefery is so common, perhaps a sysdep.h macro is in order...
That might make sense for cases where we simply load the GOT pointer
into a reg, but there aren't that many of them. In some places, I do
a little scheduling, in others I combine the low order addition with
a memory load. Besides, when hacking optimized assembly I like to see
exactly what I'm getting.
--
Alan Modra
IBM OzLabs - Linux Technology Centre