HP-UX Linker and Libraries User's Guide
10 Improving Your Application Performance
The linker provides several ways to improve your application performance. This chapter discusses
the following topics:
DescriptionSection
Describes how the linker -O option removes unnecessary ADDIL instructions
and "dead" or unused procedures.
“Linker Optimizations” (page 202)
Describes performance improvements in Translation Lookaside Buffer (TLB)
hit rates.
“Options to Improve TLB Hit Rates” (page
217)
Describes how the linker can position your code in the object file or shared
library to improve performance.
“Profile-Based Optimization (Itanium)”
(page 217)
Describes how to improve compile performance using incremental linking.“Incremental Linking” (page 217)
Describes how to improve performance by using the global symbol table
to speed up symbol searching.
“Improving Performance with the Global
Symbol Table” (page 220)
Size Describes how to improve performance by using the -nbucket linker
option to optimize the hash table size.
“Improving Performance by Optimizing the
Hash Table Size” (page 221)
Describes how to improve performance by using function symbol aliasing.“Improving Performance with Function
Symbol Aliasing” (page 222)
Describes how to improve shared library performance by saving startup
information and bypassing the lookup process when running an
application.
“Improving Shared Library Start-Up Time
with fastbind” (page 222)
Linker Optimizations
• “Invoking Linker Optimizations from the Compile Line” (page 202)
• “Incompatibilities with other Options ” (page 203)
• “Unused Procedure Elimination with +Oprocelim” (page 203)
• “Profile-Based Optimization (PA-RISC)” (page 204)
The linker supports the -O option that performs the following optimizations at link time:
• optimizes references to data by removing unnecessary ADDIL instructions from the object
code (PA-RISC only).
• removes procedures that can never be reached.
These optimizations can be separately enabled or disabled with the +O[no]fastaccess and
+O[no]procelim options, respectively. The -O linker option simply combines enabling of these
into one option. For example, the following ld command enables linker optimizations and results
in a smaller, faster executable:
$ ld -O -o prog /usr/ccs/lib/crt0.o prog.o -lm -lc
To enable one or the other optimization only, use the appropriate +O option:
$ ld +Ofastaccess -o prog /usr/ccs/lib/crt0.o prog.o -lm -lc
$ ld +Oprocelim -o prog /usr/ccs/lib/crt0.o prog.o -lm -lc
Invoking Linker Optimizations from the Compile Line
The compilers automatically call the linker with the +Oprocelim options if compiler at all optimization
levels. For example, the following cc command invokes full compiler optimization as well as linker
optimization:
$ cc -o prog +O4 prog.c //O4 invokes +Ofastaccess and +Oprocelim
202 Improving Your Application Performance