HP-UX Linker and Libraries User's Guide
• file is not a shared object.
• An error occurs during the process of loading file or relocating its symbolic references.
More detailed diagnostic information is available through dlerror.
Description
The dlopen routine is one of a family of routines that give the user direct access to the dynamic
linking facilities. The dlopen routine makes a shared library specified by a file available to a
running process. A shared library 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 shared library. Each needed shared library may, in turn, specify other needed shared
libraries. All such shared libraries are loaded along with the original shared library as a result of
the call to dlopen.
If the value of file is 0, dlopen provides a handle on a "global symbol shared library." This shared
library provides access to the symbols from an ordered set of shared libraries consisting of the
original a.out, all of the shared libraries that were loaded at program startup along with the
a.out, and all shared libraries loaded using a dlopen operation along with the RTLD_GLOBAL
flag. As the latter set of shared libraries can change during execution, the set identified by handle
can also change dynamically.
Only a single copy of a shared library file is brought into the address space, even if dlopen is
invoked multiple times in reference to the file, and even if different pathnames are used to reference
the file. When a shared library is brought into the address space of a process, it can contain
references to symbols whose addresses are not known until the shared library is loaded. These
references must be relocated before the symbols can be accessed. The mode parameter governs
the relocations and may have the following values (defined in Parameters): RTLD_LAZY and
RTLD_NOW.
Any shared library loaded by dlopen that requires relocations against global symbols can reference
the following:
• Symbols in the original a.out.
• Any shared libraries loaded at program startup, from the shared library itself.
• Any shared library included in the same dlopen invocation.
• Any shared libraries that were loaded in any dlopen invocation that specified the
RTLD_GLOBAL flag.
To determine the scope of symbols that are made available for relocation processing of objects
loaded in a dlopen invocation, the mode parameter can be bitwise alternated with one of the
following values:
RTLD_GROUP:Under this mode, the specified object and its dependencies behave as if they were
built with -B group (see ld(1)). Only symbols from objects loaded in the same dlopen invocation
are made available for relocation. This ensures that all relocations are satisfied using symbol
definitions from the same dlopen invocation.
RTLD_WORLD: Under this mode, only symbols from global objects and from the object itself are
available for relocation processing. It does not use symbol definitions from other objects loaded
as part of the dlopen invocation. This flag has no effect on objects built with -B group (see ld(1)).
RTLD_PARENT: Under this mode, symbols from the object that invoked dlopen are also made
available for relocation.
The default modes for dlopen are RTLD_WORLD|RTLD_GROUP. These flags are alternated
together when the same object is loaded with different modes.
The values RTLD_GROUP, RTLD_WORLD, and RTLD_PARENT are not available for PA32
systems.
150 Shared Library Management Routines