This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Name of indirect function evaluating to a hidden function?



Hi

Is there a way to get the name of an indirect function (STT_GNU_IFUNC) which evaluates to a hidden function?

For example, the indirect function sin in libm resolves to __sin_avx on my system. __sin_avx is not exported and not found by calls to dladdr.

Is it possible to refer to the original indirect function sin, the one with the __attribute__ ifunc||, without resolving into __sin_avx?

See example code below.

Thanks


Hans Berghäll


/*
    compiled with g++-5 -fPIC -ldl
*/

#include <cmath>
#include <dlfcn.h>
#include <iostream>

char const * name (void * arg)
{
    void * h = dlopen (NULL, RTLD_LAZY);

    if (h)
    {
        Dl_info res;
        int status = dladdr (arg, & res);
        dlclose (h);

        if (status && res.dli_sname && arg == res.dli_saddr)
            return res.dli_sname;
    }

    return "";
}

int main ()
{
std::cout << fabs (0.0) << " " << name ((void *) fabs) << std::endl; // found std::cout << sin (0.0) << " " << name ((void *) sin ) << std::endl; // not found
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]