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

Marc via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 10 15:30:07 PDT 2020


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


More information about the llvm-dev mailing list