[llvm-dev] resolve the name of an ifunc resolver function

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 10 15:56:00 PDT 2020


You could call "getValueID" on that Constant to figure out what kind it is.

Also printing it (or calling "dump()") in a debugger might be helpful.

On Mon, Aug 10, 2020 at 3:30 PM Marc via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi,
>
> I just spent 4 hours trying to find a way to get the name of the
> resolver function of a ifunc definition ... :-(
>
> and with all that time I didnt event get far:
>
> for (GlobalIFunc &IF : M.ifuncs()) {
>   StringRef ifunc_name = IF.getName();
>   Constant *r = IF.getResolver();
>
> But how do I get to the (Function*) or function name of the resolver
> from there? I tried everything with the Constant which seems to be a
> ConstantExpr type ... ....
>
> Example test program below:
>
> #include <stdio.h>
>
> int foo(void) __attribute__((ifunc("foo_resolve")));
>
> static int global = 1;
>
> static int foo1(void) { return 0; }
>
> static int foo2(void) { return 1; }
>
> void *foo_resolve(void) { return global == 1 ? foo1 : foo2; }
>
> int main() { printf("%d\n", foo()); }
>
> Thank you!
>
> Regards,
> Marc
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list