ifunc function

IFUNC

What is IFUNC?

With the aid of a resolver function that was also written by the developer, numerous implementations of a particular function can be created using the GNU indirect function support (IFUNC) feature of the GNU toolchain. During early startup, the dynamic loader calls the resolver function to determine which implementation the application will use. Once a decision on implementation is made, it cannot be modified for the duration of the procedure.

How to use it?

As you can see, there are already a few limitations on how IFUNC can be used.                                                 It is the implementations and the resolver must both be defined in the same translation unit. functions that cannot be weakly specified.   

Since the resolution of an IFUNC might occur very early in the dynamic loader startup process, especially if -Wl,z,now is used to generate the application, the limitations are actually stricter than this (requires all symbols be resolved before application startup).

  • The R * IRELATIVE relocations occur in DT JMPREL after the DT REL* relocations, which may make this work on x86 64, but there is no assurance that it will work on AArch64, PPC64, or other somewhat different architectures. Such fundamental restrictions might be lifted in the future.
  • The resolver must not be built with -fstack-protector-all or any other similar safeguards, such as asan, as they might call for an early setup that hasn't yet finished.




Comments

Popular posts from this blog

Lab2 - 6502 Assembly Language Lab(Calculation)

Lab1 - 2 Open Sources Packages