This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: powerpc STT_GNU_IFUNC support, 2 of 2

On Fri, Jul 31, 2009 at 11:25:48AM -0700, Richard Henderson wrote:
> On 07/30/2009 04:56 PM, Alan Modra wrote:
>> PowerPC64 would need 64-bit offsets.
> Really?  Even Linux relocates the text and data of a ppc64 DSO  
> separately?  I thought that was just AIX.

Yes really.  Separate text and data isn't the problem.

> That said, for ppc32 text+data, or ppc64 data only,
> static int x;
> int f(void) { return ++x; }
> with -m32 -fpic, the interesting bits are
>         lwz 9,.LANCHOR0@got(30)
>         lwz 3,0(9)
>         addi 3,3,1
>         stw 3,0(9)
> which could just as well be
>         addis 9,x@gotoffha(30)
>         lwz 3,x@gotofflo(9)
> 	addi 3,3,1
>         stw 3,x@gotofflo(9)

This would be good for ppc32 static variables, and other accesses
known to be local.  No GOT entry needed at all.  The problem with
ppc64 is simply that "x" may well be more than 2G away from the GOT
pointer.  We'd need to implement memory model flags to allow the
compiler to assume that data is less than 2G in size (or make -fpic
assume so, -fPIC not).  The general code to implement gotoff on ppc64
for your example function, using ELF syntax rather than the PowerOpen
scheme that ppc64 gcc uses, is:

	addis 9,x@gotoff@highesta(2)
	ori 9,x@gotoff@highera(9)
	sldi 9,9,32
	oris 9,x@gotoff@ha(9)
	lwz 3,x@gotoff@l(9)
	addi 3,3,1
	stw 3,x@gotoff@l(9)
	ld 9,x@got(2)
	lwz 3,0(9)
	addi 3,3,1
	stw 3,0(9)

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]