dld.so.5 (2010 09)
d
dld.so(5)
Itanium(R)-based Systems Only
dld.so(5)
The LD_PRELOAD Environment Variable
NOTE: The LD_PRELOAD feature is disabled for seteuid/setegid programs, such as
passwd. See ld(1)
for more details. This feature is not available to fully-bound static executables.
The
LD_PRELOAD environment variable allows you to load additional shared libraries at program
startup. LD_PRELOAD provides a colon-separated or space-separated list of shared libraries that the
dynamic 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 depen-
dents 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.
The LD_PRELOAD_ONCE Environment Variable
The
LD_PRELOAD_ONCE feature is similar to LD_PRELOAD except that the dynamic loader, dld.so,
unsets LD_PRELOAD_ONCE after reading it, so that any applications invoked by the current application
do not have LD_PRELOAD_ONCE set. This is useful in situations where the current application needs
certain libraries preloaded while the child application is adversely affected if these are preloaded (for
example, ksh terminates abnormally if LD_PRELOAD contains
HP-UX 11i Version 3: September 2010 − 5 − Hewlett-Packard Company 5