On Tue, Oct 05, 2010 at 11:40:11PM +0200, Joakim Tjernlund wrote: > yes, but this could be a new PIC mode that uses a new better > PIC mode for everything. Especially one that doesn't require each function > to calculate the GOT address in the function prologue(why is that so?)
The ppc32 ABI is old, much like x86. cf. x86 -O2 -fPIC (without hidden pragma). foo: call __i686.get_pc_thunk.cx addl $_GLOBAL_OFFSET_TABLE_, %ecx pushl %ebp movl %esp, %ebp popl %ebp movl y...@got(%ecx), %eax movl x...@got(%ecx), %edx movl (%eax), %eax addl (%edx), %eax ret [snip] __i686.get_pc_thunk.cx: movl (%esp), %ecx ret The new ppc64 -mcmodel=medium support does give you pic access to locals. -fPIC -O2 without hidden .LC0: .tc x[TC],x <-- compiler managed GOT entries .LC1: .tc y[TC],y [snip] .L.foo: addis 11,2,....@toc@ha addis 9,2,....@toc@ha ld 11,....@toc@l(11) ld 9,....@toc@l(9) lwz 3,0(11) lwz 0,0(9) add 3,3,0 extsw 3,3 blr -fPIC -O2 with hidden pragma .L.foo: addis 11,2,x...@toc@ha addis 9,2,y...@toc@ha lwz 3,x...@toc@l(11) <-- TOC/GOT pointer relative lwz 0,y...@toc@l(9) add 3,3,0 extsw 3,3 blr x...@toc is equivalent to @GOTOFF on other processors. -- Alan Modra Australia Development Lab, IBM