new ppc32 GOT/PLT support
Richard Henderson
rth@twiddle.net
Fri May 20 06:37:00 GMT 2005
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");
> +# 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...
r~
More information about the Libc-alpha
mailing list