Kenwood HP 9000 Personal Computer User Manual


 
242 Chapter 6
Shared Library Management Routines
The dlopen Shared Library Management Routines
More detailed diagnostic information is available through dlerror.
Description
dlopen is one of a family of routines that give the user direct access to
the dynamic linking facilities. dlopen 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 an 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 when these
relocations take place 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.