dladdr

Name

dladdr -- library routine for dynamic linking of object files

Synopsis

cc ... -ldl ...

#include <dlfcn.h>

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

int dladdr(void *address, Dlinfo *dlip);

Description

This function implements the System V dynamic linking routines.

The dladdr() function is the inverse of the dlsym() function. If the given address is successfully located inside a module, dladdr() returns nonzero, otherwise 0. On a successful return, the fields of dlip are filled in as follows:

dli_fname

the pathname of the module

dli_fbase

the base address of the module

dli_sname

the name of the highest addressed symbol whose address precedes the given address

dli_saddr

the address of that symbol

Shared objects must be linked using the -shared option to the linker ld(1). The linker flag -rpath may be used to add a directory to the default search path for shared objects and shared libraries. The linker flag -E or the C compiler flag -rdynamic should be used to cause the application to export its symbols to the shared objects.

Environment

LD_LIBRARY_PATH

directory search-path for object files