This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: rs6000 sibcall test


Hi Fergus,

On Fri, Sep 06, 2002 at 11:00:44PM +1000, Fergus Henderson wrote:
> On 06-Sep-2002, Alan Modra <amodra@bigpond.net.au> wrote:
> > rs6000.c:function_ok_for_sibcall tests TREE_ASM_WRITTEN, like alpha.
> > I can't see why, at least for powerpc64-linux.  Can someone show me
> > why it matters?
> 
> Perhaps because of the same kind of issue that prevents sibcalls
> with -fpic on x86?  On rs6000 with the AIX ABI, all code is
> position-independent, so maybe there is the same issue.

No we don't have the problem pointed out by Jakub in
http://gcc.gnu.org/ml/gcc/2002-09/msg00210.html.  The TOC pointer,
which we use to access the plt, is restored by the caller.  Taking
Jakub's example, we'd have

in libfoo.so
.foo:
 create stack frame, and save link reg
.
.
 branch and link to bar call stub
 restore toc pointer
.
 rest of foo code
 restore link reg, pop stack frame
 branch to link reg

in libbar.so
.baz
 set return reg to 23
 branch to link reg

.bar
 branch to baz

The call stub, actually inserted by the linker, save the toc pointer
on the stack, set up the toc pointer for the called function, then
jump to the function entry point.

Oh, wait a minute.  That branch to baz is actually a branch to baz
call stub because we need to allow baz to be overridden.  Heh, that
will save the toc pointer again, overwriting the same stack frame
location used by foo.  So I've answered my own question.  Or at
least found out another linker requirement to make this work.  You
see, I think we can make the linker use a call stub that _doesn't_
save the toc register in this particular case.

> But that's for the AIX ABI.  Maybe it's not appropriate for Linux.

64 bit powerpc code on linux uses the AIX ABI.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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