dladdr(3) — Subroutines
NAME
dladdr − translate address to symbolic information
SYNOPSIS
#include <stdio.h>
#define __EXTENSIONS__
#include <dlfcn.h> int dladdr(
void ∗address,
Dl_info ∗dlip );
PARAMETERS
addressSpecifies the address for the symbol being sought.
dlipSpecifies the preallocated Dl_info structure that dladdr() will fill in based on the specified address.
DESCRIPTION
The dladdr() function is one of a family of routines that give the user direct access to the dynamic linking facilities. It can only be used in dynamically linked processes.
The dladdr() function determines whether the specified address is located within one of the mapped objects that make up the current application’s address space. An address is considered to be 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 loader searches the object’s symbol table to locate the nearest symbol to the specified address.
The Dl_info structure includes the following members:
const char ∗ dli_fname;
void ∗ dli_fbase;
const char ∗ dli_sname;
void ∗ dli_saddr;
Descriptions of these members are as follows:
dli_fname
Pointer to the file name of the containing object.
dli_fbase
The base address of the containing object.
dli_sname
Pointer to the symbol name nearest to the specified address. This symbol either had the same address or is the nearest symbol with a lower address.
dli_saddr
The actual address of the symbol pointed to by the dli_sname member.
The Dl_info 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(3)).
RETURN VALUES
If the specified address cannot be matched to a mapped object, a 0 (zero) is returned. Otherwise, a nonzero returned is made and the associated Dl_info elements are filled.
If no symbol is found to describe the specified address, both the dli_sname and the dli_saddr members are set to 0.
SEE ALSO
Functions: dlclose(3), dlerror(3), dlopen(3), dlsym(3)