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

dladdr implements the System V dynamic linking routines.

Return Value

dladdr is the inverse of dlsym. If address is successfully located inside a module, dladdr returns a non-ZERO value, otherwise, it returns a 0. On success, dladdr fills in the fields of dlip 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