This is the mail archive of the libc-alpha@sourceware.org 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 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.


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)

to avoid the got relocation.

I realize that there's the potential for a small amount of code size expansion (n+1 words for got vs 2n words for gotoff maximum, depending on exact code usage), but using immediate constants avoids worst-case cache effects and the two insn sequence addis+addi has an execution speed that probably matches that of a load from cache (again, worst case, assuming the low part can't be subsumed in a memory insn and the high part can't be scheduled early).


r~



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