dlopen_pa.3c (2010 09)
d
dlopen_pa(3C)
PA-RISC Systems Only
dlopen_pa(3C)
NAME
dlopen_pa: dlopen(), dlopene() - open an HP 9000 shared library; open an HP 9000 64-bit shared library
with explicit load address
SYNOPSIS
Command:
cc [flag]... cfile...
-ldl [library ]...
#include <dlfcn.h>
void *dlopen(const char *file, int mode);
void *dlopene(const char *file, int mode, struct dlopen_opts *opts);
Remarks
This manpage describes dlopen() on HP 9000 systems. For
dlopen() on Integrity systems, see
dlopen_ia (3C).
Multithread Usage
These routines are thread-safe.
Note: The dynamic loader
dld.sl serializes the loading and unloading of shared libraries in
multithreaded applications using a recursive pthread mutex lock. See the HP-UX Linker and
Libraries Online User Guide for more information.
DESCRIPTION
dlopen() and dlopene() are members of a family of routines that give the user direct access to the
dynamic linking facilities (using the -ldl option on the compiler or ld command line).
dlopen() makes a shared object specified by a file available to a running process. A shared object may
specify other objects that it "needs" in order to execute properly. These dependencies are specified by
DT_NEEDED entries in the .dynamic section of the original object. Each needed object may, in turn,
specify other needed objects. All such objects are loaded along with the original object as a result of the
call to dlopen().
dlopene() is an extension to dlopen() which allows the caller to specify explicitly the placement of a
shared library’s text and data segment when the library is dynamically loaded.
A successful
dlopen() or dlopene() call returns to the process a handle which the process may use
on subsequent calls to dlsym() and dlclose(). This value should not be interpreted in any way by
the process.
file is used to construct a path name to the object file. If file contains a slash character, the file argument
itself is used as the path name. Otherwise
dlopen() searches a series of directories, in the following
order, for file :
• Any directories specified by the dynamic path set by calling
dlsetlibpath()
.
• Any directories specified by the environment variable
LD_LIBRARY_PATH.
• Any directories specified by
SHLIB_PATH.
• For ELF applications, any directories specified by a
DT_RPATH entry in the .dynamic section of
the original program object.
• The directories
/usr/lib and usr/ccs/lib in 32-bit mode and /usr/lib/pa20_64 and
/usr/ccs/lib/pa20_64 in 64-bit mode.
• The current working directory.
The use of
SHLIB_PATH is static. This means that when the program starts, the dynamic loader dld
uses the value in environment variable SHLIB_PATH. Any change to SHLIB_PATH during the program
execution has no effect. The dld_getenv() function removes this constraint. With dld_getenv()
you can change the SHLIB_PATH value (using putenv) and call dld_getenv() to cause dld to read
current SHLIB_PATH value. You can use this new SHLIB_PATH value for subsequent library searching.
You can use
dld_getenv() while loading shared libraries using shl_load() or dlopen().As
described earlier, you should enable SHLIB_PATH searching using the chatr +s enable option. In
case of shl_load(), you should use the DYNAMIC_PATH flag.
The following example demonstrates the
dld_getenv() function:
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1