This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: sibcall vs PIC
On Sep 5, 2002, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Sep 06, 2002 at 08:38:14AM +1000, Fergus Henderson wrote:
>> Currently on x86 GCC does not do any sibling call optimization with -fpic.
>> The source contains the following comment:
>>
>> "If PIC, we cannot make sibling calls to global
>> functions because the PLT requires %ebx live."
>>
>> Could anyone elaborate on this comment?
>> Why exactly does this prevents sibling calls?
> Now for sibcall you'd need to restore %ebx to X before jumping
> to baz PLT slot in libbar.so (or don't set %ebx at all), but IA-32 PLT
> slot expect %ebx to contain GOT address of the DSO they are in,
> so you'd call libbar.so's baz PLT slot with incorrect %ebx and die.
So why not load the address of the sibcalled function from the GOT and
skip the PLT entry entirely? Isn't the sibcall optimization worth the
load-time relocation cost in general?
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer