Dynamic linker
When building an executable file that uses dynamic linking, the
link editor adds a program header element of type PT_INTERP
to an executable file, telling the system to invoke the dynamic
linker as the program interpreter.
NOTE:
The locations of the system provided dynamic linkers are processor specific.
Exec(BA_OS) and the dynamic linker cooperate to create
the process image for the program, which entails the following actions:
-
Adding the executable file's memory segments to the process image;
-
Adding shared object memory segments to the process image;
-
Performing relocations for the executable file and its shared objects;
-
Closing the file descriptor that was used to read the executable
file, if one was given to the dynamic linker;
-
Transferring control to the program, making it look as if the program
had received control directly from exec(BA_OS).
The link editor also constructs various data that assist the dynamic
linker for executable and shared object files. As shown above in
``Program header'',
this data resides in loadable segments, making them available
during execution. (Once again, recall the exact segment contents
are processor-specific. See the processor supplement for complete
information).
-
A .dynamic section with type SHT_DYNAMIC holds
various data. The structure residing at the beginning of the section
holds the addresses of other dynamic linking information.
-
The .hash section with type SHT_HASH holds a
symbol hash table.
-
The .got and .plt sections with type
SHT_PROGBITS
hold two separate tables:
the global offset table and the procedure linkage table.
Sections below explain how the
dynamic linker uses and changes the tables to create memory
images for object files.
Because every ABI-conforming program imports the basic system
services from a shared object library, the dynamic linker
participates in every ABI-conforming program execution.
Shared objects may occupy virtual memory addresses that are
different from the addresses recorded in the file's
program header table. The dynamic linker relocates the memory
image, updating absolute addresses before the application gains
control. Although the absolute address values would be correct
if the library were loaded at the addresses specified in the
program header table, this normally is not the case.
If the process environment (see exec(BA_OS)) contains
a variable named LD_BIND_NOW with a non-null value,
the dynamic linker processes all relocations before transferring
control to the program. For example, all the following environment
entries would specify this behavior.
-
LD_BIND_NOW=1
-
LD_BIND_NOW=on
-
LD_BIND_NOW=off
Otherwise, LD_BIND_NOW either does not occur in the
environment or has a null value. The dynamic linker is permitted
to evaluate procedure linkage table entries lazily, thus avoiding
symbol resolution and relocation overhead for functions that are
not called. See
``Procedure linkage table''
for more information.
Next topic:
Dynamic section
Previous topic:
Program interpreter
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004