https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87482
Bug ID: 87482 Summary: Clarify behaviour of resolvers with parameters in for __attribute__((ifunc)) Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: peter.smith at linaro dot org Target Milestone: --- In the documentation for https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes it says: "The resolver should be declared to be a function taking no arguments and returning a pointer to a function of the same type as the implementation." I would like to check if the documentation is correct here as the implementation accepts a parameter and on some architectures, such as Arm and AArch64, the hwcaps is passed in to the resolver as a parameter by the dynamic loader? To me it looks like the documentation isn't quite right, but I could be missing something important. For example a quick modification of the example on the page: #include <stdlib.h> void *my_memcpy (void *dst, const void *src, size_t len) { return dst; } void *my_memcpy2 (void *dst, const void *src, size_t len) { return dst; } static void * (*resolve_memcpy (int hwcap))(void *, const void *, size_t) { if (hwcap == 1) return my_memcpy; else return my_memcpy2; } void *memcpy(void *, const void*, size_t) __attribute__((ifunc ("resolve_memcpy"))); Compiles without a problem. From what I can see glibc doesn't use __attribute__((ifunc("resolver"))) instead it uses __asm__ (".type " resolver, %gnu_indirect_function). For context clang will give an error message if the ifunc resolver has a parameter. ifunc2.c:20:58: error: ifunc resolver function must have no parameters void *memcpy(void *, const void*, size_t) __attribute__((ifunc ("resolve... There is a thread on cfe-dev asking if the GCC documentation is correct and to see if clang should be following the documentation or the implementation: http://lists.llvm.org/pipermail/cfe-dev/2018-September/059548.html There was a recent change for 8.0 that made "The resolver should be declared to be a function taking no arguments" more explicit. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81882