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% f77 -o myprog myprog.f
Some linker options do have compiler command-line equivalents that can appear directly on the f77 or f90 command. These include -Bx, -dx, -G, -hname, -Rpath, and -ztext. See the f77(1) and f90(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% f77 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/SC5.0/lib/crti.o .text 10c90 f4 /opt/SUNWspro/SC5.0/lib/crt1.o .text 10d84 00 /opt/SUNWspro/SC5.0/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% f77 direct.f direct.f: MAIN direct: debug: file=/opt/SUNWspro/SC5.0/lib/crti.o [ ET_REL ] debug: file=/opt/SUNWspro/SC5.0/lib/crt1.o [ ET_REL ] debug: file=/opt/SUNWspro/SC5.0/lib/values-xi.o [ ET_REL ] debug: file=direct.o [ ET_REL ] debug: file=/opt/SUNWspro/SC5.0/lib/libM77.a [ archive ] debug: file=/opt/SUNWspro/lib/libF77.so [ ET_DYN ] debug: file=/opt/SUNWspro/SC5.0/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 any of the following options requires linking with the same options:
-a, -autopar, -Bx, -fast, -G, -Lpath, -lname,-mt, -nolib, -norunpath, -p, -pg, -xlibmopt, -xlic_lib=name, -xprofile=p
Example: Compiling sbr.f with -a and smain.f without it, then linking in separate steps (-a invokes tcov old style profiling):
demo% f77 -c -a sbr.f demo% f77 -c smain.f demo% f77 -a sbr.o smain.o {link step; pass -a to the linker}
Also, a number of options require that all source files be compiled with that option. These include:
-autopar, -cg92, -dx, -dalign, -dbl, -explicitpar, -f, -misalign, -native, -parallel, -pentium, -PIC, -pic, -xarch=a, -xcache=c, -xchip=c, -xF, -xtarget=t, -ztext
See the f77(1) and f90(1) man pages and the Fortran User's Guide for details on all compiler options.