new ppc32 GOT/PLT support
Steve Munroe
sjmunroe@us.ibm.com
Tue Jun 7 22:26:00 GMT 2005
Alan Modra <amodra@bigpond.net.au> wrote on 05/17/2005 09:33:53 AM:
> ...One problem remains: ppc32 calls
> _mcount before the function prologue, so it's not possible to set up
> registers to call _mcount via the plt in pic code. So for now, if you
> profile pic code using a dynamic _mcount, the call sequence used will
> force the old exec GOT/PLT. I'm thinking the best thing is to make
> _mcount available in libc_nonshared, and only keep _mcount in libc.so
> to satisfy explicit versions, but I'm open to suggestions.
>
Looking at the details, gmon/mcount.c is aliased to __mcount_internal and
the exported _mcount symbol is defined by the stub in ppc-mcount.S.
ppc-mount.S; stacks a frame, saves the parameter register (r3-r10), setup
up the frompc and seflpc parameters in r3/r4, before calling
__mcount_internal.
Also gcc is still generating the -pg prologue as:
.data
.align 2
0: .long 0
.previous
mflr r0
lis r11,0b@ha
stw r0,4(r1)
addi r0,r11,0b@l
bl _mcount
The .data word and its address in r0 are neaver used (by mcount.c or any
other code that I can find). Also this is a non-PIC sequence that we
should elliminate for the new ABI.
One posibililty is to move the ppc-mcount.S stub code into libc_nonshared
and have it establish the got (using the new ABI). Then we could call
gmon/mcount.c version of _mcount via the new PLT. So we need two prologues
for the profiling case. One for the leaf routine case where the mcount
stub establishes its own got. And one for the none leave case where the bl
_local_mcount established the lr for the got sequence.
So the leaf case looks like:
func:
mflr r0
stw r0,4(r1)
bl _leaf_mcount
# we can assume that on return r0/lr are restored by _leaf_mcount
# to the entry value.
...
And the non-leaf case could look like:
func2:
mflr r0
stw r0,4(r1)
bl _local_mcount
1:
# we can assume that on return r0 are restored by _local_mcount
# to the lr on entry.
stwu r1,-32(r1)
stw r31,28(r1)
stw r30,24(r1)
mflr r30
stw r0,36(r1) # this is probably redundent
addis r30,r30,(got-1b)@ha
addi r30,r30,(got-1b)@l
This will require versioning the _mcount symbol for the new ABI.
Steven J. Munroe
Linux on Power Toolchain Architect
IBM Corporation, Linux Technology Center
More information about the Libc-alpha
mailing list