Previous | Contents | Index |
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 on all OpenVMS platforms.) 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 the 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 I64 and 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. |
Only object files and image files of the same architecture can be combined to create an image.
OpenVMS VAX images can run as translated images on OpenVMS Alpha and I64 systems. Similarly, OpenVMS Alpha images can run translated images I64 systems, and translated images can interoperate with native OpenVMS images. For information about migrating applications from VAX to Alpha, see Migrating an Application from OpenVMS VAX to OpenVMS Alpha. For information about migrating applications from Alpha to I64, see Porting Applications from HP OpenVMS Alpha to HP OpenVMS Industry Standard 64 for Integrity Servers. |
When a language processor translates a source language program, it produces an output file that contains one or more object modules. This output file, called an object file, has the default file type of .OBJ and is the primary form of linker input. At least one object file must be specified in any link operation. An object file may be specified in the command line or in an options file.
For example, in Example 1-1, the only input file specified on the LINK command line is the object module named HELLO.OBJ (the .OBJ file type does not need to be specified because it is the default):
$ LINK HELLO |
The linker processes the entire contents of an object file, that is, every object module in the file. It cannot selectively process object modules within an object file. The linker can process object modules selectively in an object module library (.OLB) file only.
You cannot examine an object module by using a text editor. The only
way to examine an object file is by using the ANALYZE/OBJECT utility.
This utility produces a report that lists the records that make up the
object module. This report is primarily useful to compiler writers. For
information about using the ANALYZE command, see the HP OpenVMS DCL Dictionary.
1.2.2 Shareable Images as Linker Input Files
In order to execute code or reference data from a shareable image, the
image must first be referenced by another image. That is, a shareable
image can serve as input to a link operation for that image.
To provide useful input for a link operation, the shareable image offers symbols (for example, procedure names) that are external to the other input modules of the image. As a result, when the image is run, the image activator activates the shareable image at the same time so that code and data from the shareable image can be referenced.
Another method for referencing a shareable image is to dynamically activate the image by calling LIB$FIND_IMAGE_SYMBOL and passing one of its symbols. For more information, see the HP OpenVMS RTL Library (LIB$) Manual. |
A shareable image file consists of activation information, image binaries (code and data), and a symbol table. This symbol table contains definitions of universal symbols exported by the shareable image. A universal symbol is to a shareable image what a global symbol is to a module. That is, where a global symbol can be used to satisfy references external to an object module, a universal symbol can be used to satisfy references external to the shareable image.
Shareable images can provide the following benefits:
To include a shareable image in a link operation, you must specify the shareable image in an options file, identifying the input file as a shareable image by appending the /SHAREABLE qualifier to the file specification. You cannot specify a shareable image as an input file on the LINK command line. The following example illustrates an options file, named MY_OPTIONS_FILE.OPT, that contains an input file specification of the shareable image (the .EXE file type does not need to be specified because it is the default):
MY_SHARE/SHAREABLE |
The following example illustrates the LINK command in which the options file is specified. (For more information about creating and using shareable images, see Chapter 8.) Note that the default file types for the options file and the object module do not need to be specified.
$ LINK MY_MAIN_PROGRAM,MY_OPTIONS_FILE/OPTIONS |
By default, if you do not specify the device and directory in the file specification, the linker looks for shareable images in your default device and directory.
You link against shareable images in a shareable image library by specifying the library on the LINK command line or in a linker options file, identifying the file as a library by appending the /LIBRARY qualifier to the library file specification. You can include specific shareable images from the library in the link operation by appending the /INCLUDE qualifier to the library file specification, specifying which shareable images you want to include as parameters. (For more information about specifying library files in a link operation, see Section 1.2.3). By default, the linker looks for user library files in the current default directory.
Note that images that link against shareable images do not contain the
shareable image but only a reference to it. When the executable image
is activated, the image activator activates all the shareable images to
which it has been linked. By default, each image maps its own copy of
the shareable image's pages.
1.2.2.2 Installing a Shareable Image
If you install the shareable image (using the Install utility), all processes can share the same physical copy of the shareable image in memory. To take advantage of this feature, you must specify the ADD subcommand and the /SHARED qualifier on the INSTALL command line, as in the following example:
$ INSTALL ADD/SHARED WORK:[PROGRAMS]MY_SHARE.EXE |
The system creates a set of global sections for the portions of the shareable image that can be shared. The system can map these portions as global sections into the address space of multiple processes. For portions of the image that are not shareable, each process gets a private copy at image activation time. For help in creating an image on I64 systems, see Chapter 3. For similar information about Alpha and VAX systems, see Chapter 7.
If you do not install the shareable image specifying the /SHARED
qualifier, each process receives a private copy of the image. (For
information about installing images, see the HP OpenVMS System Manager's Manual.)
1.2.3 Library Files as Linker Input Files
A library file is a file produced by the Librarian utility (default
file type is .OLB). The linker accepts object module libraries and
shareable image libraries as input files.
1.2.3.1 Creating a Library File
You create a library by specifying the /CREATE qualifier with the LIBRARY command. In the following example, the object module MY_PROG.OBJ is inserted into the library MY_LIB.OLB:
$ LIBRARY/CREATE/INSERT MY_LIB MY_PROG |
A library file contains a library header and a name table. A library name table lists all of the global symbols in all of the modules and shareable images inserted in the library and associates the name of the symbol with the name of the module or shareable image in which it is defined.
Object module libraries contain copies of the object module. Shareable image libraries contain only the names of the shareable images. However, both object and shareable image libraries contain a name table, each entry associated with a definition in an object module or shareable image. Note that this is not the full symbol table of a module or a shareable image.
You cannot examine a library file using a text editor. To find out which modules a library contains, start the Librarian utility with the /LIST qualifier. The Librarian utility lists the symbols defined in these modules if you also specify the /NAMES qualifier. In the following example, the library MYMATH_LIB.OLB contains the object module MYMATHROUTS.OBJ, which contains the definitions of the symbols myadd, mysub, mydiv, and mymul:
$ LIBRARIAN/LIST/NAMES MYMATH_LIB Directory of ELF OBJECT library WORK:[PROGS]MYMATH_LIB.OLB;1 on 30-MAR-2005 09:59:06 Creation date: 30-MAR-2005 09:58:53 Creator: Librarian I01-29 Revision date: 30-MAR-2005 09:58:53 Library format: 6.0 Number of modules: 1 Max. key length: 1024 Other entries: 4 Preallocated index blocks: 213 Recoverable deleted blocks: 0 Total index blocks used: 2 Max. Number history records: 20 Library history records: 0 Module MYMATHROUTS MYADD MYDIV MYMUL MYSUB |
For more information about creating and using libraries, see the
HP OpenVMS Command Definition, Librarian, and Message Utilities Manual.
1.2.3.2 Including a Library File in a Link Operation
You can specify a library file in a link operation in any of the following ways:
A symbol table file is the product of a previous link operation or a language processor. A symbol table file is similar to an object module but it contains only a symbol table.
For VAX linking, you can specify a symbol table file as input in a link operation as you would any other object module, as in the following example:
$ LINK MY_MAIN_PROGRAM, MY_SYMBOL_TABLE |
For I64 and Alpha linking, you cannot specify a symbol table as input in a link operation. |
The linker processes the symbol table file during symbol resolution. If the symbol table file is the by-product of a link operation in which an executable image or system image was created, the symbol table contains the names and values of every global symbol in the image. If the symbol table file is associated with a shareable image, it contains by default the names and values of the symbols in the image declared as universal.
For a symbol table file to be useful in link opertions, the values associated with the symbols in the symbol table file must be constants. The value of symbols that represent addresses, such as a procedure entry point, can vary each time the image is activated (unless the image is based).
Note also that a symbol table file associated with a shareable image should not be specified as an input file in a link operation in place of the shareable image. The shareable image itself must be specified as input because the linker requires more information than can be found in a symbol table file, such as the memory requirements of the shareable image (contained in the image header).
Symbol table files created by the linker during I64 and Alpha links can
be used as an aid to debugging with the System Dump Analyzer utility
(SDA).
1.2.5 Options Files as Linker Input Files
An options file is a standard text file you must use to specify linker options and shareable images specified as input files. You cannot specify linker options or shareable images on the LINK command line. Linker options, similar to linker qualifiers, allow you to control various aspects of the linker operation. Part 4 includes descriptions of the options supported by the linker.
In addition, you can use options files to perform the following tasks:
When creating a linker options file, keep in mind the following restrictions:
Example 1-2 illustrates an options file, named PROJECT3.OPT, that contains both input file specifications and linker options.
Example 1-2 Sample Linker Options File |
---|
MOD1.OBJ,MOD7.OBJ,LIB3.OLB/LIBRARY,- LIB4/LIBRARY/INCLUDE=(MODX,MODY,MODZ),- MOD12.OBJ/SELECTIVE_SEARCH STACK=75 SYMBOL=JOBCODE,5 |
To use an options file in a link operation, specify the name of the options file on the command line, identifying the file as an options file by appending the linker qualifier /OPTIONS to the file specification (the .OPT file type does not need to be specified because it is the default), as in the following example:
$ LINK PROGA,PROGB,PROJECT3/OPTIONS |
If you precede the link operation with the SET VERIFY command, DCL displays the contents of the options file as the file is processed.
If you want to use an options file in a command procedure or interactively on the command line, specify the input file as the logical name SYS$INPUT, appending the /OPTIONS qualifier to the logical name. DCL interprets the lines immediately following the LINK command as the contents of the options file. The following example illustrates a LINK command in a command procedure:
$ ! LINK command $ LINK MAIN,SUB1,SYS$INPUT/OPTIONS MYPROC/SHAREABLE SYS$LIBRARY:APPLPCKGE/SHAREABLE STACK=75 $ |
When you specify SYS$INPUT as an interactive options file, you must terminate the options file by entering the Ctrl/Z key sequence, as in the following example:
$ LINK MAIN,SUB1,SUB2,SYS$INPUT:/OPTIONS MYPROC/SHAREABLE SYS$LIBRARY:APPLPCKGE/SHAREABLE STACK=75 [Ctrl/Z] |
HP recommends using command procedures to invoke the LINK command because it enables you to keep both the LINK command and all input file specifications, including any options files, together in a single file. To perform a link operation using a command procedure, simply invoke the command procedure, as in the following example:
$ @LINKPROC |
Previous | Next | Contents | Index |