The following flags do not affect relocation processing, but provide the following features:

RTLD_NODELETE: Under this mode, the specified object and its dependencies behave as if they were built with -B nodelete . An explicit unload using dlclose or shl_load returns success silently without detaching the shared library for the process. Subsequently, the shared library handle is valid only for shl_findsym. It stays invalid for dlsym, dlclose, and shl_unload until the next explicit load using shl_load or dlclose.

RTLD_NOLOAD: Under this mode, the specified object is not loaded into the process's address space, but a valid handle is returned if the object already exists in the process address space. If the specified object does not already exist, then an error is returned. RTLD_NOLOAD can be used to query the presence, or for overriding the modes of an existing object.

If a file is specified in multiple dlopen invocations, mode is interpreted at each invocation. Note, however, that once RTLD_NOW has been specified, the linker operation completes all relocations, rendering any further RTLD_NOW operations redundant and any further RTLD_LAZY operations irrelevant. Similarly note that once you specify RTLD_GLOBAL, the shared library maintains the RTLD_GLOBAL status regardless of any previous or future specification of RTLD_LOCAL, as long as the shared library remains in the address space [see dlclose(3C)].

RTLD_VERBOSE: Under this mode, the dynamic loader displays verbose messages when binding symbols on PA32 systems. If RTLD_VERBOSE is ORed with the flags parameter, the dynamic loader displays verbose messages for all the unresolved symbols. You can use this option to view the symbols, which are not bound. Typically, RTLD_VERBOSE is used with RTLD_NOW to debug unresolved symbols. For example:

...

void *dl =dlopen("unsat.sl", RTLD_NOW RTLD_VERBOSE);

...

NOTE: The RTLD_VERBOSE flag for dlopen routine, and the BIND_VERBOSE flag for shl_load routine can also be enabled by using the _HP_DLDOPTS environment variable (instead of specifying the flags in the dlopen, and shl_load routines). This is particularly useful for existing programs to enable RTLD_VERBOSE, and BIND_VERBOSE without any change in code. To set the RTLD_VERBOSE and the BIND_VERBOSE flags by using _HP_DLDOPTS, enter the following command at the HP-UX prompt:

$ export _HP_DLOPTS=-load_verbose

Symbols introduced into a program through calls to dlopen may be used in relocation activities. Symbols so introduced may duplicate symbols already defined by the program or previous dlopen operations. To resolve the ambiguities such a situation may present, the resolution of a symbol reference to a symbol definition is based on a symbol resolution order. Two such resolution orders are defined: load and dependency ordering.

Load order establishes an ordering among symbol definitions using the temporal order in which the shared libraries containing the definitions were loaded, such that the definition first loaded has priority over definitions added later. Load ordering is used in relocation processing.

Dependency ordering uses a "breadth-first" order starting with a given shared library, then all of its dependencies, then any dependents of those, iterating until all dependencies are satisfied.

The dlsym function uses dependency ordering, except when the global symbol shared library is obtained via a dlopen operation on file with a value 0. The dlsym function uses load ordering on the global symbol shared library.

When a dlopen operation first makes it accessible, a shared library and its dependent shared libraries are added in dependency order. Once all shared libraries are added, relocations are performed using load order. Note that if a shared library and its dependencies have been loaded by a previous dlopen invocation or on startup, the load and dependency order may yield different resolutions.

The dlopen Shared Library Management Routines 151

Page 151
Image 151
HP UX Software Transition Kit (STK) manual Dlopen Shared Library Management Routines