This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: PATCH: Add ifunc attribute


On Fri, Jun 12, 2009 at 8:59 AM, Richard
Guenther<richard.guenther@gmail.com> wrote:
> On Fri, Jun 12, 2009 at 5:40 PM, H.J. Lu<hongjiu.lu@intel.com> wrote:
>> Hi,
>>
>> This patch adds ifunc attribute for STT_GNU_IFUNC as specified in
>> ifunc.txt at
>>
>> http://groups.google.com/group/generic-abi/files
>>
>> Any comments?
>
> Why does the attribute have an argument? ?I see that you get around

It is used to indicate which function this indirect function is
used for, like

---
static int
zero (int x)
{
  return 0;
}

void *
__attribute__ ((ifunc ("foo")))
foo_ifunc (void)
{
  return zero;
}

extern int foo (int);

int
bar (int x)
{
  return foo (x);
}
---

bar calls foo.  Since we mark foo_ifunc as the indirect function
for foo, bar will call *foo_ifunc () at run-time.


> all the issues of wrong optimizations when seeing the function body,
> but at least the documentation needs to be more explicit about
> this subtle difference.
>

How about this

`ifunc ("FUNCTION")'
     The `ifunc' attribute only applies to global function definition,
     which causes the definition to be emitted as an indirect function.
     For instance,

          void* f_ifunc () __attribute__ ((ifunc ("f")));

     defines `f_ifunc' to be an indirect function for `f'.  The
     indirect function `f_ifunc', which is used by static linker and
     dynamic linker, is never called directly in the program.  This
     attribute is ignored if `f_ifunc' is undefined in the same
     translation unit.

     See `STT_GNU_IFUNC' specified in `ifunc.txt' at
     `http://groups.google.com/group/generic-abi/files' for details.

     Not all target machines support this attribute.


-- 
H.J.


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