[Previous] [Contents] [Next]

dladdr()

Translate an address to symbolic information

Synopsis:

#include <dlfcn.h>

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

Library:

libc

Description:

The dladdr() function determines whether the specified address is located within one of the objects that make up the calling application's address space.


Note: The dladdr() function is available only to dynamically linked processes.

The Dl_info structure must be allocated by the calling process; its members are filled in by dladdr() based on the specified address. Dl_info includes the following members:

Name Type Description
dli_fname const char * A pointer to the filename of the object containing address.
dli_fbase void * The base address of the object containing address.
dli_sname const char * A pointer to the symbol name nearest the specified address. This symbol is either at address or is the nearest symbol with a lower address.
dli_saddr void * The actual address of the dli_sname symbol.

If no symbol is found to describe the specified address, dli_sname and dli_saddr are NULL.

Returns:

0 if the specified address can't be matched, or nonzero if it could be matched.

Classification:

Unix

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

Caveats:

The Dl_info pointers may become invalid if objects are removed via dlclose().

There's no way to determine which symbol you'll get if multiple symbols are mapped to the same address.

See also:

dlclose(), dlerror(), dlopen(), dlsym()


[Previous] [Contents] [Next]