This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Name of indirect function evaluating to a hidden function?
- From: Paul Pluzhnikov <ppluzhnikov at google dot com>
- To: listcrawler <listcrawler at gmail dot com>
- Cc: "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Mon, 9 Jan 2017 08:19:00 -0800
- Subject: Re: Name of indirect function evaluating to a hidden function?
- Authentication-results: sourceware.org; auth=none
- References: <1963b274-7840-7374-af13-94c8126df2bb@gmail.com>
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