HP OpenVMS Systems Documentation |
OpenVMS Linker Utility ManualOrder Number: AA--PV6CD--TK
April 2001
This manual describes the OpenVMS Linker utility. Revision/Update Information: This manual supersedes the OpenVMS Linker Utility Manual, Version 7.1 Software Version: OpenVMS Alpha Version 7.3 OpenVMS VAX Version 7.3
© 2001 Compaq Computer Corporation Compaq, VAX, VMS, and the Compaq logo Registered in U.S. Patent and Trademark Office. OpenVMS is a trademark of Compaq Information Technologies Group, L.P. in the United States and other countries. UNIX is a trademark of The Open Group. All other product names mentioned herein may be the trademarks or registered trademarks of their respective companies. Confidential computer software. Valid license from Compaq required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this document is provided "as is" without warranty of any kind and is subject to change without notice. The warranties for Compaq products are set forth in the express limited warranty statements accompanying such products. Nothing herein should be construed as constituting an additional warranty.
ZK4548 The Compaq OpenVMS documentation set is available on CD-ROM.
PrefaceIntended AudienceProgrammers at all levels of experience can use this manual effectively. Document StructureThis book has two parts and two appendixes. Part 1 includes five chapters that describe the linker. Part 2 is a reference section that describes the LINK command and its qualifiers and options. The appendixes contain the VAX Object Language specification and the Alpha Object Language specification. (The appendixes are primarily useful to compiler developers.) In Part 1, Chapter 1 introduces the OpenVMS Linker utility and how to use the LINK command and its qualifiers and parameters. Chapter 2 describes how the linker resolves symbolic references among input files. Chapter 3 describes how the linker creates image files. Chapter 4 describes how to create shareable images and use them in link operations. Chapter 5 describes how to interpret image map files. Related DocumentsFor information on including the debugger in the linking operation and on debugging in general, see the OpenVMS Debugger Manual. For additional information about Compaq OpenVMS products and services, access the Compaq website at the following location:
Reader's CommentsCompaq welcomes your comments on this manual. Please send comments to either of the following addresses:
How To Order Additional DocumentationVisit the following World Wide Web address for information about how to order additional documentation:
If you need help deciding which documentation best meets your needs, call 800-282-6672. ConventionsThe following conventions are used in this manual:
Part 1
|
Example 1-1 Hello World! Program (HELLO.C) |
---|
#include <studio.h> main() { printf("Hello World!\n"); } |
To run this program, you must first compile the source file to create an object module. To compile the example, written in C, invoke the appropriate C compiler to create an object module, as in the following example:
$ CC HELLO |
During compilation, the compiler translates the statements in the source file into machine instructions and groups portions of the program into program sections according to their memory use and other characteristics. In addition, the compiler lists all the global symbols defined in the module and referenced in the module in the global symbol directory (GSD). For example, in Example 1-1, the printf routine is referenced in the module but is not defined in it.
To create an executable image, you must then link the object file produced by the compiler, as in the following example:
$ LINK HELLO |
In the link operation, you must specify as input files all the modules required to create the image. For example, you must include the C Run-Time Library in the link of the program in Example 1-1 to resolve the reference to the printf routine.
For Alpha linking, the linker processes the C Run-Time Library shareable image [DECC$SHARE] by default because it resides in the default system shareable image library [IMAGELIB.OLB]. See Section 2.2.3.3 for more information about how the linker processes default system libraries.
For VAX linking, you must specify the C run-time shareable image [VAXCRTL] as an input file in the link operation explicitly, as in the following example:
$ LINK HELLO, SYS$INPUT/OPT SYS$LIBRARY:VAXCRTL/SHARE [Ctrl/Z] |
(For more information about linking against the C Run-Time Library for VAX images, see the VAX C compiler documentation.)
The linker processes the input files you specify in two passes. In its first pass through the input files, the linker resolves symbolic references between the modules. Because the linker processes different types of input files in different ways, the order in which you specify input files can affect symbol resolution. Chapter 2 provides more information about this topic.
After performing symbol resolution, when the linker has determined all the input modules necessary to create the image, the linker determines the memory requirements of the image based on the memory requirements of each object module. The compilers have specified the memory requirements of the object modules as program section specifications. The linker gathers together program sections with similar attributes into image sections. (Chapter 3 provides more information about image creation.) At run time, the image activator reads the memory requirements of the image by processing the list of image section descriptors (ISDs) the linker has stored in the image header.
If the image that results from the link operation is an executable image, it can be executed at the DCL command line. The following example illustrates how to execute the program in Example 1-1:
$ RUN HELLO Hello World! |
Note that a LINK command required to create a real application, unlike the Hello World! example, can involve specifying hundreds of input files of various types.
As with most other DCL commands, the LINK command supports numerous
qualifiers with which you can control various aspects of a link
operation. The linker also supports linker options,
which you can use to further control a link operation. Linker options
must be specified in an options file, which is then specified as an
input file in a link operation. Section 1.2.5 describes the benefits of
using options files and describes how to create them. Part 2
provides reference descriptions of all the qualifiers and options
supported by the linker. Section 1.5 contains a summary table of these
qualifiers and options.
1.2 Specifying Input to the Linker
You specify the files you want the linker to process on the LINK command line or in a linker options file. (Library files may also be specified as a user library, which the linker processes by default.) You must specify at least one input file in every link operation and, in every link operation, at least one input file must be an object module. Table 1-1 lists the different types of input files accepted by the linker, along with their default file types. (The defaults are used for both VAX and Alpha linking.) The table also describes how you can specify the file in a link operation.
File | Default File Type |
Description |
---|---|---|
Object file | .OBJ | Created by a language processor. May be specified on LINK command line or in a linker options file. This is the default input file accepted by the linker. |
Shareable image | .EXE | Produced by a previous link operation. Must be specified in a linker options file; you cannot specify a shareable image as an input file on the command line. Identify the input file as a shareable image by appending the /SHAREABLE qualifier to the file specification. |
Library file | .OLB | Produced by the Librarian utility. May contain object modules or shareable images. May be specified on the LINK command line, in a linker options file, or as a default user library processed by the linker. Identify the input file as a library file by appending the /LIBRARY qualifier to the library file specification. You can also include specific modules from a library in a link operation by appending the /INCLUDE qualifier to the library file specification. |
Symbol table file | .STB |
Produced by a previous link operation or a language processor. May be
specified on the LINK command line or in an options file. Because a
symbol table file is processed as an object module, it requires no
identifying qualifier.
Note that symbol table files produced by the linker during Alpha links cannot be specified as input files in a link operation. They are intended to be used only as an aid to debugging with the System Dump Analyzer utility (See Section 1.2.4 for more information.) |
Options file | .OPT | Text file containing link option specifications or link input file specifications. May be specified only on the command line; you cannot specify an options file inside another options file. Identify the input file as an options file by appending the /OPTIONS qualifier to the end of the file specification. |
You must specify only native OpenVMS Alpha object modules and shareable images as input files when creating an OpenVMS Alpha image. The same holds true when building an OpenVMS VAX image. (Note, however, that OpenVMS VAX images can run as translated images on OpenVMS Alpha systems, and translated images can interoperate with native OpenVMS Alpha images. See Migrating an Application from OpenVMS VAX to OpenVMS Alpha1 for more information.)
1 This manual has been archived but is available on the OpenVMS documentation CD-ROM. |
Next | Contents | Index |