dladdr(3C)
dladdr - Translates address to symbolic information
As shipped in IRIX 6.5.22. Last changed in IRIX 6.5.19.
NAME dladdr - Translates address to symbolic information SYNOPSIS cc [flags ...] [file ...] #include <dlfcn.h> int dladdr(void *address, Dl_info *dlip); DESCRIPTION dladdr() determines if the specified address is located within one of the mapped objects (either the executable or a DSO) that make up the current application address space. If the address is within an object, the symbol table available to the run-time linker (rld(1)) 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 Dl_info structure must be preallocated by the user. The structure members are filled in by dladdr() based on the specified address. The Dl_info structure contains at least the following members: const char * dli_fname; void * dli_fbase; const char * dli_sname; void * dli_saddr; The members are defined as follows: dli_fname Contains a pointer to the file name of the containing object. dli_fbase Contains the base address (in memory) of the containing object. dli_sname Contains a pointer to the nearest symbol name. This symbol either has the same address or is the nearest symbol with a lower address. dli_saddr Contains the actual address of the above symbol. The following nonstandard field is in Dl_info: dli_version This is filled in with zero by dladdr(). NOTES If no symbol is found to describe the specified address, but the address is within a mapped-in object, the dli_sname and dli_saddr members are set to 0 by dladdr(). The memory pointed to by dli_fname and dli_sname is within the mapped object. If the object is closed with dlclose(), the pointers become invalid. If the call is attempted on a system that does not have the supporting functionality, the following message will be emitted to /dev/tty by default, and the application will be terminated with a non-zero exit code: Fatal Error: _rld_new_interface: bad operation: 14 Applications that might be executed on IRIX releases with very old rld should first attempt the call in a separate small process. All IRIX 6.5 releases and later, and all IRIX 6.2 releases and later with the applicable rld patch, have the interface and will not receive the error. Define the environment variable _RLD_ARGS as the following to direct the rld message to disk, if its appearance on /dev/tty might be an annoyance: -log /tmp/rldmessage <dlfcn.h> does not contain a prototype for dladdr or definition of Dl_info. The #include <dlfcn.h> in the SYNOPSIS line is traditional, but contains no dladdr prototype and no IRIX library contains an implementation. Write your own declaration based on the code below. The following code is dependent on internal interfaces that are not part of the IRIX compatibility guarantee; however, there is no future intention to change this interface, so on a practical level, the code below is safe to use on IRIX. #include <rld_interface.h> #ifndef _RLD_INTERFACE_DLFCN_H_DLADDR #define _RLD_INTERFACE_DLFCN_H_DLADDR typedef struct Dl_info { const char * dli_fname; void * dli_fbase; const char * dli_sname; void * dli_saddr; int dli_version; int dli_reserved1; long dli_reserved[4]; } Dl_info; #endif #define _RLD_DLADDR 14 int dladdr(void *address, Dl_info *dl); int dladdr(void *address, Dl_info *dl) { void *v; v = _rld_new_interface(_RLD_DLADDR,address,dl); return (int)v; } DIAGNOSTICS The function returns zero if the address cannot be associated with a mapped-in object. In such a case, the Dl_info fields are not touched. The function returns non-zero if it can be associated with a mapped-in object, and the Dl_info fields are updated. SEE ALSO rld(1) dlopen(3C), dlclose(3C), dlsym(3C), sgidlopen_version(3C), sgidlopen_verison(3C) dso(5)