This is the mail archive of the
mailing list for the GCC project.
Re: PATCH: Add ifunc attribute
On Sat, Jun 13, 2009 at 9:18 AM, Richard
> On Sat, Jun 13, 2009 at 6:07 PM, H.J. Lu<email@example.com> wrote:
>> On Sat, Jun 13, 2009 at 8:15 AM, Richard
>> Guenther<firstname.lastname@example.org> wrote:
>>>> I started to write my own version of the documentation, but I realized
>>>> that I don't even understand this. ?Which function is called by the
>>>> dynamic linker, "f" or "f_ifunc"? ?Why is the attribute ignored if
>>>> "f_ifunc" is not defined; shouldn't it be an error? ?I guess that means
>>>> that "f_ifunc" is called by the dynamic linker; in that case, what
>>>> happens if "func" is defined?
>>> Yeah. ?I would have proposed that
>>> void *foo (void) __attribute__((__ifunc__))
>>> ?return zero;
>>> would simply generate foo with indirect function type.
>>> This of course causes a problem if you have a declaration for
>>> the real foo available - but then you should better not have that,
>>> as the compiler will then derive wrong properties for the real foo
>>> from the ifunc wrapper body.
>> Glibc has ifunc testcases with a declaration of foo in the same file.
>> This proposal won't work with them.
> They would just need to be fixed then.
I don't think there are anything wrong with ifunc testcases in glibc.
void *foo (void) __attribute__((__ifunc__))
isn't a good idea since this isn't the real prototype for foo. It will lead
to many problems down the road. foo is usually declared in a header
file and you can't include such a header file in the implementations
of foo if 2 prototypes don't match.