dladdr(3X) dladdr(3X)
NAME
dladdr - translate address to symbolic information
SYNOPSIS
cc [flag ...] file ... -ldl [library ...]
#include <dlfcn.h>
int dladdr(void *address, Dlinfo *dlip);
DESCRIPTION
dladdr() is one of a family of routines that give the user direct
access to the dynamic linking facilities. These routines are made
available via the library loaded when the option -ldl is passed to the
link-editor.
Note: These routines are available to dynamically-linked processes
only.
dladdr() determines if the specified address is located within one of
the mapped objects that make up the current applications address
space. An address is considered to fall within a mapped object when it
is between the base address, and the end address of that object. If a
mapped object fits this criteria, the symbol table made available to
the run-time linker is searched to locate the nearest symbol to the
specified address. The nearest symbol is one that has a value less
than or equal to the required address.
The Dlinfo structure must be preallocated by the user. The structure
members are filled in by dladdr() based on the specified address. The
Dlinfo structure includes the following members:
const char *dlifname;
void *dlifbase;
const char *dlisname;
void *dlisaddr;
sizet dlisize;
int dlibind;
int dlitype;
Descriptions of these members appear below.
dlifname Contains a pointer to the filename of the containing
object.
dlifbase Contains the base address of the containing object.
dlisname Contains a pointer to the symbol name nearest to the
specified address. This symbol either has the same
address, or is the nearest symbol with a lower address.
dlisaddr Contains the actual address of the above symbol.
Page 1 Reliant UNIX 5.44 Printed 11/98
dladdr(3X) dladdr(3X)
dlisize Contains the size in bytes of the above symbol.
dlibind Contains the binding attributes of the above symbol.
dlitype Contains the type of the above symbol.
RESULT
If the specified address cannot be matched to a mapped object, a 0 is
returned. Otherwise, a non-zero return is made and the associated
Dlinfo elements are filled.
NOTES
The Dlinfo pointer elements point to addresses within the mapped
objects. These may become invalid if objects are removed prior to
these elements being used [see dlclose(3X)].
If no symbol is found to describe the specified address, both the
dlisname and dlisaddr members are set to 0.
SEE ALSO
ld(1), dlclose(3X), dlerror(3X), dlopen(3X), dlsym(3X).
Chapter on "The C compilation system" in Guide to Tools for Program-
ming in C.
Page 2 Reliant UNIX 5.44 Printed 11/98