This relocation is similar to R_*_RELATIVE except that the value used in this relocation is the program address returned by the function, which takes no arguments, at the address of
the result of the corresponding R_*_RELATIVE relocation as specified in the processor-specific ABI. The purpose of this relocation to avoid name lookup for locally defined STT_GNU_IFUNC symbols at load-time.
More info can be found in ifunc.txt from https://sites.google.com/site/x32abi/documents.
Testing can be performed using following sample:
#include <stdio.h> int myfunc1() { return 1; } int myfunc2() { return 2; } // Prototype for the common entry point extern "C" int myfunc(); __asm__ (".type myfunc, @gnu_indirect_function"); // Make the dispatcher function. This returns a pointer to the desired function version typeof(myfunc) * myfunc_dispatch (void) __asm__ ("myfunc"); typeof(myfunc) * myfunc_dispatch (void) { if (0) return &myfunc1; else return &myfunc2; } int main() { printf("\nCalled function number %i\n", myfunc()); return 0; }
~/LLVM/build/bin/clang -fuse-ld=lld -O0 -g test.cpp -o test
./test
Depending on if() condition 1 or 2 should appear in output.