HP-UX Reference (11i v2 03/08) - 3 Library Functions N-Z (vol 7)
s
shl_load(3X) shl_load(3X)
The memory argument should point to a function with the same interface as
mal-
loc() (see malloc(3C)).
The return information consists of an array of the following records (defined in
<dl.h>):
struct shl_symbol {
char *name,
short type,
void *value,
shl_t handle,
};
The type field in the return structure can have the values
TYPE_PROCEDURE
,or
TYPE_DATA. The value and handle fields are only valid if export symbols are
requested and the NO_VALUES flag is not specified. The value field contains the
address of the symbol, while the handle field is the handle of the library that
defined the symbol, or NULL for symbols defined via the
shl_definesym()
rou-
tine and is useful in conjunction with the
GLOBAL_VALUES flag.
If successful,
shl_getsymbols()
returns the number of symbols found; other-
wise it returns −1.
shl_unload() Can be used to detach a shared library from the process. The handle argument
should be the handle returned from a previous call to shl_load(). You can also
get the handle from a call to dlopen(). shl_unload() returns 0 if successful;
otherwise −1 is returned. Any initializers registered with the library are called
before detachment. All explicitly loaded libraries are detached automatically on
process termination.
The same shared library can be opened multiple times. A reference counter is kept
for each loaded shared library, like the behavior of dlopen(3C) and dlclose (3C).
shl_unload does not remove the shared library from the address space until all
references to that shared library have been removed.
shl_get() Returns information about currently loaded libraries, including those loaded impli-
citly at startup time. The index argument is the ordinal position of the shared
library in the shared library search list for the process. A subsequent call to
shl_unload() or dlclose() decrements the index values of all libraries hav-
ing an index greater than the unloaded library. The index value −1 refers to the
dynamic loader and the index value −2 refers to the program itself. The desc argu-
ment is used to return a pointer to a statically allocated buffer containing a descrip-
tor for the shared library. The format of the descriptor is implementation depen-
dent; to examine its format, look at the contents of file /usr/include/dl.h
.
Information common to all implementations includes the library handle, pathname,
and the range of addresses the library occupies. The buffer for the descriptor used
by
shl_get() is static; the contents should be copied elsewhere before a subse-
quent call to the routine. The routine returns 0 normally, or −1 if an invalid index
is given.
shl_gethandle()
Returns information about the library specified by the handle argument. The spe-
cial handle PROG_HANDLE can be used to refer to the program itself. The descrip-
tor returned is the same as the one returned by the shl_get() routine. The
buffer for the descriptor used by shl_gethandle() is static; the contents should
be copied elsewhere before a subsequent call to the routine. The routine returns 0
normally, or −1 on error.
shl_get_r() This is a reentrant version of shl_get(). The desc argument must point to a
buffer of enough user-defined storage to be filled with the library descriptor
described in /usr/include/dl.h. Its semantics are otherwise identical to
shl_get().
shl_gethandle_r()
This is a reentrant version of shl_gethandle(). The desc argument must point
to a buffer of enough user-defined storage to be filled with the library descriptor
described in /usr/include/dl.h. Its semantics are otherwise identical to
HP-UX 11i Version 2: August 2003 − 4 − Hewlett-Packard Company Section 3−−953