*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> dladdr (3)              



NAME    [Toc]    [Back]

     dladdr -- find the shared object containing a given address

LIBRARY    [Toc]    [Back]

     Standard C Library (libc, -lc)

SYNOPSIS    [Toc]    [Back]

     #include <dlfcn.h>

     dladdr(const void *addr, Dl_info *info);

DESCRIPTION    [Toc]    [Back]

     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

     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    [Toc]    [Back]

     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    [Toc]    [Back]

     rtld(1), dlopen(3)

HISTORY    [Toc]    [Back]

     The dladdr() function first appeared in the Solaris operating system.

BUGS    [Toc]    [Back]

     This implementation is bug-compatible with the Solaris implementation.
     In particular, the following bugs are present:

     +o	 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.

     +o	 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.

     +o	 Returning 0 as an indication of failure goes against long-standing
	 Unix tradition.

FreeBSD 5.2.1		       February 5, 1998 		 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
dlsym IRIX get the address of a symbol in shared object
shm_open FreeBSD open or create a shared memory object shm_unlink -- remove a shared memory object
shm_open Tru64 Opens a shared memory object, creating the object if necessary (P1003.1b)
xlate IRIX the address translation object file section of an ELF object
dso IRIX Dynamic Shared Object (DSO)
dlopen IRIX open a shared object
dlclose IRIX close a shared object
lorder HP-UX find ordering relation for an object library
shm_unlink IRIX deletes a shared memory object
fixso Tru64 Fixes a shared object so that it can be quickstarted
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service