HP-UX Reference (11i v1 05/09) - 3 Library Functions N-Z (vol 7)
s
shl_load(3X) shl_load(3X)
NAME
shl_load(), shl_definesym(), shl_findsym(), shl_get(), shl_get_r(), shl_gethandle(), shl_gethandle_r(),
shl_getsymbols(), shl_unload(), dld_getenv() - explicit load of shared libraries
SYNOPSIS
#include <dl.h>
shl_t shl_load(const char *path, int flags, long address);
int shl_findsym(
shl_t *handle,
const char *sym,
short type,
void *value
);
int shl_definesym(
const char *sym,
short type,
long value,
int flags
);
int shl_getsymbols(
shl_t handle,
short type,
int flags,
void *(*memory) (),
struct shl_symbol **symbols,
);
int shl_unload(shl_t handle);
int shl_get(int index, struct shl_descriptor **desc);
int shl_gethandle(shl_t handle, struct shl_descriptor **desc);
int shl_get_r(int index, struct shl_descriptor *desc);
int shl_gethandle_r(shl_t handle, struct shl_descriptor *desc);
void dld_getenv();
Multithread Usage
These routines are safe to be called from multithreaded applications.
NOTE: The dynamic loader dld.sl serializes the loading and unloading of shared libraries in mul-
tithreaded applications using a recursive pthread mutex lock. See the HP-UX Linker and Libraries
Online User Guide for more information.
DESCRIPTION
These routines can be used to programmatically load and unload shared libraries, and to obtain information
about the libraries (such as the addresses of symbols defined within them). On PA-RISC 32-bit systems, the
routines themselves are accessed by specifying the -ldld option on the command line with the cc or ld
command (see cc(1) and ld(1)). On PA-RISC 64-bit systems, the routines are accessed by specifying either
-ldld or -ldl on the command line. See WARNINGS. In addition, the -E option to the ld command
can be used to ensure that all symbols defined in the program are available to the loaded libraries. This is
the default behavior on PA-RISC 64-bit systems.
Shared libraries are created by compiling source files and linking the resultant object files with the -b
(create shared library) option.
shl_load()
Attaches the shared library named by path or the shared library name that is constructed by using
the path part of path plus the shared library basename followed by the suffix .0 (e.g.
/usr/lib/pa20_64/libname.0) to the process, along with all its dependent libraries. A .0
version is looked for first for those shared libraries that do not have internal names. See ld(1)). The
library is mapped at the specified address.Ifaddress is 0L, the system chooses an appropriate
address for the library. This is the recommended practice because the system has the most complete
Section 3−−884 Hewlett-Packard Company − 1 − HP-UX 11i Version 1: September 2005