Kenwood HP 9000 Personal Computer User Manual


 
246 Chapter 6
Shared Library Management Routines
The dlopen Shared Library Management Routines
Parameters
Return Values
If handle does not refer to a valid shared library opened by dlopen, or if
the named symbol cannot be found within any of the shared libraries
associated with handle, dlsym returns NULL. The dlerror routine
provides more detailed diagnostic information.
Description
dlsym allows a process to obtain the address of a symbol defined within
a shared library previously opened by dlopen.
The dlsym routine searches for the named symbol in all shared libraries
loaded automatically as a result of loading the shared library referenced
by handle [see dlopen(3C)].
If handle is RTLD_NEXT, the search begins with the “next” shared library
after the shared library from which dlsym was invoked. Shared libraries
are searched using a load order symbol resolution algorithm [see
dlopen(3C)]. The “next” shared library, and all other shared libraries
searched, are either of global scope (because they were loaded at startup
or as part of a dlopen operation with the RTLD_GLOBAL flag) or are
shared libraries loaded by the same dlopen operation that loaded the
caller of dlsym.
Usage
RTLD_NEXT can be used to navigate an intentionally created hierarchy of
multiply defined symbols created through interposition. For example, if a
program wished to create an implementation of malloc that embedded
some statistics gathering about memory allocations, such an
implementation could define its own malloc which would gather the
Parameter Definition
handle Either the value returned by a call to dlopen or
the special flag RTLD_NEXT. In the former case,
the corresponding shared library must not have
been closed using dlclose.
name The symbol's name as a character string.