Summary information about library usage and loading can be obtained by passing additional options to the linker through the LD_OPTIONS environment variable. The compiler calls the linker with these options (and others it requires) when generating object binary files.
Using the compiler to call the linker is always recommended over calling the linker directly because many compiler options require specific linker options or library references, and linking without these could produce unpredictable results.
demo% setenv LD_OPTIONS ’–m -Dfiles’ demo% f95 -o myprog myprog.f Example: Using LD_OPTIONS to create a load map: |
Some linker options do have compiler command-line equivalents that can appear directly on the f95 command. These include -Bx, -dx, -G, -hname, -Rpath, and -ztext. See the f95(1) man pages or the Fortran User’s Guide for details.
More detailed examples and explanations of linker options and environment variables can be found in the Solaris Linker and Libraries Guide.
The linker -m option generates a load map that displays library linking information. The routines linked during the building of the executable binary program are listed together with the libraries that they come from.
Example: Using –m to generate a load map:
demo% setenv LD_OPTIONS ’-m’ demo% f95 any.f any.f: MAIN: LINK EDITOR MEMORY MAP output input virtual section section address size .interp 100d4 11 .interp 100d4 11 (null) .hash 100e8 2e8 .hash 100e8 2e8 (null) .dynsym 103d0 650 .dynsym 103d0 650 (null) .dynstr 10a20 366 .dynstr 10a20 366 (null) .text 10c90 1e70 .text 10c90 00 /opt/SUNWspro/lib/crti.o .text 10c90 f4 /opt/SUNWspro/lib/crt1.o .text 10d84 00 /opt/SUNWspro/lib/values-xi.o .text 10d88 d20 sparse.o ... |
Additional linker debugging features are available through the linker’s -Dkeyword option. A complete list can be displayed using -Dhelp.
Example: List linker debugging aid options using the -Dhelp option:
demo% ld -Dhelp … debug: args display input argument processing debug: bindings display symbol binding; debug: detail provide more information debug: entry display entrance criteria descriptors … demo% |
For example, the -Dfiles linker option lists all the files and libraries referenced during the link process:
demo% setenv LD_OPTIONS ’-Dfiles’ demo% f95 direct.f direct.f: MAIN direct: debug: file=/opt/SUNWspro/lib/crti.o [ ET_REL ] debug: file=/opt/SUNWspro/lib/crt1.o [ ET_REL ] debug: file=/opt/SUNWspro/lib/values–xi.o [ ET_REL ] debug: file=direct.o [ ET_REL ] debug: file=/opt/SUNWspro/lib/libM77.a [ archive ] debug: file=/opt/SUNWspro/lib/libF77.so [ ET_DYN ] debug: file=/opt/SUNWspro/lib/libsunmath.a [ archive ] … |
See the Linker and Libraries Guide for further information on these linker options.
Ensuring a consistent choice of compiling and linking options is critical whenever compilation and linking are done in separate steps. Compiling any part of a program with some options requires linking with the same options. Also, a number of options require that all source files be compiled with that option, including the link step.
The option descriptions in the Fortran User’s Guide identify such options.
Example: Compiling sbr.f with -fast, compiling a C routine, and then linking in a separate step:
demo% f95 -c -fast sbr.f demo% cc -c -fast simm.c demo% f95 -fast sbr.o simm.o link step; passes -fast to the linker |