dladdr -- find the shared object containing a given address


#include <dlfcn.h>

typedef struct {
             const char  *dli_fname;
             void        *dli_fbase;
             const char  *dli_sname;
             void        *dli_saddr;
} Dl_info;

int dladdr(const void * addr, Dl_info * dlip);


The dladdr() function shall query the dynamic linker for information about the shared object containing the address addr. The information shall be returned in the user supplied data structure referenced by dlip.

The structure shall contain at least the following members:


The pathname of the shared object containing the address


The base address at which the shared object is mapped into the address space of the calling process.


The name of the nearest runtime symbol with value less than or equal to addr. Where possible, the symbol name shall be returned as it would appear in C source code.

If no symbol with a suitable value is found, both this field and dli_saddr shall be set to NULL.


The address of the symbol returned in dli_sname. This address has type "pointer to type", where type is the type of the symbol dli_sname.

Example: If the symbol in dli_sname is a function, then the type of dli_saddr is of type "pointer to function".

The behavior of dladdr() is only specified in dynamically linked programs.

Return Value

On success, dladdr() shall return non-zero, and the structure referenced by dlip shall be filled in as described. Otherwise, dladdr() shall return zero, and the cause of the error can be fetched with dlerror().


See dlerror().



directory search-path for object files