| United States-English |
|
|
|
![]() |
HP-UX Linker and Libraries User's Guide: HP 9000 Computers > Chapter 3 Linker TasksUsing 64-bit Mode Linker Options |
|
This section introduces 64-bit-only linker options. In the HP-UX 11.0 release, the linker toolset supports extended features for linking in 64-bit mode. Since compatibility with the previous linker toolset is a high priority, the 64-bit linker uses much of the old behavior in the new toolset. The 64-bit mode linker includes two options to allow you to instruct the linker to link in one of two modes:
The +compat option instructs the linker to do a 32-bit-style link. When you use the +compat option, the linker:
At runtime, the dynamic loader does a 32-bit style load for all compatibility mode dependent shared libraries. The dynamic loader:
The +std option instructs the linker to do a standard mode 64-bit style link. This is currently the default in 64-bit mode. This default may change in future releases. When you use +std, the linker:
At runtime, the dynamic loader does a 64-bit-style load for all standard mode dependent shared libraries. The dynamic loader:
Use the -dynamic option to instruct the linker to look for shared libraries first and then archive libraries. The linker outputs a dynamically linked executable. This option is on by default in standard mode. In the following example, the linker only looks for shared libraries:
If you specified an archive library, the linker links it in, but the resulting executable is still a dynamically linked executable. This is true even if the linker finds no shared libraries at link time. Use the -noshared option if you need to link with all archive libraries. The linker outputs a statically bound executable.
In the following example, the linker only looks for /usr/lib/pa20_64/libfoo.a and /usr/lib/pa20_64/libc.a:
If you specify a shared library with this option, the linker emits an error message.
Use the +[no]forceload option to control how the linker loads object files from an archived library. +forceload instructs the linker to load all object files from an archive library. +noforceload tells the linker to only load those modules from an archive library that is needed. The mode you select, either by default or explicitly, remains on until you change it. +noforceload is the default on both 32-bit and 64-bit modes. In the following example, main() references foo(), which is a module in mylib.a. foo() doesn't reference any other module in mylib.a and libc.a. If mylib.a contains foo.o and bar.o, then only foo.o is linked in.
Use the +allowunsats option to instruct the linker to not flag unsatisfied symbols at link time. This is the default for relocatable (-r) and shared library builds (-b), and is the default behavior in 32-bit mode. Use the +noallowunsat option to instruct the linker to flag as an error any unsatisfied symbol in the resulting output file. The linker still creates a.out, but the file does not have any execute permission bits set. This is the default for program files (same behavior as in 32-bit mode). For example, where main() references functions foo() and bar(). bar() resides in libbar.sl. foo() resides in libfoo.sl
+allowunsats still causes the linker to emit a warning message and output a.out. If you do not specify the option and the linker finds an unsatisfied symbol, the linker emits an error message and an unexecutable a.out only if linking with +compat set.
Use the +hideallsymbols option to hide all symbols to prevent the linker from exporting them in a shared link. In the following example, main() exports func() and test(). Using +hideallsymbols, the linker does not export these two routines in the a.out.
The linker automatically maps sections from input object files onto output segments in executable files. These options to the ld command allow you to change the linker's default mapping. Use the -k filename option to provide a memory map. The linker uses the file specified by filename as the output file memory map. The +nodefaultmap option used with -k option prevents the linker from concatenating the default memory map to the map provided by filename. If you specify +nodefaultmap, the linker does not append the default mapfile to your mapfile. If you do not specify +nodefaultmap with -k, the linker appends the output file to the default mapfile.
For more information on mapfiles and examples using these options, see Appendix A “Using Mapfiles”. Use the +noenvvar to instruct the dynamic loader not to look at the environment variables relating to dynamic path searching at runtime. It ignores LD_LIBRARY_PATH and SHLIB_PATH environment variables. This option is on by default in with ld +compat. It is off by default with ld +std. For example, if libbar.sl has dependent library libfee.sl that is i ./ at link time, but is moved to /tmp by runtime:
Use the +std option to instructs the linker to do a 64-bit mode link. This is the default mode. For more information, see “Using the 64-bit Mode Linker with +compat or +std”. Use the +compat option to instruct the linker to do a 32-bit mode style link. For more information, see “Using the 64-bit Mode Linker with +compat or +std”. Use the +stripunwind option to suppress output of the unwind table.
Use the +vtype option to get verbose output about specified elements of the link operation. The following values specify the type:
In 32-bit mode, you must always include crt0.o on the link line. In 64-bit mode, you must include crt0.o on the link line for all fully archive links (ld -noshared) and in compatibility mode (+compat). You do not need to include the crt0.o startup file on the ld command line for shared bound links. In 64-bit mode, the dynamic loader, dld.sl, does some of the startup duties previously done by crt0.o. See “The crt0.o Startup File”, and crt0(3) manual page for more information. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||