operation and limitations of dladdr()?

Florian Weimer fweimer@redhat.com
Wed Mar 30 07:56:00 GMT 2016


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



More information about the Libc-help mailing list