If invoked with +O4, the compilers generate object code in such a way that code optimization is done at link time. Thus, the linker does a better job of optimizing code that was compiled with +O4.
When the compile and link phases are invoked by separate commands, specify +O4 on both command lines. For example:
$ cc | prog.c | //invokes compiler optimizations |
$ cc | prog +O4 prog.o | //invokes linker optimizations |
|
|
|
NOTE: You can also invoke linker optimizations at levels 2 and 3 by using the +Ofastaccess or +Oprocelim option.
For a brief description of compiler optimization options, see “Optimizing Based on Profile Data
Incompatibilities with other Options
The
These options have no effect on | |
| libraries with ld |
|
|
(PA32 only) Dynamic linking is incompatible with | |
|
|
Relocatable linking is incompatible with | |
|
|
Setting the offset of the data space is incompatible with | |
|
|
The linker issues a warning when such conflicts occur. If you require any of these features, do not use the linker optimization options.
Unused Procedure Elimination with +Oprocelim
Unused or "dead" procedure elimination is the process of removing unreferenced procedures from the $TEXT$ space (or .text section in the case of ELF object file) of an executable or shared library to reduce the size of the program or library.
Dead procedure elimination is performed after all symbols have been resolved prior to any relocation. It works on the basis of per subspace (per section in the case of ELF object file). That is, only entire subspaces are removed and only if all procedures in the subspace are unreferenced. Typically, if a relocatable link (ld
Along with dead procedures, the +Oprocelim option removes unreferenced data and debug information associated with the dead procedures.
If your program does symbol binding at
The +Onoprocelim is the default procelim option in linker. Compilers often automatically pass +Oprocelim to the linker for higher levels of optimization. For more information on when compilers automatically pass +Oprocelim to the linker for higher levels of optimization, refer the Compiler documentation.
Complete Executables
For complete executables, dead procedure elimination removes any text subspaces that are not referenced from another subspace.
Linker Optimizations 203