dlinfo - dynamic load information
#include <dlfcn.h> #include <link.h> #include <limits.h> int dlinfo(void *handle, int request, void *p);
The dlinfo() function sets or extracts information from the runtime linker ld.so.1(1). This function is loosely modeled after the ioctl(2) function. The request argument and a third argument of varying type are passed to dlinfo(). The action taken by dlinfo() depends on the value of the request that is provided.
The handle argument is either the value that is returned from a dlopen(3C) or dlmopen() call, or the special handle RTLD_SELF. A handle argument is required for all requests except RTLD_DI_CONFIGADDR, RTLD_DI_GETSIGNAL, and RTLD_DI_SETSIGNAL. If handle is the value that is returned from a dlopen() or dlmopen() call, the information returned by the dlinfo() call pertains to the specified object. If handle is the special handle RTLD_SELF, the information returned by the dlinfo() call pertains to the caller.
The request argument can take the following values:
RTLD_DI_ARGSINFO
dla_argc
dla_argv
dla_envp
dla_auxv
A process can be established from executing the runtime linker directly from the command line. See ld.so.1(1). The Dl_argsinfo information reflects the information that is made available to the application regardless of how the runtime linker has been invoked.
RTLD_DI_CONFIGADDR
dli_fname
dli_fbase
RTLD_DI_LINKMAP
The Link_map structure includes the following members:
unsigned long l_addr; /* base address */ char *l_name; /* object name */ Elf32_Dyn *l_ld; /* .dynamic section */ Link_map *l_next; /* next link object */ Link_map *l_prev; /* previous link object */ char *l_refname; /* filter reference name */
l_addr
l_name
l_ld
l_next
l_prev
l_refname
RTLD_DI_LMID
RTLD_DI_SERINFO
The returned Dl_serinfo structure contains dls_cnt Dl_serpath entries. Each entry's dlp_name member points to the search path. The corresponding dlp_info member contains one of more flags indicating the origin of the path. See the LA_SER_* flags that are defined in <link.h>.
RTLD_DI_SERINFOSIZE
To obtain the complete path information, a new Dl_serinfo buffer of size dls_size should be allocated. This new buffer should be initialized with the dls_cnt and dls_size entries. The initialized buffer is then passed to a RTLD_DI_SERINFO request. See EXAMPLES.
RTLD_DI_ORIGIN
RTLD_DI_GETSIGNAL
By default, the signal used by the runtime linker to terminate a process is SIGKILL. See thr_kill(3C). This default can be changed by calling dlinfo() with RTLD_DI_SETSIGNAL or by setting the environment variable LD_SIGNAL. See ld.so.1(1).
RTLD_DI_SETSIGNAL
The current signal number used by the runtime linker to terminate a process can be obtained from dlinfo() using RTLD_DI_GETSIGNAL. Use of the RTLD_DI_SETSIGNAL option is equivalent to setting the environment variable LD_SIGNAL. See ld.so.1(1).
The dlinfo() function returns -1 if the request is invalid, the parameter p is NULL, or the Dl_serinfo structure is uninitialized for a RTLD_DI_SERINFO request. dlinfo() also returns -1 if the handle argument does not refer to a valid object opened by dlopen(), or is not the special handle RTLD_SELF. Detailed diagnostic information is available with dlerror(3C).
Example 1 Use dlinfo() to obtain the library search paths.
The following example demonstrates how a dynamic object can inspect the library search paths that would be used to locate a simple filename with dlopen(). For simplicity, error checking has been omitted.
Dl_serinfo _info, *info = &_info; Dl_serpath *path; uint_t cnt; /* determine search path count and required buffer size */ dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, (void *)info); /* allocate new buffer and initialize */ info = malloc(_info.dls_size); info->dls_size = _info.dls_size; info->dls_cnt = _info.dls_cnt; /* obtain sarch path information */ dlinfo(RTLD_SELF, RTLD_DI_SERINFO, (void *)info); path = &info->dls_serpath[0]; for (cnt = 1; cnt <= info->dls_cnt; cnt++, path++) { (void) printf("%2d: %s\n", cnt, path->dls_name); }
The dlinfo() function is one of a family of functions that give the user direct access to the dynamic linking facilities. These facilities are available to dynamically-linked processes only. See the Linker and Libraries Guide.
See attributes(5) for descriptions of the following attributes:
|
ld(1), ld.so.1(1), exec(2), ioctl(2), dirname(3C), dlclose(3C), dldump(3C), dlerror(3C), dlopen(3C), dlsym(3C), putenv(3C), realpath(3C), thr_kill(3C), attributes(5).
Linker and Libraries Guide
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |