The Open Group Base Specifications Issue 8
IEEE Std 1003.1-2024
Copyright © 2001-2024 The IEEE and The Open Group

NAME

dladdr — get information relating to an address

SYNOPSIS

#include <dlfcn.h>

int dladdr(const void *restrict
addr, Dl_info_t *restrict dlip);

DESCRIPTION

The dladdr() function shall determine whether the address specified by addr is located within the address range occupied by a mapped object. The mapped objects examined shall include any executable object files that have previously been loaded by a call to dlopen() and for which dlclose() has not subsequently been called, and any shared library files that were loaded as dependencies of the executable file from which the current process image was loaded; they may also include any executable object files that have previously been loaded by a call to dlopen() and for which dlclose() has subsequently been called, the executable file from which the current process image was loaded, and implementation-defined additional mapped objects (for example, all regular files mapped using mmap() might be included). If the specified address is within the mapped address range of one of these mapped objects and the object contains a symbol table, the symbol table shall be searched for a symbol (a function identifier or a data object identifier) that has the largest address less than or equal to the specified address.

If the address specified by addr is within the mapped address range of one of the examined mapped objects, the structure pointed to by dlip shall be populated as follows:

RETURN VALUE

Upon successful completion, a non-zero value shall be returned. If the specified address is not located within the address range occupied by an examined mapped object, or if an error occurs, zero shall be returned. More detailed diagnostic information shall be available through dlerror().

ERRORS

No errors are defined.


The following sections are informative.

EXAMPLES

None.

APPLICATION USAGE

The Dl_info_t members may point to addresses within the mapped object. These pointers can become invalid if the object is unmapped (for example, loaded executable objects may be unloaded by dlclose()).

If dli_sname names a function identifier, the value of dli_saddr can be converted back to type pointer to function using a cast in the manner shown in the dlsym() EXAMPLES section. Note that this conversion is not defined by the ISO C standard. This standard requires this conversion to work correctly on conforming implementations.

RATIONALE

None.

FUTURE DIRECTIONS

None.

SEE ALSO

dlclose, dlerror, dlopen, dlsym

XBD <dlfcn.h>

CHANGE HISTORY

First released in Issue 8.

End of informative text.

 

return to top of page

UNIX® is a registered Trademark of The Open Group.
POSIX™ is a Trademark of The IEEE.
Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved
[ Main Index | XBD | XSH | XCU | XRAT ]