This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: operation and limitations of dladdr()?
- From: Florian Weimer <fweimer at redhat dot com>
- To: Britton Kerin <britton dot kerin at gmail dot com>, libc-help at sourceware dot org
- Date: Wed, 30 Mar 2016 09:56:05 +0200
- Subject: Re: operation and limitations of dladdr()?
- Authentication-results: sourceware.org; auth=none
- References: <CAC4O8c_Xudck=j4svT_2qAQJYJf3YMF2ksM5_Vg9GC8BJ5zhZw at mail dot gmail dot com>
On 03/29/2016 10:27 PM, Britton Kerin wrote:
> I'm trying to learn as much as possible about dladdr() before
> unleashing a small lib that uses it on the world. Two questions:
>
> Does the fact that dladdr() reports the symbol with the nearest
> address lower than the given
> one mean that that might be the correct function? In other words why this:
>
> const char *dli_sname; /* Name of nearest symbol with address
> lower than addr */
> void *dli_saddr; /* Exact address of symbol name in dli_sname */
>
> I would have thought that the address of the function about to be
> executed would have to match the library address exactly, but maybe
> not. What does it mean if they don't match?
dladdr cannot always determine the function symbol from an address.
Often, it is still useful to obtain the base address of the shared
object, so that you can figure out the exact location by other means
(such as DWARF debugging information).
Florian