Bug in example .glink resolver stub
#85
Closed
opened 7 years ago by wschmidt-ibm
·
0 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
On Wed, Apr 25, 2018 at 09:55:11PM +0000, Sean Fertile wrote:
Yes, that's a bit silly.
Looks good to me.
For reference, what the linker actually generates for the resolver on
powerpc64le is:
__glink_PLTresolve:
mflr r0
bcl 20,4*cr7+so,10000960 <__glink_PLTresolve+0x8>
mflr r11
std r2,24(r1)
ld r2,-16(r11)
mtlr r0
subf r12,r11,r12
add r11,r2,r11
addi r0,r12,-48
ld r12,0(r11)
rldicl r0,r0,62,2
mtctr r12
ld r11,8(r11)
bctr
Which is the same as your recommended update to the ABI with
a) using r2 to load PLToffset
b) saving r2 for localentry:0 function calls
c) insn reordering
a) was done just because you can use r2..
b) is necessary because when the --plt-localentry linker optimization
is enabled, ld generates plt call stubs for localentry:0 functions
that don't save r2, and there's no toc restore insn. That works
for calls that go directly via the plt, but not when you need to go
via the resolver for lazy plt resolution. So the resolver stub
saves r2 and r2 is restored by ld.so.
c) was done in a probably vain attempt to do a little better insn
scheduling.
--
Alan Modra
Australia Development Lab, IBM