DLINFO(3) | Library Functions Manual | DLINFO(3) |
dlinfo
—
#include <link.h>
#include <dlfcn.h>
int
dlinfo
(void
*handle, int
request, void
*p);
dlinfo
() function provides information about a
dynamically loaded object. The action taken by
dlinfo
() and exact meaning and type of
p argument depend on value of the
request argument provided by caller.
The handle argument is either the value
returned from the dlopen(3)
function call or special handle RTLD_SELF
. If
handle is the value returned from
dlopen(3), the information
returned by the dlinfo
() function pertains to the
specified object. If handle is the special handle
RTLD_SELF
, the information returned pertains to the
caller itself.
Possible values for the request argument are:
RTLD_DI_LINKMAP
The Link_map structure is defined in
<link.h>
and has the
following members:
caddr_t l_addr; /* Base Address of library */ #ifdef __mips__ caddr_t l_offs; /* Load Offset of library */ #endif const char *l_name; /* Absolute Path to Library */ void *l_ld; /* Pointer to .dynamic in memory */ struct link_map *l_next, /* linked list of mapped libs */ *l_prev;
PT_DYNAMIC
) loaded into memory.dlinfo
() function returns 0 on success, or -1 if an
error occurred. Whenever an error has been detected, a message detailing it
can be retrieved via a call to
dlerror(3).
dlinfo
() to retrieve
Link_map structure.
The following example shows how dynamic library can detect the list of shared libraries loaded after caller's one. For simplicity, error checking has been omitted.
Link_map *map; dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map); while (map != NULL) { printf("%p: %s\n", map->l_addr, map->l_name); map = map->l_next; }
dlinfo
() function first appeared in the Solaris
operating system. In NetBSD, it first appeared in
NetBSD 5.1.
dlinfo
() function was written by
Antti Kantee
<pooka@NetBSD.org>.
The manual page for this function was written by Alexey Zelkin <phantom@FreeBSD.org> and adapted to NetBSD by Kamil Rytarowski <kamil@NetBSD.org>.
January 13, 2020 | NetBSD 10.1 |