glibc ifunc

Florian Weimer fw@deneb.enyo.de
Tue Feb 25 07:21:20 GMT 2025


* 赵爱南:

> I'm a glibc developer, now our arch wants to implement the
> ifunc. Where can I find the introduction document for glibc ifunc,
> thanks.Best wish to you.

What kind of documentation are you looking for?

On the glibc side, implementing IFUNC support requires adding a code
path to elf_machine_rela (or elf_machine_rel) in dl-machine.h,
typically something like this:

  if (sym != NULL
      && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
      && __glibc_likely (sym->st_shndx != SHN_UNDEF)
      && __glibc_likely (!skip_ifunc))
    value = elf_ifunc_invoke (value);

And elf_ifunc_invoke casts the value argument to the appropriate
function pointer type and calls it with the required arguments.


More information about the Libc-alpha mailing list