| United States-English |
|
|
|
![]() |
HP-UX Linker and Libraries User's Guide: HP 9000 Computers > Chapter 8 Ways to Improve Performance Linker Optimizations |
|
The linker supports the -O option which performs the following optimizations at link time:
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:
To enable one or the other optimization only, use the appropriate +O option:
The compilers automatically call the linker with the +Ofastaccess and +Oprocelim options if compiler optimization level 4 is selected. For example, the following cc command invokes full compiler optimization as well as linker optimization:
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:
For a brief description of compiler optimization options see “Selecting an Optimization Level with PBO ”. For a complete description, see your compiler manuals or online help. The -O, +Ofastaccess, and +Oprocelim options are incompatible with these linker options:
The linker issues a warning when such conflicts occur. If you require any of these features, do not use the linker optimization options. Unused or "dead" procedure elimination is the process of removing unreferenced procedures from the $TEXT$ space 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 a per subspace basis. That is, only entire subspaces are removed and only if all procedures in the subspace are unreferenced. Typically, if a relocatable link (ld -r) has not been performed and the code is not written in assembly, every procedure is in its own subspace. Relocatable links may merge subspaces. Merged subspaces can prevent the removal of dead procedures. Therefore, it is optimal to have each procedure in its own subspace. For complete executables, dead procedure elimination removes any text subspaces that are not referenced from another subspace. Self references, such as recursive procedures or subspaces with multiple procedures that call each other, are not considered outside references and are therefore candidates for removal. If the address of a procedure is taken, the subspace within which it resides is not removed. If a subspace is referenced in any way by a fixup representing a reference other than a PC-relative call or an absolute call it is not removed. For incomplete executables, dead procedure elimination works the same as for complete executables except that no exported symbols or their dependencies are removed. If an incomplete executable contains a symbol that is to be referenced by a shared library and is not exported, it is removed if the other conditions discussed above hold. In shared libraries only symbols that are not referenced and not exported are removed. In shared libraries all symbols that are not of local scope are exported. Therefore only locally scoped symbols not referenced are removed. When performing a relocatable link with the -r option, dead procedure elimination is disabled since the only possible gain would be the removal of unreferenced local procedures. Objects resulting from a relocatable link are subject to dead procedure elimination upon a final link. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||