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]

Re: Name of indirect function evaluating to a hidden function?


On Mon, Jan 9, 2017 at 5:31 AM, listcrawler <listcrawler@gmail.com> wrote:
>
>
> Hi
>
> Is there a way to get the name of an indirect function (STT_GNU_IFUNC) which evaluates to a hidden function?


http://stackoverflow.com/questions/41533519/how-to-get-name-of-gnu-indirect-function-using-dladdr

>
>
> 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?

Not without looking at the dynamic relocation at the call site, I think.

What are you *actually* trying to achieve?

>
> 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
> }
>



-- 
Paul Pluzhnikov


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