HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)
d
dlopen_pa(3C) dlopen_pa(3C)
(For PA-RISC Systems)
Only a single copy of an object file is brought into the address space, even if
dlopen() is invoked multi-
ple times in reference to the file, and even if different path names are used to reference the file.
When a shared object is brought into the address space of a process, it may contain references to symbols
whose addresses are not known until the object 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:
RTLD_LAZY Under this mode, only references to data symbols are relocated when the object is loaded.
References to functions are not relocated until a given function is invoked for the first
time. This mode should result in better performance, since a process may not reference
all of the functions in any given shared object.
RTLD_NOW Under this mode, all necessary relocations are performed when the object is first loaded.
This may result in some wasted effort, if relocations are performed for functions that are
never referenced, but is useful for applications that need to know as soon as an object is
loaded that all symbols referenced during execution will be available.
Any object loaded by
dlopen() that requires relocations against global symbols can reference the sym-
bols in the original a.out, any objects loaded at program startup, from the object itself as well as any
other object included in the same dlopen() invocation, and any objects that were loaded in any
dlo-
pen() invocation that specified the RTLD_GLOBAL
flag. To determine the scope of visibility for the sym-
bols loaded with a
dlopen() invocation, the mode parameter should be bitwise or’ed with one of the fol-
lowing values:
RTLD_GLOBAL
The object’s symbols are made available for the relocation processing of any other object.
In addition, symbol lookup using dlopen(0,mode) and an associated dlsym() allows
objects loaded with RTLD_GLOBAL to be searched.
RTLD_LOCAL The object’s symbols are made available for relocation processing only to objects loaded in
the same dlopen() invocation.
If neither
RTLD_GLOBAL nor RTLD_LOCAL are specified, the default is RTLD_LOCAL.
If a file is specified in multiple
dlopen() invocations, mode is interpreted at each invocation. Note,
however, that once RTLD_NOW has been specified, all relocations will have been completed, rendering any
further RTLD_NOW operations redundant and any further RTLD_LAZY operations irrelevant. Similarly
note that once RTLD_GLOBAL has been specified, the object will maintain the RTLD_GLOBAL status
regardless of any previous or future specification of RTLD_LOCAL, so long as the object remains in the
address space (see dlclose (3C)).
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 or’ed 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 build with -B
group (see ld(1)).
RTLD_PARENT
Under this mode, symbols from the object that invoked dlopen() are also made avail-
able for relocation.
The modes
RTLD_GROUP, RTLD_WORLD, and RTLD_PARENT are presently supported only for 64-bit
applications.
The default modes for
dlopen() are RTLD_WORLD|RTLD_GROUP. These flags are or’ed together when
the same object is loaded with different modes.
The following flags do not affect relocation processing but provide other features:
RTLD_NODELETE
Under this mode, the specified object and its dependencies behave as if they were built
with -B nodelete (see ld(1)). An explicit unload using dlclose() or shl_load()
returns success silently without detaching the shared library from the process.
Section 3−−220 Hewlett-Packard Company − 2 − HP-UX 11i Version 2: September 2004