HP-UX Reference (11i v1 05/09) - 5 Miscellaneous Topics (vol 9)
d
dld.sl(5) dld.sl(5)
NAME
dld.sl - dynamic loader
MULTITHREAD USAGE
The dynamic loader is thread-safe.
DESCRIPTION
The /usr/lib/pa20_64/dld.sl
program is the PA-RISC 64-bit dynamic loader. The
/usr/lib/dld.sl
program is the PA-RISC 32-bit dynamic loader. In programs that use shared
libraries,
dld.sl is invoked automatically at startup time by exec on PA-RISC 64-bit systems and by the
startup file crt0.o on PA-RISC 32-bit systems. Identical copies of
crt0.o are kept in both
/opt/langtools/lib
and /usr/ccs/lib directories. The dynamic loader is, itself, a shared
library, although it defines no symbols for use by user programs.
Shared Libraries
Shared libraries are executable files created with the
-b option to ld (see ld(1)). They must contain
position-independent code (PIC) that can be mapped anywhere in the address space of a process and exe-
cuted with minimal relocation. PIC can use PC-relative addressing modes and/or linkage tables. It is gen-
erated by default by the compilers on PA-RISC 64-bit systems and by specifying the
+z/+Z options on PA-
RISC 32-bit systems. See the
+help option to ld(1) or the HP-UX Linker and Libraries User’s Guide
manual for details on writing PIC in assembly language.
Incomplete Executables
An executable program linked with one or more shared libraries is called an incomplete executable.
When creating an executable (
a.out) file from object files and libraries, the linker does not copy text
(code) or data from the shared library into the output file. Instead, the dynamic loader maps the library
into the address space of the process at run time. The linker binds all program references to shared library
routines and data to entries in a linkage table, and relies on the dynamic loader to fill in the linkage table
entries once the libraries have been mapped. This linkage table serves as a jump table for function calls.
Thread local storage is now supported. The dynamic loader will tally each shared library’s thread local
storage size as well as the program’s thread local storage size. When all libraries are loaded on PA-RISC
32-bit systems, the dynamic loader either calls a thread routine to set the thread pointer and allocate space
for the initial thread or calls mmap() and lwp_setprivate()
to allocate the space and setup the
thread pointer. On PA-RISC 64-bit systems, the dynamic loader invokes an initializer in the system library
libc which will do the thread initialization, allocation of the initial thread, and set the thread pointer.
On previous PA-RISC 32-bit releases, shared library data items referenced by the program were copied into
the program executable file so that the data references could be resolved statically. Beginning with the
Series 700/800 10.0 release, references to shared library data from the a.out are included in a linkage
table and are resolved at run time.
Loading
An incomplete executable contains a list of path names of the shared libraries searched at link time. At run
time, the dynamic loader attaches to the process all shared libraries that were linked with the program.
The dynamic loader will attempt to load each library from the same directory in which it was found at link
time. It is possible to change the shared library run time search path by specifying a dynamic path list.
See PA-RISC 32-bit Dynamic Path List and/or PA-RISC 64-bit Dynamic Path List.
The text segment of a library is shared among all processes that use it. The data and bss segments are
shared on a page-by-page basis. When a process first accesses (reads or writes) a data or bss page, a copy of
that page is made for the process.
PARISC 32-bit Dynamic Path List
There are two was to specify a dynamic path list :
• by storing a directory path list in the executable using the
+b path_list option to ld,
• by linking the executable with ld option +s, enabling the executable to use the path list defined by
the SHLIB_PATH environment variable at run time.
The path list is a list of one or more path names separated by colons (:). The dynamic path list will work
only for libraries specified with the -l or -l: options to ld. However, it can be enabled for libraries
specified with a full path name using the -l option to chatr (see chatr(1)). If both +s and +b are used,
their relative order on the command line indicates which path list will be searched first in compatibility
HP-UX 11i Version 1: September 2005 − 1 − Hewlett-Packard Company Section 5−−41