This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Name of indirect function evaluating to a hidden function?
- From: listcrawler <listcrawler at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Mon, 9 Jan 2017 14:31:33 +0100
- Subject: Name of indirect function evaluating to a hidden function?
- Authentication-results: sourceware.org; auth=none
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
}