HP-UX Linker and Libraries User's Guide
debugger with incremental-linking support. The linker performs the following different modes of
linking:
• Normal link: the default operation mode in which the linker links all modules.
• Initial incremental link: the mode entered when you request an incremental link, but the output
module created by the incremental linker does not exist, or it exists but the incremental linker
is unable to perform an incremental update.
• Incremental link: the mode entered when you request an incremental link, an output module
created by the incremental linker exists, and the incremental linker does not require an initial
incremental link.
Incremental links are usually much faster than regular links. On the initial link, the incremental linker
requires about the same amount of time that a normal link process requires, but subsequent
incremental links can be much faster than a normal link. A change in one object file in a moderate
size link (tens of files, several megabytes total) normally is about 10 times faster than a regular ld
link. The incremental linker performs as many incremental links as allocated padding space and
other constraints permit. The cost of the reduced link time is an increase in the size of the executable
or shared library.
The incremental linker allocates padding space for all components of the program. Padding makes
modules larger than those modules linked by ld. As object files increase in size during successive
incremental links, the incremental linker can exhaust the available padding. If this occurs, it displays
a warning message and does a complete initial incremental link of the module. When an object
file changes, the incremental linker not only replaces the content of that file in the executable or
shared library being linked, but also adjusts references to all symbols defined in the object file and
referenced by other objects. This is done by looking at relocation records saved in the incrementally
linked executable or shared library.
On the initial incremental link, the linker processes the input object files and libraries in the same
way as the normal link. In addition to the normal linking process, the incremental linker performs
the additional actions:
• Saves information about all the object files processed during the linking process.
• Saves information about all global symbol for recreating the linker symbol table.
• Saves relocations to keep track of symbolic references.
• Pads text, data, bss, and other sections in the output file with additional space for future
expansion.
On subsequent incremental links, the linker uses timestamps and file sizes to determine which object
files have changed. It then performs the following actions:
• Remove and vacate the effect of old versions of the modified object files from the output file.
• Add contents of the modified object files into the space vacated, or into the padding space
when needed.
• Use the saved relocation information to patch the symbolic references in the rest of the output
file.
Under certain conditions, the incremental linker cannot perform incremental links. When this occurs,
the incremental linker automatically performs an initial incremental link to restore the process. In
the following situations, the linker automatically performs an initial incremental link of the output
file:
• Changed linker command line, where the linker command line does not match the command
line stored in the output file. (With the exceptions of the verbose and tracing options)
• Any of the padding spaces have been exhausted.
218 Improving Your Application Performance