HP-UX Reference (11i v2 07/12) - 5 Miscellaneous (vol 9)
d
dld.so(5)
Itanium(R)-based Systems Only
dld.so(5)
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.
Running Setuid Programs
For looking up shared libraries for setuid applications, the dynamic loader uses only the paths listed in
/etc/dld.sl.conf.
If LD_LIBRARY_PATH and SHLIB_PATH are set, they are validated against the list of paths in
/etc/dld.sl.conf. (This allows the individual applications to appropriately order the list from the
conf file).
You can turn this feature off by setting the option _HP_DLDOPTS to -no_setuidpath. Using this
option disables setuid programs from all dynamic path lookup.
The configuration file /etc/dld.sl.conf is expected to contain a list of shared library search paths
(delimited by either colon or newline characters). To avoid redundant searches, you should see that one
HP-UX 11i Version 2: December 2007 Update − 5 − Hewlett-Packard Company 123