PATCH: Add ifunc attribute

Paolo Bonzini bonzini@gnu.org
Wed Jun 24 14:08:00 GMT 2009


Richard Guenther wrote:
> On Tue, Jun 23, 2009 at 7:19 PM, H.J. Lu<hjl.tools@gmail.com> wrote:
>> Hi,
>>
>> I opened a bug report:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40528
>>
>> with the third proposal:
>>
>> 3. Ifunc attribute with prototype, but without argument:
>>
>> int
>> __attribute__ ((ifunc))
>> foo (...)
>> {
>>  <return address of foo_{1,2,3}>
>> }
>>
>> We can call foo in the same file. Gcc checks the return value for
>> foo.
>>
>> Any comments?
> 
> I don't understand this third proposal.

"int foo (...)" is only declared as a prototype and with the ifunc 
attribute dropped.  The body of the function is actually compiled to 
.ifunc.foo or something like that, with a signature

__typeof(foo) __attribute__ ((ifunc)) .ifunc.foo(void)

and with ".gnu.indirect.function .ifunc.foo" emitted in the assembly 
instead of ".function".

Via some magic mechanism, a further redeclaration of foo is prohibited.

Looks a bit too like DWIM and too little like a specification.  I think 
I prefer option 1, in some cases you may want to call the trampoline and 
having it accessible can help.  With

__typeof (foo) *
__attribute__ ((ifunc ("foo")))
foo_ifunc (void)
{
   <return address of foo_{1,2,3}>
}

you could call foo_ifunc if you wish in principle, and the header file 
only has the prototype of foo as expected.

Paolo



More information about the Libc-alpha mailing list