HP-UX Reference (11i v3 07/02) - 5 Miscellaneous Topics (vol 9)
d
dld.so(5) dld.so(5)
(Itanium(R)-based System Only)
loader can interpret. The dynamic loader, dld.so
, loads the specified shared libraries as if the program
had been linked explicitly with the shared libraries in
LD_PRELOAD before any other dependents of the
program.
At startup time, the dynamic loader implicitly loads one or more libraries, if found, specified in the
LD_PRELOAD environment. It uses the same load order and symbol resolution order as if the library had
been explicitly linked as the first library in the link line when building the executable. For example, given
an executable built with the following link line:
$ ld ... lib2.so lib3.so lib4.so
If LD_PRELOAD="/var/tmp/lib1.so",
the dynamic loader uses the same load order and symbol
resolution order as if
lib1.so had been specified as the first library in the link line:
$ ld ... /var/tmp/lib1.so lib2.so lib3.so lib4.so
In a typical command line use (with /usr/bin/sh
), where LD_PRELOAD is defined as follows:
$ LD_PRELOAD=mysl.so
application
The dynamic loader searches application according to
$PATH, but searches mysl.so according to
SHLIB_PATH and/or LD_LIBRARY_PATH
, and/or the embedded path (if enabled).
NOTE: Because the dynamic loader checks the
LD_PRELOAD environment variable when running any
executable (except seteuid/setegid programs), if you export
LD_PRELOAD , you should unset it after run-
ning your executable, or run the executable as in the command listed above or in a script.
You can use the
LD_PRELOAD environment variable to load a shared library built with static thread-local
storage model that contains TLS to avoid the following error when loading the library dynamically:
/usr/lib/hpux[32|64]/dld.so: Can’t shl_load() a library containing
Thread Local Storage: /usr/lib/hpux[32|64]/libcps.so.1
You can use +tls=dynamic compiler option to re-compile the library to avoid the above error message.
The load order and symbol resolution order may be different in a PA-RISC 32-bit compatibility mode pro-
gram because the dynamic loader uses depth-first search order in PA-RISC 32-bit mode and breadth-first
search order in standard mode. See Symbol Searching and Dependent Libraries in the
+help option to
ld(1) or the HP-UX Linker and Libraries User’s Guide for more information.
The dynamic loader uses the
LD_PRELOAD environment variable even if you use the +noenvvar in the
link line. This insures that
LD_PRELOAD is enabled even in a +compat link. The LD_PRELOAD vari-
able is always enabled except for setuid and setgid programs.
Note: Using
LD_PRELOAD can cause a core dump when used with applications which mix shared and
archived libraries, especially when both the shared library and the application are built with aC++ or use
libc.
You can specify multiple libraries as part of the LD_PRELOAD environment variable. Separate the
libraries by spaces or colons as in LD_LIBRARY_PATH
. (Multi-byte support is not provided as part of
parsing the
LD_PRELOAD library list). You can specify LD_PRELOAD libraries with absolute paths or
relative paths. The LD_PRELOAD libraries can also consist of just the library names, in which case the
dynamic loader uses the directory path list in the environment variables LD_LIBRARY_PATH
and/or
SHLIB_PATH or the embedded path list (if enabled) to search for the libraries.
The dynamic loader does not issue an error or warning message if it cannot find a library specified by
LD_PRELOAD . However, if it does not find a dependent of the LD_PRELOAD libraries, the dynamic
loader issues the same error message as if the LD_PRELOAD library is specified in the link line.
DIAGNOSTICS
If the dynamic loader is not present, or cannot be invoked by the process for any reason, an error message
is printed to standard error and the process terminates with a non-zero exit code.
These errors fall into two basic categories: errors in attaching a shared library, and errors in binding sym-
bols. The former can occur only at process startup time but the latter can occur at any time during process
execution unless the -B immediate option is used with ld. Possible errors that can occur while attach-
ing a shared library include library not present, library not executable, library corrupt, high water mark too
low, or insufficient room in the address space for the library. Possible errors that can occur while binding
symbols include symbol not found (unresolved external), or library corrupt.
122 Hewlett-Packard Company − 5 − HP-UX 11i Version 3: February 2007