HP OpenVMS Systems Documentation |
OpenVMS Linker Utility Manual
2.3.2 Controlling Cluster CreationYou can control in which cluster the linker places an input file by using either of the following linker options:
2.3.2.1 Using the CLUSTER= Option to Control ClusteringThe CLUSTER= option causes the linker to create a named cluster and to place in the cluster the object modules specified in the option. (The linker puts shareable images in their own clusters by default.) For example, you can use the CLUSTER= option to fix the link operation illustrated in Section 2.2.4, where the link failed because a shareable image was processed selectively. To make the linker process the object module MY_MAIN.OBJ before it processes the shareable image MY_MAIN.EXE, put the object module in a named cluster. In the following example, the /EXECUTABLE qualifier is specified on the command line to specify the name of the resultant image, because MY_MAIN is not specified on the command line.
The Object Module Synopsis section of the image map file verifies that the linker processed the object module MY_MAIN before it processed the shareable image MY_MATH, as in the following map file excerpt:
2.3.2.2 Using the COLLECT= Option to Control ClusteringYou can also create a named cluster by specifying the COLLECT= option. The COLLECT= option directs the linker to put specific program sections in a named cluster. The linker creates the cluster if it does not already exist. Note that the COLLECT= option manipulates program sections, not input files.
The linker sets the global (GBL) attribute of the program sections
specified in a COLLECT= option to enable a global search for the
definition of that program section.
For VAX linking, you link against the OpenVMS executive by specifying the system symbol table (SYS$LIBRARY:SYS.STB) in the link operation. Because a symbol table file is an object module, the linker processes the symbol table file as it would any other object module. For Alpha linking, you link against the OpenVMS executive by specifying the /SYSEXE qualifier. When this qualifier is specified, the linker selectively processes the system shareable image, SYS$BASE_IMAGE.EXE, located in the directory pointed to by the logical name ALPHA$LOADABLE_IMAGES. The linker does not process SYS$BASE_IMAGE.EXE by default. Note that, because the linker is processing a shareable image, references to symbols in the OpenVMS executive are fixed up at image activation, not fully resolved at link time as they are for VAX linking. Also note that the linker looks for SYS$BASE_IMAGE.EXE in the directory pointed to by the logical name ALPHA$LOADABLE_IMAGES, not in the directory pointed to by the logical name SYS$LIBRARY as for VAX linking. When the /SYSEXE qualifier is specified, the linker processes the file selectively. To disable selective processing, specify the /SYSEXE=NOSELECTIVE qualifier. For more information about using the /SYSEXE qualifier, see the description of the qualifier in Part 2.
Relation to Default Library Processing
When you specify the /SYSEXE qualifier, the linker processes the SYS$BASE_IMAGE.EXE file after processing the system shareable image library, IMAGELIB.OLB, and before processing the system object library, STARLET.OLB. (Note that the linker also processes the system service shareable image, SYS$PUBLIC_VECTORS.EXE, when it processes STARLET.OLB by default.) The /SYSSHR and /SYSLIB qualifiers, which control processing of the default system libraries, do not affect SYS$BASE_IMAGE.EXE processing. When the /NOSYSSHR qualifier is specified with the /SYSEXE qualifier, the linker does not process IMAGELIB.OLB, but still processes SYS$BASE_IMAGE.EXE and then STARLET.OLB and SYS$PUBLIC_VECTORS.EXE. When /NOSYSLIB is specified, the linker does not process IMAGELIB.OLB, STARLET.OLB, or SYS$PUBLIC_VECTORS, but still processes SYS$BASE_IMAGE.EXE. To process SYS$BASE_IMAGE.EXE before the shareable images in IMAGELIB.OLB, specify SYS$BASE_IMAGE.EXE in a linker options file as you would any other shareable image. If you specify SYS$BASE_IMAGE.EXE in your options file, do not use the /SYSEXE qualifier. Figure 2-4 illustrates how the /SYSEXE qualifier, in combination with the /SYSSHR and /SYSLIB qualifiers, can affect linker processing. (The default syntax illustrated in the figure is rarely specified.) Figure 2-4 Linker Processing of Default Libraries and SYS$BASE_IMAGE.EXE 2.5 Defining Weak and Strong Global SymbolsIn the dialects of MACRO, BLISS, and Pascal supported on both VAX and Alpha systems, you can define a global symbol as either strong or weak, and you can make either a strong or a weak reference to a global symbol. In these languages, all definitions and references are strong by default. To make a weak definition or a weak reference, you must use the .WEAK assembler directive (in MACRO), the WEAK attribute (in BLISS), or the WEAK_GLOBAL or WEAK_EXTERNAL attribute (in Pascal). The linker records each symbol definition and each symbol reference in its global symbol table, noting for each whether it is strong or weak. The linker processes weak references differently from strong references and weakly defined symbols differently from strongly defined symbols. A strong reference can be made to a weakly defined symbol or to a strongly defined symbol. For a strong reference, the linker checks all explicitly specified input modules and libraries and all default libraries for a definition of the symbol. In addition, if the linker cannot locate the definition needed to resolve the strong reference, it assigns the symbol a value of 0 and reports an error. By default, all references are strong. A weak reference can be made to a weakly defined symbol or to a strongly defined symbol. In either case, the linker resolves the weak reference in the same way it does a strong reference, with the following exceptions:
One purpose of making a weak reference arises from the need to write and test incomplete programs. The resolution of all symbolic references is crucial to a successful linking operation. Therefore, a problem arises when the definition of a referenced global symbol does not yet exist (as would be the case, for example, if the global symbol definition is an entry point to a module that is not yet written). The solution is to make the reference to the symbol weak, which informs the linker that the resolution of this particular global symbol is not crucial to the link operation. By default, all global symbols in all VAX and Alpha languages have a strong definition. A strongly defined symbol in a library module is included in the library symbol table; a weakly defined symbol in a library module is not. As a result, if the module containing the weak symbol definition is in a library but has not been specified for inclusion by means of the /INCLUDE qualifier, the linker will not be able to resolve references (strong or weak) to the symbol. If, however, the linker has selected that library module for inclusion (in order to resolve a strong reference), it will be able to resolve references (strong or weak) to the weakly defined symbol. If the module containing the weak symbol definition is explicitly specified either as an input object file or for extraction from a library (by means of the /INCLUDE qualifier), the weak symbol definition is as available for symbol resolution as a strong symbol definition.
Chapter 3
|
Attribute | Keyword | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Alignment | -- |
Specifies the alignment of the program section as an integer that
represents the power of 2 required to generate the desired alignment.
For certain alignments, the linker supports keywords to express the
alignment. The following table lists all the alignments supported by
the linker with their keywords:
|
||||||||||||||||||||||||||||||||||||
Position Independence | PIC/NOPIC | Specifies that the program section can run anywhere in virtual address space. Applicable in shareable images only. Note that this attribute is not meaningful for Alpha images, but it is still used to sort program sections. | ||||||||||||||||||||||||||||||||||||
Overlaid/Concatenated | OVR/CON | When set to OVR, specifies that the linker may combine (overlay) this program section with other program sections with the same name and attribute settings. Program sections that are overlaid are assigned the same base address. When set to CON, the linker concatenates the program sections. | ||||||||||||||||||||||||||||||||||||
Relocatable/Absolute | REL/ABS | When set to REL, specifies that the linker can place the program section anywhere in virtual memory, according to the memory allocation strategy for the type of image being produced. When set to ABS, this attribute specifies that the program section is an absolute program section that contains no binary data or code and appears to be based at virtual address 0. Absolute program sections are used by compilers primarily to define constants. | ||||||||||||||||||||||||||||||||||||
Global/Local | GBL/LCL | When set to GBL, specifies that the linker should gather contributions to the program section from all clusters and place them in the same image section. When set to LCL, the linker gathers program sections into the same image section only if they are in the same cluster. The memory for a global program section is allocated in the cluster that contains the first contributing module. | ||||||||||||||||||||||||||||||||||||
Shareability | SHR/NOSHR | Specifies that the program section can be shared between several processes. Only used to sort program sections in shareable images. | ||||||||||||||||||||||||||||||||||||
Executability | EXE/NOEXE | Specifies that the program section contains executable code. If an image transfer address is defined in a nonexecutable program section, the linker issues a diagnostic message. | ||||||||||||||||||||||||||||||||||||
++For Alpha linking, the EXE attribute is propagated to the image section descriptor where it is used by the Install utility when it is installing the image as a resident image. (For information about resident images, see the description of the /SECTION_BINDING qualifier in Part 2.) | ||||||||||||||||||||||||||||||||||||||
Writability | WRT/NOWRT | Specifies that the contents of a program section can be modified at run time. | ||||||||||||||||||||||||||||||||||||
Protected Vectors | VEC/NOVEC | Specifies that the program section contains privileged change-mode vectors or message vectors. In shareable images, image sections with the VEC attribute are automatically protected. | ||||||||||||||||||||||||||||||||||||
Solitary | SOLITARY | Specifies that the linker should place this program section in its own image section. Useful for programs that map data into specific locations in their virtual memory space. Note that compilers do not set this attribute. You can set this attribute using the PSECT_ATTR= option. | ||||||||||||||||||||||||||||||||||||
++Unmodified | NOMOD/MOD | When set, specifies that the program section has not been initialized (NOMOD). On Alpha systems, the linker uses this attribute to create demand zero sections; see Section 3.4.3. Only compilers can set this attribute. You can clear this attribute only by specifying the MOD keyword in the PSECT_ATTR= option. | ||||||||||||||||||||||||||||||||||||
++COM | -- | Used by the Compaq C compiler to implement the relaxed symbol reference/definition model for external variables. See the C documentation for more information. This attribute cannot be modified using the PSECT_ATTR= option. | ||||||||||||||||||||||||||||||||||||
Readability | RD | Reserved by Compaq. | ||||||||||||||||||||||||||||||||||||
User/Library | USR/LIB | Reserved by Compaq. To ensure future compatibility, this attribute should be clear. |
To illustrate program section creation, consider the program sections created by the VAX C compiler when it processes the sample programs in the following examples.
Example 3-1 Sample Program MYTEST.C |
---|
extern int global_data; int myadd(); int mysub(); main() { int num1, num2, res1, res2; static int my_data; num1 = 5; num2 = 6; res1 = myadd( num1, num2 ); res2 = mysub( num1, num2 ); printf("res1 = %d, res2 =%d, globaldata=%d\n", res1,res2,global_data); } |
Example 3-2 Sample Program MYADD.C |
---|
#include <stdio.h> myadd(value_1,value_2) int value_1; int value_2; { int result; static int add_data; printf("In MYADD.C\n"); result = value_1 + value_2; return( result ); } |
Example 3-3 Sample Program MYSUB.C |
---|
int global_data = 5; mysub(value_1,value_2) int value_1; int value_2; { int result; static int sub_data; result = value_1 - value_2; return( result ); } |
To see what program sections the VAX C compiler creates for these programs, use the ANALYZE/OBJECT utility to examine the global symbol directory (GSD) in each object module. (Note that the names the language processors assign to program sections are architecture specific.)
Example 3-4 presents an excerpt from the analysis of the object module MYTEST.OBJ. Only the program section definitions are included in the excerpt.
Example 3-4 Program Sections Generated by Example 3-1 |
---|
4. GLOBAL SYMBOL DIRECTORY (OBJ$C_GSD), 138 bytes . . . 6) Program Section Definition (GSD$C_PSC) (1) alignment: 4-byte boundary <-- psect 0 (2) attribute flags: (0) GPS$V_PIC 1 (1) GPS$V_LIB 0 (2) GPS$V_OVR 0 (3) GPS$V_REL 1 (4) GPS$V_GBL 0 (5) GPS$V_SHR 1 (6) GPS$V_EXE 1 (7) GPS$V_RD 1 (8) GPS$V_WRT 0 (9) GPS$V_VEC 0 (3) allocation: 63 (%X'0000003F') (4) symbol: "$CODE" 7) Program Section Definition (GSD$C_PSC) alignment: 4-byte boundary <-- psect 1 attribute flags: (0) GPS$V_PIC 1 (1) GPS$V_LIB 0 (2) GPS$V_OVR 0 (3) GPS$V_REL 1 (4) GPS$V_GBL 0 (5) GPS$V_SHR 0 (6) GPS$V_EXE 0 (7) GPS$V_RD 1 (8) GPS$V_WRT 1 (9) GPS$V_VEC 0 allocation: 4 (%X'00000004') symbol: "DATA" 8) Program Section Definition (GSD$C_PSC) alignment: 4-byte boundary <-- psect 2 attribute flags: (0) GPS$V_PIC 1 (1) GPS$V_LIB 0 (2) GPS$V_OVR 1 (3) GPS$V_REL 1 (4) GPS$V_GBL 1 (5) GPS$V_SHR 1 (6) GPS$V_EXE 0 (7) GPS$V_RD 1 (8) GPS$V_WRT 1 (9) GPS$V_VEC 0 allocation: 4 (%X'00000004') symbol: "GLOBAL_DATA" 9) Program Section Definition (GSD$C_PSC) alignment: 4-byte boundary <-- psect 3 attribute flags: (0) GPS$V_PIC 1 (1) GPS$V_LIB 0 (2) GPS$V_OVR 0 (3) GPS$V_REL 1 (4) GPS$V_GBL 0 (5) GPS$V_SHR 0 (6) GPS$V_EXE 0 (7) GPS$V_RD 1 (8) GPS$V_WRT 1 (9) GPS$V_VEC 0 allocation: 36 (%X'00000024') symbol: "$CHAR_STRING_CONSTANTS" . . . |
Previous | Next | Contents | Index |