Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
dladdr(3)
Edit
PageHistory
Diff
Info
LikePages
!!NAME __dladdr__ -- find the shared object containing a given address !!LIBRARY Standard C Library (libc, -lc) !!SYNOPSIS __#include <dlfcn.h>__ %%% __''int''__ __dladdr__(__''const void *addr''__, __''Dl''_''info *info''__); !!DESCRIPTION The __dladdr__() function queries the dynamic linker for information about the shared object containing the address __''addr''__. The information is returned in the structure specified by __''info''__. The structure contains at least the following members: const char *dli_fname The pathname of the shared object containing the address. void *dli_fbase The base address at which the shared object is mapped into the address space of the calling process. const char *dli_sname The name of the nearest run-time symbol with a value less than or equal to __''addr''__. When possible, the symbol name is returned as it would appear in C source code. If no symbol with a suitable value is found, both this field and __''dli''_''saddr''__ are set to NULL. void *dli_saddr The value of the symbol returned in dli_sname. The __dladdr__() function is available only in dynamically linked programs. !!ERRORS If a mapped shared object containing __''addr''__ cannot be found, __dladdr__() returns 0. In that case, a message detailing the failure can be retrieved by calling __dlerror__(). On success, a non-zero value is returned. !!SEE ALSO rtld(1), dlopen(3) !!HISTORY The __dladdr__() function first appeared in the Solaris operating system. !!BUGS This implementation is bug-compatible with the Solaris implementation. In particular, the following bugs are present: * If __''addr''__ lies in the main executable rather than in a shared library, the pathname returned in __''dli''_''fname''__ may not be correct. The pathname is taken directly from __''argv[[0]''__ of the calling process. When executing a program specified by its full pathname, most shells set __''argv[[0]''__ to the pathname. But this is not required of shells or guaranteed by the operating system. * If __''addr''__ is of the form __''&func''__, where __''func''__ is a global function, its value may be an unpleasant surprise. In dynamically linked programs, the address of a global function is considered to point to its program linkage table entry, rather than to the entry point of the function itself. This causes most global functions to appear to be defined within the main executable, rather than in the shared libraries where the actual code resides. * Returning 0 as an indication of failure goes against long-standing Unix tradition.
One page links to
dladdr(3)
:
dlsym(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.