HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

d
dladdr(3C) dladdr(3C)
NAME
dladdr() - get the symbolic information for an address
SYNOPSIS
cc [flag]... cfile ...
-ldl [library]...
#include <dlfcn.h>
int dladdr(void *address, Dl_info *dlip);
Multithread Usage
This routine is thread-safe.
DESCRIPTION
dladdr() is one of a family of routines that give the user direct access to the dynamic linking facilities
(using the
-ldl option on the compiler or
ld command line). dladdr() allows a process to obtain infor-
mation about the symbol that most closely defines a given address.
dladdr() determines whether the
specified address is located within one of the load modules (executable or shared libraries) that make up the
process address space. An address is deemed to fall within a load module when it is between the base
address at which the load module was mapped and the highest virtual address mapped for that load
module, inclusive. If a load module fits this criteria, its dynamic symbol table is searched to locate the
nearest symbol to the specified address. The nearest symbol is the one whose value is equal to, or closest to
but less than the specified address.
dlip is a pointer to a
Dl_info structure. The structure must be allocated by the user. The structure
members are set by dladdr() if the specified address falls within one of the load modules. The
Dl_info structure contains the following members:
struct {
const char *dli_fname;
void *dli_fbase;
const char *dli_sname;
void *dli_saddr;
size_t dli_size; /* ELF only */
int dli_bind; /* ELF only */
int dli_type;
};
The fields of the Dl_info structure contain the following:
dli_fname
Pointer to the filename of the load module containing the address. The contents of this memory
location can change between calls to
dladdr().
dli_fbase
Handle to the load module. This can be used as the first argument to dlsym()
.
dli_sname
Pointer to the name of the nearest symbol to the specified address. This symbol either has the
same address, or is the nearest symbol with a lower address. The contents of this memory loca-
tion can change between calls to
dladdr().
dli_saddr
Actual address of the nearest symbol. For code symbols, it contains the address of the OPD
(Official Plabel Descriptor) for the nearest code symbol.
dli_size
(ELF process only) Size of the nearest symbol as defined in the dynamic symbol table.
dli_bind
(ELF process only) Binding attribute of the nearest symbol as defined in the dynamic symbol
table. The values for this are those used for a symbol’s binding in the ELF symbol table (see
<elf.h>)
dli_type
Type of the nearest symbol. For ELF process, this is the same as the value for type in the
dynamic symbol table. The values for this are those used for a symbol’s type in the ELF symbol
table (see <elf.h>). For SOM process, this can have the value TYPE_DATA or
TYPE_PROCEDURE as defined in <dl.h>).
HP-UX 11i Version 1: September 2005 1 Hewlett-Packard Company Section 3149