| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- dynamic load information
#include <dlfcn.h>#include <link.h>#include <limits.h>#include <sys/mman.h>intdlinfo(void *handle,intrequest,void *p);
Thedlinfo() function sets or extracts information from the runtime linkerld.so.1(1).This function is loosely modeled after theioctl(2) function. Therequest argumentand a third argument of varying type are passed todlinfo(). Theaction taken bydlinfo() depends on the value of therequest that isprovided.
Thehandle argument is either the value that is returned from adlopen(3C) ordlmopen() call, or the special handleRTLD_SELF. Ahandle argumentis required for all requests exceptRTLD_DI_CONFIGADDR,RTLD_DI_GETSIGNAL, andRTLD_DI_SETSIGNAL. Ifhandle isthe value that is returned from adlopen() ordlmopen() call, the informationreturned by thedlinfo() call pertains to the specified object. Ifhandleis the special handleRTLD_SELF, the information returned by thedlinfo() call pertainsto the caller.
Therequest argument can take the following values:
Obtain process argument information. Thep argument is a pointer (Dl_argsinfo_t *p). The following elements from this structure are initialized:
The number of arguments passed to the process.
The argument array passed to the process.
The active environment variable array that is available to the process. This element initially points to the environment variable array that is made available toexec(2). This element can be updated should an alternative environment be established by the process. Seeputenv(3C).
The auxiliary vector array passed to the process.
A process can be established from executing the runtime linker directly from the command line. Seeld.so.1(1). TheDl_argsinfo_t information reflects the information that is made available to the application regardless of how the runtime linker has been invoked.
Obtain the configuration file information. Thep argument is aDl_info_t pointer (Dl_info_t *p). The following elements from this structure are initialized:
The full name of the configuration file.
The base address of the configuration file loaded into memory.
Obtain theLink_map for thehandle that is specified. Thep argument points to aLink_map pointer (Link_map **p). The actual storage for theLink_map structure is maintained byld.so.1.
TheLink_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 */
The base address of the object loaded into memory.
The full name of the loaded object. This full name is the filename of the object as referenced byld.so.1.
Points to theSHT_DYNAMIC structure.
The nextLink_map on the link-map list. Other objects on the same link-map list as the current object can be examined by following thel_next andl_prev members.
The previousLink_map on the link-map list.
If the object that is referenced is afilter, this member points to the name of the object being filtered. If the object is not afilter, this member is0. See theLinker and Libraries Guide.
Obtain the ID for the link-map list upon which thehandle is loaded. Thep argument is aLmid_t pointer (Lmid_t *p).
Determine the number of segment mappings for thehandle that is specified, for use in aRTLD_DI_MMAPS request. Thep argument is auint_t pointer (uint_t *p). On return from aRTLD_DI_MMAPCNT request, theuint_t value that is pointed to byp contains the number of segment mappings that the associated object uses.
To obtain the complete mapping information for an object, ammapobj_result_t array forRTLD_DI_MMAPCNT entries must be provided. This array is assigned to thedlm_maps member, and the number of entries available in the array are assigned to thedlm_acnt member. This initialized structure is then passed to aRTLD_DI_MMAPS request. SeeEXAMPLES.
Obtain segment mapping information for thehandle that is specified. Thep argument is aDl_mapinfo_t pointer (Dl_mapinfo_t *p). This structure can be initialized from the mapping count obtained from a previousRTLD_DI_MMAPCNT request.
Segment mapping information is provided in an array ofmmapobj_result_t structures that originate from themmapobj(2) of the associated object. Thedlm_acnt member, typically initialized from a previousRTLD_DI_MMAPCNT request, indicates the number of entries in ammapobj_result_t array. This array is assigned to thedlm_maps member. This initialized structure is then passed to aRTLD_DI_MMAPS request, where the segment mapping information is copied to themmapobj_result_t array. Thedlm_rcnt member indicates the number ofmmapobj_result_t element entries that are returned. SeeEXAMPLES.
Obtain the library search paths for thehandle that is specified. Thep argument is aDl_serinfo_t pointer (Dl_serinfo_t *p). A user must first initialize theDl_serinfo_t structure with aRTLD_DI_SERINFOSIZE request. SeeEXAMPLES.
The returnedDl_serinfo_t structure containsdls_cntDl_serpath_t entries. Each entry'sdlp_name member points to the search path. The correspondingdlp_info member contains one of more flags indicating the origin of the path. See theLA_SER_* flags that are defined in <link.h>.
Initialize aDl_serinfo_t structure for thehandle that is specified, for use in aRTLD_DI_SERINFO request. Both thedls_cnt anddls_size members are returned. Thedls_cnt member indicates the number of search paths that are applicable to thehandle. Thedls_size member indicates the total size of aDl_serinfo_t buffer required to holddls_cntDl_serpath_t entries and the associated search path strings. Thep argument is aDl_serinfo_t pointer (Dl_serinfo_t *p).
To obtain the complete path information, a newDl_serinfo_t buffer of sizedls_size should be allocated. This new buffer should be initialized with thedls_cnt anddls_size entries. The initialized buffer is then passed to aRTLD_DI_SERINFO request. SeeEXAMPLES.
Obtain the origin of the dynamic object that is associated with thehandle. Thep argument is achar pointer (char *p). Thedirname(3C) of the associated object'srealpath(3C), which can be no larger than {PATH_MAX}, is copied to the pointerp.
Obtain the numeric signal number used by the runtime linker to kill the process in the event of a fatal runtime error. Thep argument is anint pointer (int *p). The signal number is copied to the pointerp.
By default, the signal used by the runtime linker to terminate a process isSIGKILL. Seethr_kill(3C). This default can be changed by callingdlinfo() withRTLD_DI_SETSIGNAL or by setting the environment variableLD_SIGNAL. Seeld.so.1(1).
Provide a numeric signal number used by the runtime linker to kill the process in the event of a fatal runtime error. Thep argument is anint pointer (int *p). The value pointed to byp is established as the terminating signal value.
The current signal number used by the runtime linker to terminate a process can be obtained fromdlinfo() usingRTLD_DI_GETSIGNAL. Use of theRTLD_DI_SETSIGNAL option is equivalent to setting the environment variableLD_SIGNAL. Seeld.so.1(1).
Assign a new dependency name to an existing deferred dependency. Thep argument is aDl_definfo_t pointer (Dl_definfo *p). Thedlv_refname field defines an existing dependency name. Thedlv_depname field defines the new dependency name.
Dependency names are defined byDT_NEEDED dynamic entries, which can be displayed using the-d option ofelfdump(1). Individual dependencies can be tagged as deferred. See the-zdeferred option ofld(1). Deferred dependencies are only loaded during process execution, when the first binding to a deferred reference is made. Prior to a deferred dependency being loaded, the dependency name can be changed withRTLD_DI_DEFERRED. See alsoRTLD_DI_DEFERRED_SYM.
Once a deferred dependency is loaded, any attempt to change the dependency name withdlinfo() results in an error return of -1.
Assign a new dependency name to an existing deferred symbol, using a symbol reference that exists to the dependency. Thep argument is aDl_definfo_t pointer (Dl_definfo *p). Thedlv_refname field defines a symbol reference to the deferred dependency. Thedlv_depname field defines the new dependency name.
RTLD_DI_DEFERRED_SYM provides an alternative means of modifying a deferred dependency to usingRTLD_DI_DEFERRED. One, or more symbol references can be associated with a deferred dependency.RTLD_DI_DEFERRED_SYM allows one of these deferred symbol references to be used to select the associated deferred dependency. Prior to a deferred dependency being loaded, the dependency name can be changed withRTLD_DI_DEFERRED_SYM. SeeEXAMPLES.
Once a deferred dependency is loaded, any attempt to change the dependency name withdlinfo() results in an error return of -1.
Thedlinfo() function returns -1 if therequest is invalid, the parameterp isNULL, or theDl_serinfo_t structure is uninitialized for aRTLD_DI_SERINFO request.dlinfo() also returns -1 if thehandle argument does not refer to avalid object opened bydlopen(), or is not the special handleRTLD_SELF.Detailed diagnostic information is available withdlerror(3C).
Example 1 Usedlinfo() to obtain library search paths.
The following example demonstrates how a dynamic object can inspect the librarysearch paths that would be used to locate a simple filename withdlopen(). For simplicity, error checking has been omitted.
Dl_serinfo_t _info, *info = &_info; Dl_serpath_t *path; uint_t cnt; /* determine search path count and required buffer size */ dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, info); /* allocate new buffer and initialize */ info = malloc(_info.dls_size); info->dls_size = _info.dls_size; info->dls_cnt = _info.dls_cnt; /* obtain search path information */ dlinfo(RTLD_SELF, RTLD_DI_SERINFO, info); path = &info->dls_serpath[0]; for (cnt = 1; cnt <= info->dls_cnt; cnt++, path++) { (void) printf("%2d: %s\n", cnt, path->dls_name); }Example 2 Usedlinfo() to obtain segment information.
The following example demonstrates how a dynamic object can inspect its segmentmapping information. For simplicity, error checking has been omitted
Dl_mapinfo_t mi; uint_t cnt; /* determine the number of segment mappings */ dlinfo(RTLD_SELF, RTLD_DI_MMAPCNT, &mi.dlm_acnt); /* allocate the appropriate mapping array */ mi.dlm_maps = malloc(mi.dlm_acnt * sizeof (mmapobj_result_t)); /* obtain the mapping information */ dlinfo(RTLD_SELF, RTLD_DI_MMAPS, &mi); for (cnt = 0; cnt < mi.dlm_rcnt; cnt++) { (void) printf("addr=%x - memory size=%x\n", mi.dlm_maps[cnt].mr_addr, mi.dlm_maps[cnt].mr_msize); }Example 3 Usedlinfo() to change a deferred dependency.
The following program defines a deferred dependency,foo.so, and an associated deferredsymbol reference,foo().
$elfdump -d main | egrep "NEEDED|POSFLAG [0] POSFLAG_1 0x5 [ LAZY DEFERRED ] [1] NEEDED 0x17e foo.so$elfdump -y main | fgrep foo [12] DBLP [1] foo.so foo
The program probes the existence of the symbolfoo() to verify thatan associated deferred dependency exists. If the dependency does not exist, andhence the symbol can not be found, the program exchanges the deferred dependencyassociated with the symbol for a new dependency namedbar.so. Following thisexchange, the program once more probes for the existence of the symbolfoo()toverify that the new dependency can be loaded, and the symbol canbe found.
if (dlsym(RTLD_PROBE, "foo") == NULL) { Dl_definfo_t info; info.dld_refname = "foo"; info.dld_depname = "bar.so"; if (dlinfo(RTLD_SELF, RTLD_DI_DEFERRED_SYM, &info) == -1) return (1); if (dlsym(RTLD_PROBE, "foo") == NULL) return (1); } foo();A deferred dependency can only be exchanged before the dependency is loaded.If the dependency exists, then any probe would cause the dependency tobe loaded, and any following exchange attempts would fail. To successfully exchange adeferred dependency that is expected to exist, a program must not probefor the symbol before making the exchange.
Dl_definfo_t info; info.dld_refname = "foo"; info.dld_depname = "bar.so"; if (dlinfo(RTLD_SELF, RTLD_DI_DEFERRED_SYM, &info) == -1) (void) printf("Using original dependency\n"); else (void) printf("Using new dependency: bar.so\n");Thedlinfo() function is one of a family of functions that givethe user direct access to the dynamic linking facilities. These facilities areavailable to dynamically-linked processes only. See theLinker and Libraries Guide.
Seeattributes(5) for descriptions of the following attributes:
|
elfdump(1),ld(1),ld.so.1(1),exec(2),ioctl(2),mmapobj(2),dirname(3C),dlclose(3C),dldump(3C),dlerror(3C),dlopen(3C),dlsym(3C),putenv(3C),realpath(3C),thr_kill(3C),attributes(5).
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |