VSI OpenVMS Linker Utility Manual

Document Number: DO–DLKRRM–01A
Publication Date: May 2024
Operating System and Version:
VSI OpenVMS IA-64 Version 8.4-1H1 or higher
VSI OpenVMS Alpha Version 8.4-2L1 or higher
VSI OpenVMS x86-64 Version 9.2-1 or higher

Preface

1. About VSI

VMS Software, Inc. (VSI) is an independent software company licensed by Hewlett Packard Enterprise to develop and support the OpenVMS operating system.

2. Intended Audience

Programmers at all levels of experience can use this manual effectively.

3. Document Structure

This book is organized as follows:

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 on x86-64 and I64 systems.

Chapter 3 describes how the linker creates image files on x86-64 and I64 systems.

Chapter 4 describes how to create shareable images and use them in link operations on x86-64 and I64 systems.

Chapter 5 describes how to interpret linker image maps on x86-64 and I64 systems.

Chapter 6 describes how the linker resolves symbolic references among input files on Alpha and VAX systems.

Chapter 7 describes how the linker creates image files on Alpha and VAX systems.

Chapter 8 describes how to create shareable images and use them in link operations on Alpha and VAX systems.

Chapter 9 describes how to interpret linker image maps on Alpha and VAX systems.

Chapter 10 provides reference information that describes the LINK command and its qualifiers and options.

The Glossary contains a list of important terms to refer to hardware and/or software entities, for the OpenVMS Linker running on a variety of OpenVMS operating systems and computers.

4. Related Documents

The following manuals contain related information.

For architecture-specific information, see:
  • VAX Architecture Handbook, Digital Equipment Corporation, 1987

  • Alpha Architecture Handbook, Digital Equipment Corporation, 1996

  • Intel® Itanium® Architecture Software Developer’s Manual, Intel Corporation, 2010

  • Intel® 64 and IA-32 Architectures Software Developer Manuals, Intel Corporation, 2019

For information about run-time conventions, see the VSI OpenVMS Calling Standard.

For information on including the debugger in the linking operation and about debugging in general, see the VSI OpenVMS Debugger Manual.

5. VSI Encourages Your Comments

You may send comments or suggestions regarding this manual or any VSI document by sending electronic mail to the following Internet address: . Users who have VSI OpenVMS support contracts through VSI can contact for help with this product.

6. OpenVMS Documentation

The full VSI OpenVMS documentation set can be found on the VMS Software Documentation webpage at https://docs.vmssoftware.com.

7. Typographical Conventions

The following conventions are used in this manual:
ConventionMeaning
Ctrl/xA sequence such as Ctrl/x indicates that you must hold down the key labeled Ctrl while you press another key or a pointing device button.
PF1 xA sequence such as PF1 x indicates that you must first press and release the key labeled PF1 and then press and release another key (x) or a pointing device button.
...
A horizontal ellipsis in examples indicates one of the following possibilities:
  • Additional optional arguments in a statement have been omitted.

  • The preceding item or items can be repeated one or more times.

  • Additional parameters, values, or other information can be entered.

.
.
.
A vertical ellipsis indicates the omission of items from a code example or command format; the items are omitted because they are not important to the topic being discussed.
( )In command format descriptions, parentheses indicate that you must enclose choices in parentheses if you specify more than one.
[ ]In command format descriptions, brackets indicate optional choices. You can choose one or more items or no items. Do not type the brackets on the command line. However, you must include the brackets in the syntax for directory specifications and for a substring specification in an assignment statement.
|In command format descriptions, vertical bars separate choices within brackets or braces. Within brackets, the choices are optional; within braces, at least one choice is required. Do not type the vertical bars on the command line.
{ }In command format descriptions, braces indicate required choices; you must choose at least one of the items listed. Do not type the braces on the command line.
bold typeBold type represents the name of an argument, an attribute, or a reason. Bold type also represents the introduction of a new term.
italic typeItalic type indicates important information, complete titles of manuals, or variables. Variables include information that varies in system output (Internal error number), in command lines (/PRODUCER=name), and in command parameters in text (where dd represents the predefined code for the device type).
UPPERCASE TYPEUppercase type indicates a command, the name of a routine, the name of a file, or the abbreviation for a system privilege.
Example

This typeface indicates code examples, command examples, and interactive screen displays. In text, this type also identifies website addresses, UNIX command and pathnames, PC-based commands and folders, and certain elements of the C programming language.

-
A hyphen at the end of a command format description, command line, or code line indicates that the command or statement continues on the following line.
numbersAll numbers in text are assumed to be decimal unless otherwise noted. Nondecimal radices—binary, octal, or hexadecimal—are explicitly indicated.

Chapter 1. Introduction

This chapter introduces the OpenVMS Linker utility (the linker), describing its primary functions and its role in software development. The chapter describes the following:
  • Definition of the linker and its main functions

  • How to invoke the linker

  • How to specify input files in a link operation

  • How to specify which output files the linker produces

In addition, this chapter provides an overview of how you can control a link operation by using qualifiers and options.

1.1. Overview

This section provides a list of key terms used in this manual and an overview of the OpenVMS Linker.

1.1.1. Terminology Used in this Manual

The OpenVMS Linker utility runs on a variety of OpenVMS operating systems and computers. Several important terms are used in this manual to refer to these hardware and/or software entities. The following list defines these terms. For a complete list of linker terminology, see the Glossary.
  • system — The computer hardware, the server; distinguish from the operating system (for example, OpenVMS Alpha).

  • platform — The system architecture; includes all systems running (for example, Intel® Itanium® processors).

  • OpenVMS system — An operating system that runs on multiple platforms including x86-64, I64, Alpha, and VAX.

  • OpenVMS x86-64 system (or x86-64 system) — A server running the OpenVMS x86-64 operating environment.

  • OpenVMS I64 system (or I64 system) — An HPE Integrity server running the OpenVMS I64 operating environment.

  • OpenVMS Alpha system (or Alpha system) — An HPE Alpha system running the OpenVMS Alpha operating system.

OpenVMS x86-64, OpenVMS I64, and OpenVMS Alpha systems are collectively referred to as the 64-bit systems.
  • OpenVMS VAX system (or a VAX system) — An HPE VAX system running the OpenVMS VAX operating system.

  • Executable and Linkable Format (ELF) — The object and image format described in the System V Application Binary Interface. See the Glossary for a complete definition of this term and additional terms.

x86-64, I64, Alpha, or VAX might be used as prefixes as well. For example:
  • x86-64 linking — The process of using the OpenVMS Linker utility to create an OpenVMS x86-64 image.


  • I64 image — An OpenVMS I64 image that includes binary data and Itanium instructions.

  • Alpha object file — An OpenVMS Alpha object that includes binary data and Alpha instructions.

1.1.2. Linker Overview

The primary purpose of the linker is to create images. An image is a file containing binary code and data that can be executed on an OpenVMS system.

On OpenVMS x86-64 and OpenVMS I64 systems, the linker creates only native images—x86-64 images on x86-64 systems, I64 images on I64 systems.

On OpenVMS Alpha and OpenVMS VAX systems, the linker creates native images by default.

On both OpenVMS Alpha and OpenVMS VAX systems, the linker supports /ALPHA and /VAX qualifiers that allow you to instruct the linker to accept Alpha or VAX object files on each respective system (see information about these linker qualifiers in Chapter 10). As a result, the linker can create VAX images on an Alpha system, and vice versa.

The primary type of image the linker creates is an executable image. An executable image can be activated at the DCL command line by issuing the RUN command. At run-time, the image activator, which is part of the operating system, opens the image file and reads activation information from the image to set up process page tables and pass control to the location (transfer address) where image execution is to begin.

The linker can also create a shareable image. A shareable image is a collection of procedures and data that can be called by executable images or by other shareable images. A shareable image is similar to an executable image. The linker separates shareable from nonshareable code and data. Shareable code and data can be shared via global sections that are set up by the Install utility or by the image activator.

To use the procedures or data of a shareable image, the shareable image has to be included in a link operation for another image, either explicitly in a linker option or implicitly from a default shareable image library. At run-time, when the image activator processes an executable image, it activates all the shareable images to which the executable image was linked.

The OpenVMS Alpha and OpenVMS VAX linkers can also create a system image, which can be run as a standalone system. System images generally do not contain image activation information and are not activated by the image activator. Images without activation information are not defined in the OpenVMS x86-64 and I64 object languages. As a result, the OpenVMS x86-64 and OpenVMS I64 linkers do not create this special type of image.

The linker creates images by processing the input files you specify. The primary type of input file that can be specified in a link operation is an object file. Object files that contain one or more object modules are produced by language processors, such as compilers or assemblers.

The binary code and data in an object module is in a platform-specific format:
  • On x86-64 and I64 platforms, the object module (and the resulting image) is in the Executable and Linkable Format (ELF).

  • On Alpha platforms, the object module is in the Alpha Object Language format.

  • On VAX platforms, the object module is in the VAX Object Language format.


Note

This manual frequently refers to parts of the format of the object language. As such, different terminology is occasionally used when referring to the same item on different platforms.

For example, on OpenVMS Alpha and VAX systems, the linker collects program sections (generally called psects) into image sections. Comparatively, on OpenVMS x86-64 and I64 systems the linker collects sections into segments. Although the names appear similar, there are considerable differences between the structure and content of an image section on OpenVMS Alpha and VAX compared with a segment on OpenVMS x86-64 and I64.

OpenVMS I64 compilers also take advantage of a short data section when constructing code with offsets from the global pointer (GP) register, neither of which are present on OpenVMS Alpha and VAX.

When the manual refers to a specific part of the object language, distinctions are made as to whether the reference pertains to the object language used by OpenVMS x86-64, I64, Alpha, or VAX.

The linker also accepts other input files such as shareable images, and on VAX platforms, symbol table files, which are both products of previous link operations. Section 1.2 provides more information about all the types of input files accepted by the linker. Section 1.3 provides more information about the output files created by the linker.

Figure 1.1 illustrates the relationship of the linker to the language processor in the program development process.

Chapter 2. Understanding Symbol Resolution (x86-64 and I64)

This chapter describes how the linker performs symbol resolution on OpenVMS x86-64 and OpenVMS I64 systems.

For information on performing symbol resolution on OpenVMS Alpha and OpenVMS VAX systems, see Chapter 6.

As one of its primary tasks, the linker must resolve symbolic references between modules. This chapter describes how you can control the process to ensure that the linker resolves symbolic references as you intend.

2.1. Overview

Programs are typically made up of many interdependent modules. For example, one module may define a symbol to represent a program location or data element that is referenced by many other modules. The linker is responsible for finding the correct definition of each symbol referenced in all the modules included in the link operation. This process of matching symbolic references with their definitions is called symbol resolution.

2.1.1. Types of Symbols

Symbols can be categorized by their scope, that is, the range of modules over which they are intended to be visible. Some symbols, called local symbols, are meant to be visible only within a single module. Because the definition and the references to these symbols must be confined to a single module, language processors such as compilers can resolve these references.

Other symbols, called global symbols, are meant to be visible to external modules. A module can reference a global symbol that is defined in another module. Because the value of the symbol is not available to the compiler processing the source file, it cannot resolve the symbolic reference. Instead, a compiler creates an ELF symbol table (SYMTAB) in an object module that includes all of the global symbol references and global symbol definitions it contains. These symbols are part of the global symbol directory (GSD).

On x86-64 and I64 systems, the GSD has a conceptual meaning. It no longer indicates an area within an object module, in which all named entities are listed. For ELF objects, the named entities for data and code are listed in the ELF symbol table; the name identities for sections are listed in the section header table. To use the traditional name GSD on x86-64 and I64 systems, the GSD can be seen as a subset of the ELF symbol table, plus a subset of the section header table.

In most programming languages, you can explicitly specify whether a symbol is global or local by setting or omitting particular attributes in the symbol definition or reference. For example, in C all functions are global symbols by default but the functions with the static attribute are local symbols.

In shareable images, symbols that are intended to be visible to external modules are called universal symbols. A universal symbol in a shareable image is the equivalent of a global symbol in an object module. Note, however, that only those global symbols that have been declared as universal are listed in the ELF symbol table (SYMTAB) of the shareable image and are available to external modules to link against. These symbols are part of the global symbol table (GST).

Similar to the GSD, the GST has a conceptual meaning on x86-64 and I64 systems; that is, it no longer indicates an area within an image file, in which all named entities are listed. For ELF images, the named entities for data and code are listed in the ELF symbol table and the named entities for sections are listed in the section header table. To use the traditional name GST on x86-64 and I64 systems, the GST can be seen as a subset of the ELF symbol table, plus a subset of the section header table.

You must explicitly declare universal symbols as part of the link operation in which the shareable image is created. For more information about declaring universal symbols, see Chapter 4.

2.1.1.1. Understanding Strong and Weak Symbols

As on Alpha and VAX systems, the linkers on x86-64 and I64 systems support global symbols that can be strong or weak. Weak symbols can be one of two types: VMS-style weak and UNIX-style weak.

The VMS-style weak symbol is identical to the weak symbol on Alpha and VAX. Using VMS-style weak symbols reflects a programming concept where the developer marks a symbol as weak depending on available language support. For information about how the linker processes VMS-style weak symbols, see Section 2.5.

UNIX-style weak symbols are unique to x86-64 and I64 systems and primarily used by the C++ compiler. Using UNIX-style weak symbols reflects an implementation concept, where the compiler marks symbols as weak, depending on language constructs. For information about how the linker processes UNIX-style weak symbols, see Section 2.6.

2.1.1.2. Group Symbols

Global symbols can be gathered in a group which is seen by the linker as a single entity. All symbols in a group are included or excluded in the link process. The group is identified by its group name, which is also called a group signature. A group also defines a set of sections, which contain definitions or references of the group symbols. As with UNIX-style weak symbols, groups are an implementation concept, primarily used by the VSI C++ compiler. For more information about working with group symbols, see Section 2.6.

2.1.1.3. The C Extern Common Model

In some VSI programming languages, certain types of global symbols, such as external variables in the C common extern model and COMMON data in FORTRAN, are not listed in the symbol table as global symbol references or definitions. Because these data types implement virtual memory that is shared, the languages implement them as sections that are overlaid. Rather than appearing as global symbol definitions or references, these variable names emerge as section names. (Compilers use sections to define the memory requirements of an object module). Although this may look like symbol resolution to the user, the linker does not process symbols. For information about how the linker processes sections, see Chapter 3.

For example, this C definition and the Fortran data that follows are matched and address the same data:
#pragma extern_model common_block
struct { int first; int second; } numbers;

INTEGER*4 first, second
COMMON /numbers/ first, second

2.1.1.4. Tentative Definitions in C

In the VSI C programming language, external variables can be defined in a strict or a relaxed reference/definition model. The strict model allows only one strong definition. The relaxed model, allows several tentative definitions. Any initialized variable is a strong symbol definition in the strict model. All uninitialized variables can be relaxed or tentative definitions. For both types of external variables, strong global symbols are generated by the compiler. For a strong definition in any model, the compiler reserves memory in the defining module. For tentative definitions, the compiler does not reserve memory. Tentative definitions result in global symbols in the symbol table, marked as ELF common.

Note

Do not confuse the term "ELF common" with "Fortran common"; these are different concepts.

If there is one strong definition, the linker uses it as the primary definition and treats all the tentative definitions as references. Otherwise, the linker does the following:
  • Creates a section named after the symbol to define memory for the tentative definitions.

  • Assigns the first module with a tentative definition as the defining module.

The section created by the linker contains the overlay attribute. Any other section with the same name and the same attributes can overlay onto this section.

For example, the following C definitions are tentative:
/* module A */ #pragma extern_model relaxed_refdef int my_data;
/* module B */ #pragma extern_model relaxed_refdef int my_data;
The linker creates a section with memory for the variable and marks module A as the defining module for the section.

Note

The linker does not include section names in its symbol resolution processing. The name spaces for symbols and sections are separate. The overlaying of sections with a created section for a tentative definition with the same name does not produce an exception.

2.1.1.5. Considerations for C Language Extensions

On x86-64 and I64 systems, the VSI C language extensions globalref and globaldef allow you to create external variables that appear as symbol references and definitions in the symbol table. For more information, see the VSI C User Manual.

In addition, VSI C supports command line qualifiers and source code pragma statements (as shown in the previous examples) that allow you to control the extern model. For more information, see the VSI C User Manual.

2.2. Input File Processing for Symbol Resolution

The linker can include object modules, shareable images, and libraries in its symbol resolution processing. Options files do not play an important role in symbol resolution (the SYMBOL= option can define a symbol and its value).

By default, the linker includes all the symbol definitions from the object module or shareable image. However, if you append the /SELECTIVE_SEARCH qualifier to the object module or shareable image file specification, then the linker includes in its processing only those symbols that define symbols referenced in a previously processed input file. For more information about selectively processing input files, see Section 2.2.4.

Table 2.1 summarizes how the linker processes these different types of input files when performing symbol resolution.
Table 2.1. Linker Input File Processing

Input File

How Processed

Object file (.OBJ)

By default, the linker processes all the symbol definitions and references listed in the global symbol table of the module. If you append the /SELECTIVE_SEARCH qualifier to the input file specification, the linker includes only those symbol definitions from the global symbol table that resolve symbolic references found in previously processed input files.

Shareable image file (.EXE)

By default, the linker processes all symbol definitions listed in the global symbol table of the image. However, the linker lists only those symbol definitions in the map file that are referenced by other modules in order to reduce map file clutter.

If you append the /SELECTIVE_SEARCH qualifier to the input file specification, the linker includes in its processing only those symbol definitions from the global symbol table that resolve symbolic references found in previously processed input files.

Library files (.OLB)

Specifying /LIBRARY, the linker searches the name table of the library for symbols that are undefined in previously-processed input files. (Usually, a library file's name table lists all the symbols available in all of the modules it contains). If the linker finds the definition of a symbol referenced by a previously-processed input file, it includes in the link operation, the library module containing the definition of the symbol. Once the object module or shareable image is included in the link operation, the linker processes it as any other object module or shareable image.

If you append only the /INCLUDE qualifier to a library file specification, the linker does not search the library's name table to find undefined symbolic references. Instead, the linker includes the specified object module or shareable image specified as a parameter to the /INCLUDE qualifier.

You cannot process a library file selectively. However, if the Librarian utility's /SELECTIVE_SEARCH qualifier was specified when the object module or shareable image was inserted into the library, the linker processes the module selectively when it extracts it from the library. VSI does not recommend to use libraries with selectively added object modules.

2.2.1. Processing Object Modules

The linker resolves symbolic references with their definitions. For example, the program in Example 2.1 references the symbol mysub.
Example 2.1. Source File Containing a Symbolic Reference: MY_MAIN.C
#include <stdio.h>
int mysub( int value_1, int value_2 );
main()
{
    int num1, num2, result;
    num1 = 5;
    num2 = 6;
    result = 0;
    result = mysub( num1, num2 );
    printf( "Result is: %d\n", result );
}
mysub, which Example 2.1 references, is defined in the program in Example 2.2.
Example 2.2. Source File Containing a Symbol Definition: MY_MATH.C
int myadd( int value_1, int value_2 )
{
    int result;
    result = value_1 + value_2;
    return result;
}
int mysub ( int value_1, int value_2 )
{
    int result;
    result = value_1 - value_2;
    return result;
}
int mymul( int value_1, int value_2 )
{
    int result;
    result = value_1 * value_2;
    return result;
}
int mydiv( int value_1, int value_2 )
{
    int result;
    result = value_1 / value_2;
    return result;
}
The GSD created by the language processor for the object module MY_MAIN.OBJ lists the reference to the symbol mysub. Because object modules cannot be examined using a text editor, the following representation of the GSD is taken from the output of the ANALYZE/OBJECT utility of the OpenVMS object module MY_MAIN.OBJ.
$ CC MY_MAIN.C
$ ANALYZE/OBJECT/SECTION=SYMTAB MY_MAIN.OBJ
   .
   .
   .
Description                  Hex <bitmask>    Decimal Interpretation
-----------                  ---------------  ------- --------------
Symbol 16. (00000010)        "MYSUB" 1
  Name Index in Sec. 8.:            0000004C      76.
  Symbol Info Field:                      12
    Symbol Type:                          02          STT_FUNC 2
    Symbol Binding:                       01          STB_GLOBAL 3
  Symbol 'Other' Field:                   80
    Symbol Visibility                     00          STV_DEFAULT
      .
      .
      .
  Bound to section:                     0000       0. (SHDR$K_SHN_UNDEF) 4
  Symbol Value              0000000000000000       0. 5
  Size associated with sym: 0000000000000000

1

In Example 2.2, MYSUB is defined in lowercase characters: mysub. The C compiler automatically upper cases all external symbol names unless you use the qualifier /NAMES=AS_IS.

2

The Symbol Type for MYSUB is STT_FUNC, which classifies MYSUB as a function (procedure). The linker checks the definition of mysub and make sure that its Symbol Type is also STT_FUNC. The linker issues an error if there is a discrepancy.

3

The Symbol Binding for MYSUB is STB_GLOBAL. For most applications, symbol types fall into two categories: global (STB_GLOBAL) and local (STB_LOCAL). Global symbols are visible across modules. Local symbols are visible only within the module.

4

References, or undefined symbols, are bound to a special section number which marks an undefined, missing, irrelevant or otherwise meaningless section (zero or SHDR$K_SHN_UNDEF). Definitions are bound to a section with a number greater than zero.

5

For references, the Symbol Value and the Size are not always known, and therefore are displayed as a zero.

The GSD created by the language processor for the object module MY_MATH.OBJ contains the definition of the symbol mysub, as well as the other symbols defined in the module. The definition of the symbol includes the value of the symbol.

The following excerpt from an analysis of the OpenVMS object module (performed using the ANALYZE/OBJECT utility).
$ CC MY_MATH.C
$ ANALYZE/OBJECT/SECTION=SYMTAB MY_MATH.OBJ
   .
   .
   .
Description                  Hex <bitmask>  Decimal Interpretation
-----------                  -------------  ------- --------------
Symbol 12. (0000000C)        "MYSUB"
 Name Index in Sec. 8.:            00000027      39.
 Symbol Info Field:                      12
   Symbol Type:                          02          STT_FUNC
   Symbol Binding:                       01          STB_GLOBAL
 Symbol 'Other' Field:                   80
   Symbol Visibility                     00          STV_DEFAULT
     .
     .
     .
 Bound to section:                     0003       3. "$CODE$" 1
 Symbol Value              0000000000000020      32. 2
 Size associated with sym: 0000000000000020          3

1

Since MYSUB is a procedure, it is associated with a code section.

2

The Symbol Value (32) is the byte offset of the code entry point into the section $CODE$.

3

The Size associated with the symbol is the amount of code in the routine (32 bytes).

When you link the modules shown in Example 2.1 and Example 2.2 together to create an image, you specify both object modules on the command line, as in the following example:
$ LINK MY_MAIN, MY_MATH 

When the linker processes these object modules, it reads the contents of the GSDs, obtaining the value of the symbol from the symbol definition.

For I64 images, the value of a symbol that is a function can be expressed in two ways:
  • If the linker has created a function descriptor (called a procedure descriptor on Alpha) the value is the address of the function descriptor. This is listed in the Symbol Cross Reference portion of the map with the suffix -R or in the Symbols By Value portion of the map with the prefix R-.

  • If the symbol is a function, and the linker has not created a function descriptor, the value of a symbol is the location within the image of the entry point of the function. This information is listed in the Symbol Cross Reference portion of the map with the suffix -RC or in the Symbols By Value portion of the map with the prefix RC-. R is the label that means relocatable, and C is the label that means code address.

The function descriptor created by the linker is a pair of quadwords that contain the Global Pointer (GP) for the image and the pointer to the entry point of the function. Note that on I64, the linker creates the function descriptors rather than the compiler. The linker also chooses the value for the GP, which is an address that the code segment uses to access the short data segment. It accesses different parts of the short data segment by using different offsets to the value the linker has chosen for the GP.

For x86-64 images, a function symbol's value is always a code address. There is no GP and no short data segment.

If the symbol is data, it can be either relocatable or not relocatable. The linker uses the R prefix or suffix in the map to indicate relocation.

2.2.2. Processing Shareable Images

When the linker processes a shareable image, it processes all the universal symbol definitions in the GST of the image. Because the linker creates the GST of a shareable image in the same format as an object module's symbol table, the processing of shareable images for symbol resolution is similar to the processing of object modules. The linker sets an attribute that flags the symbol as protected, which also indicates a universal symbol when the linker creates an image. Note that the linker includes only those universal symbols in the map file that resolve references, thus eliminating extraneous symbols in the linker map.

For example, the program in Example 2.2 (in Section 2.2.1) can be implemented as a shareable image. (For information about creating a shareable image, see Chapter 4). The shareable image can be included in the link operation as in the following example:
$ LINK/MAP/FULL MY_MAIN, SYS$INPUT/OPT
MY_MATH.EXE/SHAREABLE
Ctrl/Z

The GST created by the linker for the shareable image MY_MATH.EXE contains the universal definition of the symbol MYSUB, as well as the other symbols defined in the module.

Because images cannot be examined using a text editor, the following representations of the GST are taken from the output of the ANALYZE/IMAGE utility:

$ CC MY_MATH.C
$ LINK/MAP/FULL/CROSS/SHAREABLE MY_MATH.OBJ,SYS$INPUT/OPT
SYMBOL_VECTOR=(MYADD=PROCEDURE,-
               MYSUB=PROCEDURE,-
               MYMUL=PROCEDURE,-
               MYDIV=PROCEDURE)
Ctrl/Z
$ ANALYZE/IMAGE/SECTION=SYMTAB MY_MATH.EXE
Ctrl/Z
   .
   .
   .
  Symbol 3. (00000003)        "MYSUB"
    Name Index in Sec. 2.:            0000000D      13.
    Symbol Info Field:                      12
      Symbol Type:                          02          STT_FUNC
      Symbol Binding:                       01          STB_GLOBAL
    Symbol 'Other' Field:                   93
      Symbol Visibility                     03          STV_PROTECTED
      Function Type                         10          VMS_SFT_SYMV_IDX
       .
       .
       .
    Bound to section:                     0008       8. "$LINKER RELOCATABLE_SYMBOL"
    Symbol Value              0000000000000001       1.
    Size associated with sym: 0000000000000000

For x86-64 and I64 images, STV_PROTECTED indicates a universal definition. The "Symbol Type", STT_FUNC, indicates that this symbol represents a function (or procedure). The Function Type, VMS_SFT_SYMV_IDX, indicates that the symbol value (in this case 1) is the index into the symbol vector of the pointer to the function descriptor for MYSUB.

The analysis also lists all the indexes in the symbol vector. The following Index, which matches the previous value for the symbol, is 1.

For x86-64 images, the entry in the symbol vector with the index value of 1 contains the values 00002080 and 80000020. The first value is the procedure value for MYSUB, and the second value is the code address of the entry point for MYSUB.
SYMBOL VECTOR                         4. Elements
-------------                         -----------
Index   Value                         Size            Symbol or Section Name
-----   -----                         ----            ----------------------
    0.  0000000000002070 PROCEDURE                    "MYADD"
        0000000080000000
    1.  0000000000002080 PROCEDURE                    "MYSUB"
        0000000080000020
    2.  0000000000002090 PROCEDURE                    "MYMUL"
        0000000080000040
    3.  00000000000020A0 PROCEDURE                    "MYDIV"
        0000000080000060
            .
            .
            .

For I64 images, the entry in the symbol vector with the index value of 1, contains the value 30080, which is the address of a function descriptor for MYSUB. The function descriptor is a quadword pair. The first quadword is the address of the entry point for MYSUB (10020). The address 10020 is in a segment that has the execute flag set (that is, a code segment). The second quadword contains the global pointer chosen by the linker for the image (230000).

SYMBOL VECTOR                         4. Elements
-------------                         -----------
Index   Value                       Entry/GP or Size  Symbol or Section Name
-----   -----                       ----------------  ----------------------
    0.  0000000000030068 PROCEDURE  0000000000010000  "MYADD"
                                    0000000000230000
    1.  0000000000030080 PROCEDURE  0000000000010020  "MYSUB"
                                    0000000000230000
    2.  0000000000030098 PROCEDURE  0000000000010040  "MYMUL"
                                    0000000000230000
    3.  00000000000300B0 PROCEDURE  0000000000010090  "MYDIV"
                                    0000000000230000
            .
            .
            .

2.2.2.1. Implicit Processing of Shareable Images

For VAX linking, when you specify a shareable image in a link operation, the linker not only resolves symbols from the shareable image you specify but it also resolves symbols from all shareable images that the shareable image has been linked against (that is, the shareable image's dependency list).

The x86-64 and I64 linkers perform like the Alpha linker in that it does not automatically scan down a shareable image's dependency list to resolve symbols. Instead, on I64 an image's dependency list is in the dynamic segment. It appears in an analysis near the top of the file under the title Shareable Image List, as in the following example analysis of MY_MAIN.EXE:
$ LINK/MAP/FULL/CROSS MY_MAIN,SYS$INPUT/OPT
MY_MATH.EXE/SHAREABLE
Ctrl/Z
$ ANALYZE/IMAGE MY_MAIN
   .
   .
   .
Image Activation Information, in segment 4.
     Global Pointer:                             0000000000240000
     Whole program FP-mode:                      IEEE DENORM_RESULTS
     Link flags
         Call SYS$IMGSTA
         Image has main transfer
         Traceback records in image file
     Shareable Image List
         MY_MATH
             (EQUAL, 9412., 468313704).
         DECC$SHR
             (LESS/EQUAL, 1., 1).

Note

If your VAX application's build procedure depends on implicit processing of shareable images, you may need to add these shareable images to your x86-64 or I64 linker options file.

2.2.4. Processing Input Files Selectively

By default, the linker processes all the symbol definitions and references in an object module or a shareable image specified as input in a link operation. However, if you append the /SELECTIVE_SEARCH qualifier to an input file specification, the linker processes from the input file only those symbol definitions that resolve references in previously processed input files.

Processing input files selectively can reduce the amount of time a link operation takes and can conserve the linker's use of virtual memory. Note, however, that selective processing can also introduce dependencies on the ordering of input files in the LINK command.

Note

Processing files selectively does not affect the size of the resultant image; the entire object module is included in the image even if only a subset of the symbols it defines is referenced. (Shareable images do not contribute to the size of an image).

For example, in the link operation in Section 2.2.2, the linker processes the shareable image MY_MATH.EXE before it processes the object module MY_MAIN.OBJ because of the way in which the linker clusters input files. (For information about how the linker clusters input files, see Section 2.3.1). When it processes the shareable image, the linker includes on its list of symbol definitions all the symbols defined in the shareable image. When it processes the object module MY_MAIN.OBJ and encounters the reference to the symbol mysub, the linker has the definition to resolve the reference.

If you append the /SELECTIVE_SEARCH qualifier to the shareable image file specification and all of the other input files are specified on the command line, the link will fail. In the following example, because the linker has no symbols on its undefined symbol list when it processes the shareable image file MY_MATH.EXE, it does not include any symbol definitions from the shareable image in its processing. When it subsequently processes the object module MY_MAIN.OBJ that references the symbol mysub, the linker cannot resolve the reference to the symbol. For information about how to correct this link operation, see Section 2.3.1.
$ LINK MY_MAIN, SYS$INPUT/OPT
MY_MATH.EXE/SHAREABLE/SELECTIVE_SEARCH
Ctrl/Z
%ILINK-W-NUDFSYMS, 1 undefined symbol:
%ILINK-I-UDFSYM,        MYSUB
%ILINK-W-USEUNDEF, undefined symbol MYSUB referenced
         section: $CODE$
         offset: %X0000000000000110  slot: 2
         module: MY_MAIN
         file: WORK:[PROGRAMS]MY_MAIN.OBJ;1

To process object modules or shareable images in a library selectively, you must specify the /SELECTIVE_SEARCH qualifier when you insert the module in the library. For more information about using the Librarian utility, see the VSI OpenVMS Command Definition, Librarian, and Message Utilities Manual.

2.3. Ensuring Correct Symbol Resolution

For many link operations, the order in which the input files are specified in the LINK command is not important. However, in complex link operations that specify multiple library files or process input files selectively, correct symbol resolution may become problematic.

To ensure that the linker resolves all the symbolic references as you intend, you may need to know order in which the linker processes the input files. To control the order in which the linker processes input files, you must understand how the linker parses the command line. The following sections describe these processes.

2.3.1. Understanding Cluster Creation

As it parses the command line, the linker groups the input files you specify into clusters and places these clusters on a cluster list. A cluster is an internal linker construct that determines segment creation. The position of an input file in a cluster and the position of that cluster on the linker's cluster list determine the order in which the linker processes the input files you specify.

The linker always creates at least one cluster, called the default cluster. The linker may create additional clusters, called named clusters, depending on the types of input files you specify and the linker options you specify. If it creates additional clusters, the linker places them on the cluster list ahead of the default cluster, in the order in which it encounters them in the options file. The default cluster appears at the end of the cluster list. (Within the default cluster, input files appear in the same order in which they are specified on the LINK command line).

Clusters for shareable images, specified in shareable image libraries, appear after the default cluster on the cluster list because they are created later in linker processing, when the linker knows which shareable images in the library are needed for the link operation.

The linker groups input files into clusters according to file type. Table 2.2 lists the types of input files accepted by the linker and describes how the linker processes them when creating clusters.
Table 2.2. Linker Input File Cluster Processing

Input File

Cluster Processing

Object file (.OBJ)

Placed in the default cluster unless explicitly placed in a named cluster using the CLUSTER= option.

Shareable image file (.EXE)

Always placed in a named cluster.

Library files (.OLB)

Placed in the default cluster unless explicitly placed in a named cluster using the CLUSTER= option. If the library contains shareable images and the linker includes a shareable image from the library in the link operation, the linker creates a new cluster for the shareable image.

The linker puts input files included in a link operation from a library using the /INCLUDE qualifier in the same cluster as the library.

The linker puts modules extracted from any default user library that is an object library and from STARLET.OLB in the default cluster. However, the linker puts shareable images referenced from IMAGELIB.OLB into new clusters at the end of the cluster list (after the default cluster).

Options file (.OPT)

Not placed in a cluster.

The following example illustrates how the linker puts the various types of input files in clusters. To see which clusters the linker creates for this link operation, look at the Cluster Synopsis section of the image map file. Figure 2.4 illustrates the clusters created for this link operation. Note that order of cluster creation is: MY_CLUS, MY_SHARE, DEFAULT_CLUSTER, MY_SHARE_IMG.
$ DEFINE LNK$LIBRARY  SYS$DISK:[]MY_DEFAULT_LIB.OLB
$ LINK  MY_MAIN.OBJ, MY_LIB.OLB/LIBRARY, SYS$INPUT/OPT
CLUSTER=MY_CLUS,,,MY_PROG.OBJ
MY_SHARE.EXE/SHAREABLE
MY_SHARE_LIB.OLB/LIBRARY
Ctrl/Z
Figure 2.4. Clusters Created for Sample Link
Clusters Created for Sample Link

The linker processes input files in cluster order, processing each input file starting with the first file in the first cluster, then processing the second file, and so on, until it has processed all files in the first cluster. The linker continues processing the input files in the second, and subsequent, clusters in the same manner. Processing concludes when the linker has processed all files in all clusters.

2.3.2. Controlling Cluster Creation

You can control cluster creation and ordering by using either of the following linker options:
  • CLUSTER= option

  • COLLECT= option

2.3.2.1. Using the CLUSTER= Option to Control Clustering

The 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).

For example, you can use the CLUSTER= option to fix the link operation illustrated in Section 2.2.4, where the link operation yielded warnings because a shareable image was processed first and 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 before specifying the shareable image. 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.
$ LINK/EXECUTABLE=MY_MAIN SYS$INPUT/OPT
CLUSTER=MYMAIN_CLUS,,,MY_MAIN
MY_MATH/SHAREABLE/SELECTIVE_SEARCH
Ctrl/Z

The Object and Image 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:

                      +---------------------------+
                      ! Object and Image Synopsis !
                      +---------------------------+
  Module/Image  File           Ident             Attributes      Bytes
  ------------  ----           -----          –--------------    -----
  MY_MAIN                       V1.0               Lkg    Dnrm     504
                WORK:[PROGRAMS]MY_MAIN.OBJ;1
  MY_MATH                       V1.0           Sel Lkg               0
                WORK:[PROGRAMS]MY_MATH.EXE;1
    .
    .
    .

2.3.2.2. Using the COLLECT= Option to Control Clustering

You can also create a named cluster by specifying the COLLECT= option. The COLLECT= option directs the linker to put specific sections in a named cluster. The linker creates the cluster if it does not already exist. Note that the COLLECT= option manipulates sections, not input files.

The linker sets the global (GBL) attribute of the sections specified in a COLLECT= option to enable a global search for the definition of that section.
$ LINK/EXECUTABLE=MY_MAIN SYS$INPUT/OPT
CLUSTER=MYMAIN_CLUS,,,MY_MAIN
COLLECT=MYCODE_CLUS,$CODE$
MY_MATH/SHAREABLE/SELECTIVE_SEARCH
Ctrl/Z

In this example, a cluster MYCODE_CLUS is created after MYMAIN_CLUS and the section $CODE$ is collected into the cluster MYCODE_CLUS.

2.4. Resolving Symbols Defined in the OpenVMS Executive

For x86-64 and I64 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 X86$LOADABLE_IMAGES for x86-64 links and IA64$LOADABLE_IMAGES for I64 links. 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.

When the /SYSEXE qualifier is specified, the linker processes the file selectively. To disable selective processing, specify the /SYSEXE=NOSELECTIVE qualifier and keyword. For more information about using the /SYSEXE qualifier, see the description of the qualifier in Chapter 10.

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.5 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.5. Linker Processing of Default Libraries and SYS$BASE_IMAGE.EXE
Linker Processing of Default Libraries and SYS$BASE_IMAGE.EXE

2.5. Processing Weak and Strong Global Symbols

This section describes how the linker processes weak and strong global symbols.

2.5.1. Overview of Weak and Strong Global Symbol Processing

The linker records each symbol definition and each symbol reference in its internal global symbol table. For each symbol, the linker notes whether the symbol is strong, VMS-style weak, or UNIX-style weak.

The linker processes strong symbol definitions differently than it does UNIX-style weak symbol definitions (see Section 2.5.2). In general, a symbol can have only one strong or one VMS-style weak definition but it can have multiple UNIX-style weak definitions. When linking against libraries, note that there is also a difference between VMS-style weak and UNIX-style weak symbol definitions.

The linker processes weak references differently than it does strong references, although it handles both types of weak references in the same manner. Strong references must be resolved, whereas VMS-style and UNIX-style weak can be resolved optionally. If any weak symbol is not resolved, then the linker puts the value zero in place of the reference. In this case, the linker does not display a warning message.

By default, all global symbols generated by most x86-64 and I64 language processors are strong. That is, object modules usually contain strong symbol definitions and strong symbol references. You can decide to make some symbols VMS-weak definitions and references. To do so, you must use a language feature and explicitly mark the code or data as VMS-style weak. (For example, you would explicitly mark the code or data as VMS-style weak with the intention of performing a link operation on partially complete development code). See Section 2.5.1.2 for more information about creating and using VMS-style weak symbols.

For some language constructs, the VSI C++ compiler generates UNIX-style weak symbols. That is, some object modules may contain strong and weak symbol definitions and references. The compiler produces redundant code or data in multiple object modules and the linker resolves to the first symbol encountered in the link operation.

2.5.1.1. Strong Symbols

For strong global symbols, there can be only one definition. If the linker finds more than one definition in different input modules, any secondary definition is reported as a multiple definition.

By default, when adding an object module to a library, a strong symbol definition from the object module is included in the library symbol table. As a result, the symbol can be found when the linker searches a library to resolve a symbol reference.

2.5.1.2. VMS-Style Weak Symbols

VMS-style weak global symbols can have only one definition. If the linker finds more than one definition in different input modules, any secondary definition is reported as multiply defined.

When adding an object module to a library, a VMS-style weak global symbol is not included in the library symbol table. As a result, if the module containing the weak symbol definition is in a library but is not selected for inclusion (by means of the /INCLUDE qualifier or to resolve a strong reference), the linker is unable to resolve the reference.

2.5.1.3. UNIX-Style Weak Symbols

UNIX-style weak global symbols can have multiple definitions. When a strong definition is absent, the linker selects the first occurrence of the UNIX-style weak definition and views subsequent ones as references.

When adding an object module to a library, a UNIX weak symbol is included in the library symbol table. (The x86-64 and I64 Librarians are compatible with UNIX-style weak symbols). If multiple modules define the same UNIX-style weak symbol, the librarian maintains an ordered list of symbols in its symbol table. With this information, the linker can find a UNIX-style weak symbol when searching a library for an unresolved symbol. Note that the earliest module added in the library defining the symbol is selected for inclusion.

If the object module containing any type of weak symbol definition is explicitly specified, either as an input object file or for extraction from a library (by means of the /INCLUDE qualifier or to resolve a strong reference), the VMS-style weak or UNIX-style weak symbol definitions are available for symbol resolution.

2.5.2. Strong and Weak Definitions

The OpenVMS x86-64 and I64 linkers support modules from various programming languages and contain rules for handling symbols from these languages under different circumstances. Table 2.3 shows how symbol definitions are handled when object modules are processed.
Table 2.3. Symbol Definition Handling

Current Symbol Definition

New Symbol Definition Encountered

Action

<none>

<any>

Assign new definition

UNIX-style weak

UNIX-style weak

Ignore new definition

UNIX-style weak

VMS-style weak

Assign VMS-style weak definition

UNIX-style weak

Strong

Assign Strong definition

VMS-style weak

UNIX-style weak

Ignore new definition

VMS-style weak

VMS-style weak

Report multiple defined symbols

VMS-style weak

Strong

Report multiple defined symbols

Strong

UNIX-style weak

Ignore new definition

Strong

VMS-style weak

Report multiple defined symbols

Strong

Strong

Report multiple defined symbols

An exception to the rules presented in Table 2.3 is for the special symbol, ELF$TFRADR, which defines the image entry point. Typically, each compiler defines one symbol for each module that contains code. If the module contains a main entry, then a strong symbol is defined. Conversely, if there is no main entry, a VMS-style weak symbol is defined (which behaves differently than a strong symbol).

If you have only VMS-style weak ELF$TFRADR symbols, the first-encountered definition determines the image entry and the other definitions are ignored. If there is a strong definition, it overwrites an existing VMS-style weak definition and other definitions are ignored.

Note

This case is different than processing UNIX-style weak symbols, where ignored symbols are converted to references.

2.5.3. Resolving Strong and Weak Symbols

This section describes how the x86-64 and I64 linkers process strong and weak references to resolve symbols. In general, a strong reference can be resolved by a strong symbol definition or any type of weak symbol definition.

For a strong reference, the linker searches all input files (explicit and implicit) for a definition of the symbol. If the linker cannot locate the definition needed to resolve the strong reference, it reports the undefined symbol and assigns the symbol a value, which usually results in a run-time error for accessing the data or calling the routine.

When the linker resolves a weak reference with a strong symbol definition or a weak symbol definition, it resolves the weak reference in the same way it does a strong reference, with the following exceptions:
  • The linker will not search library modules that have been specified with the /LIBRARY qualifier or default libraries (user-defined or system) solely to resolve a weak reference. If, however, the linker resolves a strong reference to another symbol in such a module, it will also use that module to resolve any weak references.

  • If the linker cannot locate the definition needed to resolve a weak reference, it assigns the symbol a value, which usually results in a run-time error, but does not report an undefined symbol. If, however, the linker reports any unresolved strong references, it will also report any unresolved weak references.

By default, most global definitions in x86-64 and I64 languages are strongly defined.

2.5.4. Creating and Using VMS-style Weak Symbols

In the dialects of MACRO, BLISS, and Pascal supported on x86-64 and I64 systems, you can define a global symbol as either strong or VMS-style weak, and you can make either a strong or a VMS-style weak reference into a global symbol.

In these languages, all definitions and references are strong by default. To make a VMS-style weak definition or a VMS-style 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).

One purpose for making a weak reference is need to write and test incomplete programs. Resolving all symbolic references is crucial to a successful link operation. Therefore, a problem arises when the definition of a referenced global symbol does not yet exist. (This 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 to this condition is to make the reference to the symbol VMS-style weak, which informs the linker that the resolution of this particular global symbol is not crucial to the link operation.

2.6. Processing VSI C++ Compiler-Generated UNIX-Style Weak and Group Symbols

UNIX-style weak symbols and groups are used by the VSI C++ compiler to implement template instantiation. Templates, commonly used in the VSI C++ standard library,provide a programming model that allows you to write and use data type-independent code. When this code is part of a source module, it is used with a data type, that is, the template is instantiated.

To instantiate the template, the compiler defines UNIX-style weak symbols for variables and functions used in the template and generates a group. All these symbols, along with code and data, are placed in the group and marked as group symbols. When the same template with the same data type is instantiated in several source modules, a group with the same name containing the same code and data appears in each object module.

The linker handles group symbols in a special way to generate an image which contains only one occurrence of this group of sections. The linker ensures that all references to the groups are resolved to the designated instance of the group.

Currently, UNIX-style weak symbols and group symbols are only used by the VSI C++ compiler, which usually limits the usage of UNIX-style weak binding to group symbols. However, UNIX-style weak symbols and group symbols can be seen as independent, and the linker handles them as such. UNIX-style weak symbols can be defined in shareable images and – similar to shareable image groups – always take precedence over UNIX-style weak symbol definitions found in object modules.

2.6.1. Processing Group Symbols

When linking modules, the first occurrence of a group makes its symbols known to the linker. The linker regards any additional occurrence of the group with the same name as redundant and therefore, ignores it.

Because the concept of groups (as described in the ELF specification) is limited to object modules, the use of shareable images requires a different approach: the VMS extension to ELF allows groups for shareable images. A shareable image group always takes precedence over groups found in object modules. For global symbols and identical groups, this means that all group symbols from an already processed group of an object module are replaced by the ones from the shareable image. The linker's intention is to always use the code and data from the shareable image.

2.6.2. VSI C++ Examples

The following VSI C++ examples demonstrate how symbols are resolved when you link with compiler-generated UNIX-style weak and group symbols.

The examples apply a user-written function template called myswap. Note that you can also use class templates, which are implemented in a similar manner. If you are an experienced C++ programmer, you will also recognize that there is a "swap" function in the VSI C++ standard library, which you should use instead of writing your own function.

In the examples, the compiler combines code sections (and other required data)into a group, giving it a unique group name derived from the template instantiation.

The linker includes the first occurrence of this group in the image. All UNIX-style weak definitions obtained from that group are now defined by the module providing this group. All subsequent groups with the same name do not contribute code or data; that is, the linker ignores all subsequent sections. The UNIX-style weak definitions from these ignored sections become references, which are resolved by the definition from the designated instance (that is, first-encountered instance) of the group. In this manner, code (and data) from templates are included only once for the image.

Example 2.3 shows UNIX-Style weak symbols and group symbols.
Example 2.3. UNIX-Style Weak and Group Symbols
//  file: my_asc.cxx
template <typename T> 1
void myswap (T &v1, T &v2) { 2
        T tmp;
        tmp = v1;
        v1 = v2;
        v2 = tmp;
}
void ascending (int &v1, int &v2) {
        if (v2&lt;v1)
                myswap (v1,v2); 3
}
//  file: my_desc.cxx
template <typename T> 1
void myswap (T &v1, T &v2) { 2
        T tmp;
        tmp = v1;
        v1 = v2;
        v2 = tmp;
}
void descending (int &v1, int &v2) {
        if (v1&lt;v2)
                myswap (v1,v2); 3
}
//  file: my_main.cxx
#include <cstdlib>
#include <iostream>
using namespace std;
static int m = 47;
static int n = 11;
template <typename T> void myswap (T &v1, T &v2);
extern void ascending (int &v1, int &v2);
extern void descending (int &v1, int &v2);
int main (void) {
        cout << "original: " << m << " " << n << endl;
        myswap (m,n); 4
        cout << "swapped: " << m << " " << n << endl;
        ascending (m,n);
        cout << "ascending: " << m << " " << n << endl;
        descending (m,n);
        cout << "descending: " << m << " " << n << endl;
        return EXIT_SUCCESS;
}
Example 2.4 shows the compile and link commands.
Example 2.4. Compile and Link Commands
$ CXX/OPTIMIZE=NOINLINE/STANDARD=STRICT_ANSI MY_MAIN 1
$ CXX/OPTIMIZE=NOINLINE/STANDARD=STRICT_ANSI MY_ASC  2
$ CXX/OPTIMIZE=NOINLINE/STANDARD=STRICT_ANSI MY_DESC 2
$ CXXLINK MY_MAIN, MY_ASC, MY_DESC                   3

In the examples, the compiler combines code sections (and other required data) into a group, giving it a unique group name derived from the template instantiation.

The linker includes the first occurrence of this group in the image. All UNIX-style weak definitions obtained from that group are now defined by the module providing this group. All subsequent groups with the same name do not contribute code or data; that is, the subsequent sections are ignored. The UNIX-style weak definitions from these ignored sections become references, which are resolved by the definition from the designated instance (first-encountered) of the group. In this manner, code (and data) from templates are included only once for the image.

1

To keep the examples simple, the template definitions are included in the sources, usually templates are defined in include files.

2

C++ mangles symbol names to guarantee unique names for overloaded functions. Therefore, in the linker map or in the output from ANALYZE/OBJECT utility, the string MYSWAP may be part of a longer symbol name and may not be easily identified. Further, the compiler creates more names using the string MYSWAP:the unique group name, code section names, and so on.

3

The functions "ascending" and "descending" sort a pair of numbers. If necessary the contents are swapped. Swapping is implemented as a function template, which is automatically instantiated with the call inside of the functions "ascending"and "descending".

4

In the main function, "myswap" is used to demonstrate a strong reference to a UNIX-style weak definition. (As previously mentioned, this is not common practice. Usually, templates are defined in include files and included in all sources). Note that there is only a reference to the function and that there is no definition. That is, the compiler does not create a group. When compiling the main module, a reference to "myswap <int>" is automatically generated for the call to myswap inside the main function. This strong reference will be resolved by the first UNIX-style weak definition from either MY_ASC.OBJ or MY_DESC.OBJ which define "myswap <int>".


1

To see the effects of this example, the compiler should not inline code. Because inlining is an optimization, this feature is demonstrated only by omitting optimization.

2

When both source modules are compiled, both object modules contain the definition of the "myswap <int>" function. The compiler groups the code (and other required data) sections into a group with a unique group name derived from the template instantiation. The compiler generates UNIX-style weak symbols and adds them to the group.

3

For linking, the CXXLINK command is used in the examples. This command invokes the C++ linker driver, which in turn calls the OpenVMS linker to perform the actual link operation.

2.6.3. Compiler-Generated Symbols and Shareable Images

To create a VMS shareable image, you must define the interface in a symbol vector at link time with a SYMBOL_VECTOR option. VSI C++ generated objects contain mangled symbols and may contain compiler-generated data, which belongs to a public interface. In the SYMBOL_VECTOR option, the interface is describe with the names from the object modules. Because they contain mangled names, such a relationship may not be obvious from the source code and the symbols as seen in an object module.

If you do not export all parts of an interface, code that is intended to update one data cell may be duplicated in the executable and the shareable image along with the data cell. That is, data can become inconsistent at run-time, producing a severe error condition. This error condition can not be detected at link time nor at image activation time. Conversely, if you export all symbols from an object module, you may export the same symbol which is already public from other shareable images.

A conflict arises when an application is linked with two shareable images that export the same symbol name. In this case, the linker flags the multiple definitions with a MULDEF warning that should not be ignored. This type of error most often results when using templates defined in the C++ standard library but instantiated by the user with common data types. Therefore, VSI recommends that you only create a shareable image when you know exactly what belongs to the public interface. In all other cases, use object libraries and let applications link against these libraries.

The VSI C++ run-time library contains pre-instantiated templates. The public interfaces for these are known and therefore, the VSI C++ run-time library ships as a shareable image. The universal symbols from the VSI C++ run-time library and the group symbols take precedence over user instantiated templates with the same data types. As with other shareable images, this design is upwardly compatible and does not require you to recompile or relink to make use of the improved VSI C++ run-time library.

2.7. Understanding and Fixing DIFTYPE and RELODIFTYPE Linker Conditions (I64 Only)

On OpenVMS I64 systems, if a module defines a variable as data (OBJECT), it must be referenced as data by all other modules. If a module defines a variable as a procedure (FUNC), it must be referenced as a procedure by all other modules.

When data is referenced as a procedure, the linker displays the following informational message:
%ILINK-I-DIFTYPE, symbol symbol-name of type OBJECT cannot be referenced as type FUNC
When a procedure is referenced as data, the following informational message is displayed:
%ILINK-I-DIFTYPE, symbol symbol-name of type FUNC cannot be referenced as type OBJECT

Type checking is performed by the linker on OpenVMS I64 because the linker must create function descriptors. The equivalent procedure descriptor was created by the compiler on OpenVMS Alpha, so this informational message is new for the linker on OpenVMS I64.

This message is informational only and does not require user action. However, if the linker detects data referenced as a procedure, it might issue the following warning message in addition to the DIFTYPE message:
%ILINK-W-RELODIFTYPE, relocation requests the linker to build a function descriptor for a non-function type of symbol
The following example of two modules demonstrates how to fix these conditions:
TYPE1.C
#include <stdio>
int status ;   // Defines status as data.
extern int sub();
main ()
{
    printf ("Hello World\n");
    sub();
}

TYPE2.C
extern int status (int x) ;  // Refers to status as a procedure.
sub ()
{
    int x;
    x = (int)status;
    return status (x);
 }
When these modules are linked, you get an informational message and a warning message, as follows:
$ CC/EXTERN_MODEL=STRICT_REFDEF TYPE1
$ CC/EXTERN_MODEL=STRICT_REFDEF TYPE2
$ LINK TYPE1,TYPE2
%ILINK-I-DIFTYPE, symbol STATUS of type OBJECT cannot be referenced as
type FUNC
       module: TYPE2
       file: NODE1$:[SMITH]TYPE2.OBJ;6
%ILINK-W-RELODIFTYPE, relocation requests the linker to build a
function descriptor for a non-function type of symbol
        symbol: STATUS
        relocation section: .rela$CODE$ (section header entry: 18)
        relocation type: RELA$K_R_IA_64_LTOFF_FPTR22
        relocation entry: 0
        module: TYPE2
        file: NODE1$:[SMITH]TYPE2.OBJ;6
To correct the problem and avoid the informational and warning messages, correct TYPE1.C to define status as a procedure:
TYPE1.C
#include <stdio>
int status (int x);  // Defines status as a procedure.
extern int sub();
main ()
{
    printf ("Hello World\n");
    sub();
}
nt status (int x) {
   return 1;
}
$ CC/EXTERN_MODEL=STRICT_REFDEF TYPE1
$ CC/EXTERN_MODEL=STRICT_REFDEF TYPE2
$ LINK TYPE1,TYPE2

Chapter 3. Understanding Image File Creation (x86-64 and I64)

This chapter describes how the linker creates an image on OpenVMS x86-64 and OpenVMS I64 systems. The linker creates images from the input files you specify in a link operation. You can control image file creation by using linker qualifiers and options.

3.1. Overview

After the linker has resolved all symbolic references between the input files specified in the LINK command (described in Chapter 2), the linker knows all the object modules and shareable images that are required to create the image. For example, the linker has extracted from libraries specified in the LINK command those modules that contain the definitions of symbols required to resolve symbolic references in other modules. The linker must now combine all these modules into an image.

To create an image, the linker must perform the following processing:
  • Determine the memory requirements of the image

    The memory requirements of an image are the sum of the memory requirements of each object module included in the link operation, together with the memory the linker created to support code and data. The language processors that create the object modules specify the memory requirements of an object module as section definitions. A section represents an area of memory that has a name, a length, and other characteristics, called attributes, which describe the intended or permitted usage of that portion of memory. Section 3.2 describes sections.

    The linker processes the section definitions in each object module, combining sections with similar attributes into a segment, which on x86-64 and I64 systems is analogous to an image section on Alpha and VAX systems (see Chapter 7). Each segment specifies the size and attributes of a portion of the virtual memory of an image. The image activator uses the segment attributes to determine the characteristics of the physical memory pages into which it loads the image, such as protection.

    Figure 3.1 illustrates how memory requirements are communicated from the language processor to the linker and from the linker to the image activator. Section 3.3 provides more information about this process.

    Figure 3.1. Communication of Image Memory Requirements on x86-64/I64
    Communication of Image Memory Requirements on x86-64/I64

    Note that shareable images included in link operations have already been processed by the linker. These images are separate images with their own memory requirements, as specified by their own segments. The image activator activates these shareable images at run-time.

  • Initialize the image

    When segments are first created, they are empty. In this step of linker processing, the linker copies the code and data sections from the object modules into the image's segments. Section 3.4 provides more information about this process.

    In the process of initializing the image, the linker may encounter sections that have the type SHT_NOBITS. This section type indicates that the section occupies no space in the file — a demand-zero section. The linker combines these sections together into demand-zero segments. The linker also trims the zeros off the end of segments when the qualifier /DEMAND_ZERO=PER_PAGE is used. Note that this is not the default. The operating system initializes demand-zero segments at run-time, when a reference to a segment requires the operating system to move the pages into memory. Section 3.4.4 describes how the linker creates demand-zero segments.

After creating segments and filling them with binary code and data, the linker writes the image to an image file. Section 3.4.2 describes this process.

3.2. Creating Sections

Language processors create sections and define their attributes. The number of sections created by a language processor and the attributes of these sections are depend on language semantics. For example, some programming languages implement global variables as separate sections with a particular set of attributes. Programmers working in high-level languages typically have little direct control over the sections created by the language processor. Medium- and low-level languages provide programmers with more control over section creation. For more information about the section creation features of a particular programming language, see the language processor documentation.

The x86-64 and I64 linkers also create sections that are combined with the compiler sections to create segments (see Section 3.2.1).

Section Attributes

The language processors define the attributes of the sections they create and communicate these attributes to the linker in the section header table.

Section attributes define various characteristics of the area of memory described by the section, such as the following:
  • Access

    Using section attributes, compilers can prohibit some types of access, such as write access. Using other section attributes, compilers can allow access to the section by more than one process.

  • Positioning

    By specifying certain section attributes, compilers can specify to the linker how it should position the section in memory.

Section attributes are Boolean values, that is, they are either on or off. Table 3.2 lists all section attributes with the keyword you can use to set or clear the attribute, using the PSECT_ATTR=option. For more information about using the PSECT_ATTR= option, see Section 3.3.7.

For example, to specify that a section should have write access, specify the writability attribute as WRT. To turn off an attribute, specify the negative keyword. Some attributes have separate keywords that express the negation of the attribute. For example, to turn off the global attribute (GBL), you must specify the local attribute (LCL). Note that the alignment of a section is not strictly considered an attribute of the section. However, because you can set it using the PSECT_ATTR= option, it is included in the table.

To be compatible with Alpha and VAX linkers, the x86-64 and I64 linkers retain the user interfaces as much as possible. This information includes the traditional OpenVMS section attribute names (WRT, EXE, and so on) that are used in the PSECT_ATTR= option. However, on x86-64 and I64 systems, the underlying object conforms to the ELF standard. When processing the object module, the linker maps the ELF terms to the OpenVMS terms. For compatibility, only OpenVMS terms are written to the map file. In contrast, other tools, such as the ANALYZE/OBJECT utility, do not use OpenVMS terms; they simply format the contents of the object file and therefore display the ELF terms.

Table 3.1 provides mapping between the ELF names and the traditional OpenVMS section attribute names.
Table 3.1. Mapping ELF Section Terms to OpenVMS Attributes

ELF Section Attribute (prefix SHDR$V_)

Traditional OpenVMS Section Attribute

SHF_WRITE

WRT

SHF_EXECINSTR

EXE

SHF_VMS_GLOBAL

GBL

SHF_VMS_OVERLAID

OVR

?

REL

SHF_VMS_SHARED

SHR

SHF_VMS_VECTOR

VEC

SHF_VMS_ALLOC_64BIT

ALLOC_64BIT

SHF_X86_64_LARGE?

SHF_IA_64_SHORT?

SHORT

SHT_NOBITS?

NOMOD?

Table 3.2 lists all section attributes with the keyword you can use to set or clear the attribute, using the PSECT_ATTR=option.
Table 3.2. Section Attributes on x86-64/I64
AttributeKeywordDescription

Alignment

Specifies the alignment of the 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:

Power of 2KeywordMeaning

0

BYTE

Alignment on byte boundaries.

1

WORD

Alignment on word boundaries.

2

LONG

Alignment on longword boundaries.

3

QUAD

Alignment on quadword (8-byte) boundaries.

4

OCTA

Alignment on octaword (16-byte) boundaries.

5

HEXA

Alignment on hexadecimal word (32-byte) boundaries.

6

Alignment on 64-byte boundaries.

7

Alignment on 128-byte boundaries.

8

Alignment on 256-byte boundaries.

9

Alignment on 512-byte boundaries.

13

Alignment on 8 KB boundaries.

14

Alignment on 16 KB boundaries.

15

Alignment on 32 KB boundaries.

16

Alignment on 64 KB boundaries.

PAGE

Alignment on the default target page size, which is 8 KB for x86-64 and 64 KB for I64 linking. You can override this default by specifying the /BPAGE qualifier.

Position Independence

PIC/NOPIC

This keyword is ignored by the x86-64 and I64 linkers.

Overlaid/Concatenated

OVR/CON

When set to OVR, specifies that the linker will overlay this section with other sections with the same name and attribute settings. Sections that are overlaid are assigned the same base address. When set to CON, the linker concatenates the sections.

Relocatable/Absolute

REL/ABS

When set to REL, specifies that the linker can place the section anywhere in virtual memory. Absolute sections are used by compilers primarily to define constants, but in the ELF object language they are not put into an actual section. Setting the section to ABS on x86-64 and I64 is not meaningful, and the ABS keyword is ignored by the x86-64 and I64 linkers.

Global/Local

GBL/LCL

When set to GBL, specifies that the linker should gather contributions to the section from all clusters and place them in the same segment. When set to LCL, the linker gathers sections into the same segment only if they are in the same cluster. The memory for a global section is allocated in the cluster that contains the first contributing module.

Shareability

SHR/NOSHR

Specifies that the section can be shared between several processes. Only used to sort sections in shareable images.

Executability

EXE/NOEXE

Specifies that the section contains executable code.

Writability

WRT/NOWRT

Specifies that the contents of a section can be modified at run-time.

Protected Vectors

VEC/NOVEC

Specifies that the section contains privileged change-mode vectors or message vectors. In shareable images, segments with the VEC attribute are automatically protected.

Solitary

SOLITARY

Specifies that the linker should place this section in its own segment. 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 section has not been initialized (NOMOD). The x86-64 and I64 linkers use this attribute to create demand zero segments (see Section 3.4.4). Only compilers can set this attribute (in ELF objects, the section type SHT_NOBITS). You can clear this attribute only by specifying the MOD keyword in the PSECT_ATTR= option.

Readability

RD

This keyword is ignored by the x86-64 and I64 linkers.

User/Library

USR/LIB

This keyword is ignored by the x86-64 and I64 linkers.

Short Data?

SHORT

When set this indicates that a data section should be put in one of the short sections. Compilers can set this attribute, in which case the user can not alter it.

Allocate section in P2 space

ALLOC_64BIT/
NOALLOC_64BIT

When set this indicates that the section should be allocated in P2 space instead of P0 space. The program may run but not execute correctly when initialized data is put in P2 space. Code and demand zero data do work properly.

To illustrate section creation, consider the sections created by the VSI C compiler when it processes the sample programs in the following examples:
Example 3.1. Sample Program MYTEST.C
#include <stdio.h>
extern int global_data;
extern int myadd( int, int );
extern int mysub( int, int );
main()
{
  int num1, num2, res1, res2;
  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>
int add_data = -1;
int myadd( int value_1, int value_2 )
{
  printf( "In MYADD.C\n" );
  add_data = value_1 + value_2;
  return add_data;
}

Example 3.3. Sample Program MYSUB.C
#include <stdio.h>
int global_data = 5;
int sub_data = -1;
int mysub( int value_1, int value_2 )
{
  printf( "In MYSUB.C\n" );
  sub_data = value_1 - value_2;
  return sub_data;
}
To see what sections the VSI C compiler creates for these modules, use the ANALYZE/OBJECT utility to examine each object module. Example 3.4 (x86-64) and Example 3.5 (I64) present excerpts from the analysis of the object module MYTEST.OBJ. Only the section definitions are included in the excerpts.
Example 3.4. Sections Generated by an Analysis of Example 3.1 on x86-64
$ anal/object/section=all/out=mytest.anl mytest.obj
   .
   .
   .
SECTION SUMMARY

Number  Type                 Name                              Flags
    0.  NULL                                                   ----------------------
    1.  PROGBITS             .text                             -AE-------------------
    2.  PROGBITS             .data                             WA--------------------
    3.  NOBITS               .bss                              WA--------------------
    4.  NOTE                 .note                             ----------------------
    5.  PROGBITS             .debug_info                       ----------------------
    6.  RELA                 .rela.debug_info                  ----------------------
    7.  PROGBITS             .debug_abbrev                     ----------------------
    8.  PROGBITS             .debug_aranges                    ----------------------
    9.  PROGBITS             .debug_macinfo                    ----------------------
   10.  PROGBITS             .debug_line                       ----------------------
   11.  RELA                 .rela.debug_line                  ----------------------
   12.  PROGBITS             .debug_loc                        ----------------------
   13.  PROGBITS             .debug_pubnames                   ----------------------
   14.  RELA                 .rela.debug_pubnames              ----------------------
   15.  PROGBITS             .debug_pubtypes                   ----------------------
   16.  RELA                 .rela.debug_pubtypes              ----------------------
   17.  PROGBITS             .debug_str                        ---S------------------
   18.  PROGBITS             .debug_ranges                     ----------------------
   19.  PROGBITS             $CODE$                            -AE--------------Shr--
   20.  RELA                 .rela$CODE$                       ----------------------
   21.  PROGBITS             .rodata                           -A--------------------
   22.  PROGBITS             .note.GNU-stack                   ----------------------
   23.  PROGBITS             .eh_frame                         -A--------------------
   24.  RELA                 .rela.eh_frame                    ----------------------
   25.  STRTAB               .shstrtab                         ----------------------
   26.  SYMTAB               .symtab                           ----------------------
   27.  STRTAB               .strtab                           ----------------------

Key for Flags: W (Write), A (Alloc), E (Execute), S (Strings), I (Info link), L (Link order), O (OS-specific processing), G (Group), Lrg (Large), Sho (Short), Nrc (No recovery code), Gbl (Global), Ovr (Overlaid), Shr (Shared), Vec (Vector), 64b (Allocate 64bit address), Pro (Protected)
   .
   .
   .
SECTION HEADER ENTRY 19. (0013)
"$CODE$"
Description                    Hex (<bitmask>)  Interpretation           Field Name
-----------                    ---------------  --------------           ----------
Name Offset in .shstrtab:             000000FA  "$CODE$"    2           shdr$l_sh_name
Section Type:                         00000001  SHDR$K_SHT_PROGBITS      shdr$l_sh_type
Section Flags:  3              0000000000400006                         shdr$q_sh_flags
 Data occupies memory:      <0000000000000002> SHDR$M_SHF_ALLOC          shdr$v_shf_alloc
 Machine instructions:      <0000000000000004> SHDR$M_SHF_EXECINSTR    shdr$v_shf_execinstr
 Shareable section:         <0000000000400000> SHDR$M_SHF_VMS_SHARED_  shdr$v_shf_vms_shared_
Section Load Address:         0000000000000000  Not Used (Object File)   shdr$pq_sh_addr
Offset to Section Data:       00000000000001B0                           shdr$q_sh_offset
Size of Section Data:         0000000000000163     4                    shdr$q_sh_size
Section Link Field:                   00000000                           shdr$l_sh_link
Section Info Field:                   00000000                           shdr$l_sh_info
Alignment Constraint:         0000000000000010     5                  shdr$q_sh_addralign
Entry Size (if table):        0000000000000000                           shdr$q_sh_entsize
   .
   .
   .
SECTION HEADER ENTRY 23. (0017)
".eh_frame"
Description                    Hex (<bitmask>)  Interpretation           Field Name
-----------                    ---------------  --------------           ----------
Name Offset in .shstrtab:             000000B8  ".eh_frame"              shdr$l_sh_name
Section Type:                         00000001  SHDR$K_SHT_PROGBITS      shdr$l_sh_type
Section Flags:                0000000000000002                           shdr$q_sh_flags
  Data occupies memory:      <0000000000000002> SHDR$M_SHF_ALLOC         shdr$v_shf_alloc
Section Load Address:         0000000000000000  Not Used (Object File)   shdr$pq_sh_addr
Offset to Section Data:       0000000000000340                           shdr$q_sh_offset
Size of Section Data:         0000000000000058                           shdr$q_sh_size
Section Link Field:                   00000000                           shdr$l_sh_link
Section Info Field:                   00000000                           shdr$l_sh_info
Alignment Constraint:         0000000000000008                           shdr$q_sh_addralign
Entry Size (if table):        0000000000000000                           shdr$q_sh_entsize

Example 3.5. Sections Generated by an Analysis of Example 3.1 on I64
$ anal/object/section=all/out=mytest.anl mytest.obj
   .
   .
   .
SECTION SUMMARY

Number  Type                 Name                              Flags
    0.  NULL                                                   -------------------------
    1.  STRTAB               .shstrtab                         -------------------------
    2.  NOTE                 .note                             -------------------------
    3.  PROGBITS             $CODE$                            -AE-----------------Shr--
    4.  PROGBITS             $LITERAL$                         -A------------------Shr--
    5.  NOBITS               $LINK$                            -A-----------------------
    6.  PROGBITS             .IA_64.unwind_info                -A-----------------------
    7.  IA_64_UNWIND         .IA_64.unwind              1     -A---L-------------------
    8.  STRTAB               .strtab                           -------------------------
    9.  SYMTAB               .symtab                           -------------------------
   10.  VMS_TRACE            .debug_line                       -------------------------
   11.  RELA                 .rela.debug_line                  -------------------------
   12.  VMS_TRACE            .trace_abbrev                     -------------------------
   13.  VMS_TRACE            .trace_info                       -------------------------
   14.  RELA                 .rela.trace_info                  -------------------------
   15.  VMS_TRACE            .trace_aranges                    -------------------------
   16.  RELA                 .rela.trace_aranges               -------------------------
   17.  RELA                 .rela.IA_64.unwind_info           -------------------------
   18.  RELA                 .rela.IA_64.unwind                -------------------------
   19.  RELA                 .rela$CODE$                       -------------------------

Key for Flags: W (Write), A (Alloc), E (Execute), S (Strings), I (Info link), L (Link order),
               O (OS-specific processing), G (Group), Sho (Short), Nrc (No recovery code),
               Gbl (Global), Ovr (Overlaid), Shr (Shared), Vec (Vector),
               64b (Allocate 64bit address), Pro (Protected)
   .
   .
   .

SECTION HEADER ENTRY 3. (0003)
"$CODE$"
Description                    Hex (<bitmask>)  Interpretation          Field Name
-----------                    ---------------  --------------          ----------
Name Offset in .shstrtab:             00000011  "$CODE$"     2         shdr$l_sh_name
Section Type:                         00000001  SHDR$K_SHT_PROGBITS     shdr$l_sh_type
Section Flags:  3            0000000400000006                          shdr$q_sh_flags
  Data occupies memory:      <0000000000000002> SHDR$M_SHF_ALLOC        shdr$v_shf_alloc
  Machine instructions:      <0000000000000004> SHDR$M_SHF_EXECINSTR   shdr$v_shf_execinstr
  Shareable section:         <0000000400000000> SHDR$M_SHF_VMS_SHARED  shdr$v_shf_vms_shared
Section Load Address:         0000000000000000  Not Used (Object File)  shdr$pq_sh_addr
Offset to Section Data:       0000000000000170                          shdr$q_sh_offset
Size of Section Data:         00000000000001C0     4                   shdr$q_sh_size
Section Link Field:                   00000000                          shdr$l_sh_link
Section Info Field:                   00000000                          shdr$l_sh_info
Alignment Constraint:         0000000000000010     5                   shdr$q_sh_addralign
Entry Size (if table):        0000000000000000                               shdr$q_sh_entsize
   .
   .
   .
SECTION HEADER ENTRY 7. (0007)
".IA_64.unwind"
Description                    Hex (<bitmask>)  Interpretation           Field Name
-----------                    ---------------  --------------           ----------
Name Offset in .shstrtab:             0000003C  ".IA_64.unwind"          shdr$l_sh_name
Section Type:                         70000001  SHDR$K_SHT_IA_64_UNWIND  shdr$l_sh_type
Section Flags:                0000000000000082                           shdr$q_sh_flags
  Data occupies memory:      <0000000000000002> SHDR$M_SHF_ALLOC         shdr$v_shf_alloc
  Preserve section order:    <0000000000000080> SHDR$M_SHF_LINK_ORDER  shdr$v_shf_link_order
Section Load Address:         0000000000000000  Not Used (Object File)   shdr$pq_sh_addr
Offset to Section Data:       0000000000000090                           shdr$q_sh_offset
Size of Section Data:         0000000000000030                           shdr$q_sh_size
Section Link Field: 1                00000003                           shdr$l_sh_link
Section Info Field: 1                00000006                           shdr$l_sh_info
Alignment Constraint:         0000000000000008                          shdr$q_sh_addralign
Entry Size (if table):        0000000000000000                           shdr$q_sh_entsize 

Note

You can also determine the sections in an object module after a link operation by looking at the Program Section Synopsis of an image map file, as illustrated in Example 3.8.

The items in the following list correspond to the numbered items in Example 3.4 and Example 3.5:

1

The unwind table section is the only section with the Link Order attribute set. The Link Order attribute signifies that the I64 linker must preserve section ordering (see Section 3.2.1.7).

2

The Name Offset indicates the name of the section.

3

Section flags indicate which section attributes are set. The attributes are listed by their ELF name. Note that the keywords are only listed when the bit in shdr$q_sh_flags is set. For example SHDR$M_SHF_EXECINSTR (Machine Instructions) is an attribute of the $CODE$ section.

4

The Size of Section Data indicates the number of bytes required for the section.

5

Alignment Constraint specifies the address boundary at which the linker must place a module's contribution to the section. The number shown here, 10 (hexadecimal), is a byte alignment and not an OpenVMS style (power of 2) of specifying the section attributes.

Figure 3.2 illustrates some of the sections created by the VSI C Compiler for the modules in Examples 3.1, 3.2, and 3.3 on x86-64 and I64 systems. The shaded areas represent the settings of the section attributes the linker considers when sorting the sections into image segments in an executable image. See Section 3.3.4 for more information about how the linker creates segments in an image.

Figure 3.2. Sections Created for Examples 3.1, 3.2, and 3.3
Sections Created for Examples 3.1, 3.2, and 3.3

3.3. Creating Segments

On x86-64 and I64 systems, the linker creates segments, which are analogous to image sections on Alpha and VAX systems. Segments define the memory requirements and page protection characteristics of an image.

To create segments, the linker processes the sections in the object modules specified in the link operation. The number and type of segments the linker creates depend on the input files and what is specified in the link operation. For more information on creating segments, see Section 3.3.1, which describes how the clustering of input files affects segment creation, and Section 3.3.2, which describes the effects of section attributes on segment creation.

3.3.1. Processing Clusters to Create Segments

To create segments, the linker processes the section definitions in the input files you specify in the LINK command. The linker processes these input files on a cluster-by-cluster basis (as described in Section 2.3.1).

Each cluster spawns segments into which sections are placed. However, the linker crosses cluster boundaries when processing sections with the global (GBL) attribute. (In ELF, GBL corresponds to SHF_VMS_GLOBAL). When the linker encounters a section with the global attribute, it searches all the previously processed clusters for a section with the same name and attributes and, if it finds one, places the new definition of the global section in the same cluster as the first definition of the program section.

The linker processes input files in the order by which they appear in the clusters. Note that on x86-64 and I64 systems, there are no based clusters, that is, the x86-64 and I64 linkers do not allow you to enter a base address with the CLUSTER= option. In addition, the linkers only have to process clusters once.

For more information about creating clusters, see the descriptions of the CLUSTER= and the COLLECT= option in Chapter 10.

A LINK command to create an image using the object modules in Section 3.2 is shown in Example 3.6.
The CLUSTER= option in this link operation causes the linker to create a cluster named MYSUB_CLUS, which contains the object module MYSUB.OBJ. The linker puts the object modules MYTEST.OBJ and MYADD.OBJ in the default cluster. These clusters appear on the linker's cluster list in the following order:
  1. MYSUB_CLUS

  2. DEFAULT_CLUSTER

  3. DECC$SHR

The linker always processes the default cluster after any user-specified cluster (MYSUB_CLUS). DECC$SHR was automatically picked up from IMAGELIB.OLB by the x86-64 and I64 linkers after the preceding clusters were processed and there were still unresolved symbols.

3.3.2. Combining Sections into Image Segments

The linker creates segments by grouping together sections with similar attributes. Within a segment, the linker organizes sections alphabetically by name. If more than one object module contributes to the same section, the linker lays out their contributions in the order it processes them.

Figure 3.5 shows how the linker groups the sections in the object modules from the sample link into segments, based on the setting of their significant attributes. In the figure, the settings of these significant attributes are represented by shading. (The figure considers attributes that are significant when creating executable images, and does not consider the SHR attribute as significant as it does with shareable images. Section 3.3.4 provides more information about which program section attributes are significant).

Note that in Figure 3.5, the relaxed definition from MYTEST.OBJ for GLOBAL_DATA appears in the MYSUB_CLUS cluster, even though the object module MYTEST.OBJ is in the default cluster. In general, the linker puts all contributions to a global section in the cluster in which it is first defined. In the relaxed case, the linker chooses the memory from the hard definition that occurs in MYSUB.OBJ.

Figure 3.5. Combining Sections into Image Segments — Part 1
Combining Sections into Image Segments — Part 1

Figure 3.6 continues the representation in Figure 3.5.

Figure 3.6. Combining Sections into Image Segments — Part 2
Combining Sections into Image Segments — Part 2

3.3.3. Traditional OpenVMS Image Attribute Terms and ELF Terms

The ELF format has fewer attributes than a traditional OpenVMS image. Some of the attributes are expressed in the segment header and some are not used on x86-64 and I64 systems. In addition, the linker creates an image file in the ELF format. However, for compatibility, the x86-64 and I64 linkers write a map file with image attribute names the same as for other OpenVMS systems. Other utilities like ANALYZE/IMAGE simply display the ELF terms. Table 3.3 shows how traditional OpenVMS image attribute terms are mapped ELF terms.
Table 3.3. Mapping OpenVMS Image Attribute Terms to ELF Terms

Traditional OpenVMS Image Attribute (prefix [E]ISD$M_)

Display Name in Linker Map

ELF Image Attribute (prefix PHDR$M_)

GBL

?

CRF

WRITE,SHARED

PF_VMS_SHARED,PF_W

Demand zero

DEMAND ZERO

Zero segment file size?

EXE

EXECUTABLE

PF_X

WRT

READ WRITE

PF_W

MATCHCTL

?

LASTCLU

?

FIXUPVEC

?

RESIDENT

RESIDENT

PF_VMS_RESIDENT?

VECTOR

VECTOR

PF_VMS_VECTOR

PROTECT

PROTECT

PF_VMS_PROTECT


Note

All sections, and therefore all segments, are position independent. Therefore, there is no PIC segment type on x86-64 and I64.

3.3.4. Processing Significant Section Attributes

When combining sections into segments, the linker considers only significant section attributes, that is, a subset of the section attributes. The set of significant attributes varies according to the type of image being created. When creating an executable image, the linker considers all combinations of the following attributes when combining sections into segments:
  • Writability (WRT/NOWRT)

  • Executability (EXE/NOEXE)

  • Protected vector (VEC/NOVEC)

  • Unmodified (NOMOD/MOD)

  • Short (SHORT/NOSHORT)

  • Allocation in P2 (ALLOC_64BIT/NOALLOC_64BIT)

When creating a shareable image, the linker considers all combinations of the following attributes when combining sections into segments:
  • Writability (WRT/NOWRT)

  • Executability (EXE/NOEXE)

  • Shareability (SHR/NOSHR)

  • Protected vector (VEC/NOVEC)

  • Unmodified (NOMOD/MOD)

  • Short (SHORT/NOSHORT)

  • Allocation in P2 (ALLOC_64BIT/NOALLOC_64BIT)

Tables 3.4 and 3.5 list all the possible combinations of the significant section attributes for executable images and shareable images. Note that the order in which the combinations appear in the table (each row) is the same order in which the linker processes them.

For example, the linker first processes all sections with the WRT, NOEXE, NOVEC, MOD, and NOSHORT attributes, creating a segment of sections with these attributes. The linker then processes all sections with the WRT, NOEXE, NOVEC, NOMOD, and NOSHORT attributes, creating another segment for those sections. The linker continues this processing until all the combinations of significant attributes have been processed and all the sections in the cluster have been placed in a segment.

The tables include only sections that are relocatable (with the REL attribute). Absolute sections (with the ABS attribute), by definition, can have no allocation (they contain only constants) and cannot contribute to a segment.

To simplify the tables, they do not include the ALLOC_64BIT attribute. ALLOC_64BIT only determines if the section should be allocated in P2 space. The default is NOALLOC_64BIT. This attribute does not influence the segment attributes of the created segment. But obviously, two sections, whose attribute only differ in ALLOC_64BIT, end up in different segments. On I64, the ALLOC_64BIT attribute can be set for all sections except the ones with the SHORT attribute.

The linker creates additional segments that cannot be controlled by the user (see Section 3.4.3).

The tables assume that the images are linked using the /DEMAND_ZERO qualifier, which is the default. (When this qualifier is specified, the linker groups sections that do not contain any data into demand-zero segments, allocating memory for the segment but not writing zeros to disk). If the image is linked with the /NODEMAND_ZERO qualifier, then the linker allocates space for the segment in the image file. Note that the /NODEMAND_ZERO qualifier does not affect how the linker sorts sections; it proceeds exactly as specified by the table. However, when the image is written, the linker allocates disk space for the segment and fills the space with zeros.

The tables also show how a particular combination of section attributes determines the attributes of the segment in which it is placed. For more information about segment attributes, see Section 3.3.6.
Table 3.4. Mapping Section Attributes to Segment Attributes for Executable Images

Significant Section Attribute Settings

Segment Attributes Set (prefix PHDR$V_)

NOEXE

WRT

NOVEC

MOD

NOSHORT

PF_R,PF_W

NOEXE

WRT

NOVEC

NOMOD

NOSHORT

PF_R,PF_W,Demand zero?

NOEXE

WRT

VEC

MOD

NOSHORT

PF_R,PF_W,PF_VMS_VECTOR,
PF_VMS_PROTECT

EXE

NOWRT

NOVEC

MOD

NOSHORT

PF_R,PF_X

EXE

WRT

NOVEC

MOD

NOSHORT

PF_R,PF_W,PF_X

EXE

NOWRT

VEC

MOD

NOSHORT

PF_R,PF_X,PF_VMS_VECTOR,
PF_VMS_PROTECT

EXE

WRT

VEC

MOD

NOSHORT

PF_R,PF_W,PF_X,PF_VMS_VECTOR,
PF_VMS_PROTECT

EXE

NOWRT

*?

NOMOD

NOSHORT

PF_R,PF_X

EXE

WRT

*

NOMOD

NOSHORT

PF_R,PF_W,PF_X

NOEXE

NOWRT

NOVEC

MOD

NOSHORT

PF_R

NOEXE

NOWRT

NOVEC

NOMOD

NOSHORT

PF_R,Demand zero?

NOEXE

NOWRT

VEC

MOD

NOSHORT

PF_R,PF_VMS_VECTOR,
PF_VMS_PROTECT

*

WRT

*

*

SHORT

PF_R,PF_W,PF_VMS_SHORT

*

NOWRT

*

*

SHORT

PF_R,PF_VMS_SHORT


Table 3.5. Mapping Section Attributes to Segment Attributes for Shareable Images

Significant Section Attribute Settings

Segment Attributes Set (prefix PHDR$V_)

NOSHR

NOEXE

WRT

NOVEC

MOD

NOSHORT

PF_R,PF_W

NOSHR

NOEXE

WRT

NOVEC

NOMOD

NOSHORT

PF_R,PF_W,Demand zero?

SHR

NOEXE

WRT

NOVEC

MOD

NOSHORT

PF_R,PF_W,PF_VMS_SHARED

SHR

NOEXE

WRT

NOVEC

NOMOD

NOSHORT

PF_R,PF_W,PF_VMS_SHARED

NOSHR

NOEXE

WRT

VEC

MOD

NOSHORT

PF_R,PF_W,PF_VMS_VECTOR,
PF_VMS_PROTECT

SHR

NOEXE

WRT

VEC

MOD

NOSHORT

PF_R,PF_W,PF_VMS_VECTOR,
PF_VMS_PROTECT

NOSHR

EXE

NOWRT

NOVEC

MOD

NOSHORT

PF_R,PF_X

NOSHR

EXE

WRT

NOVEC

MOD

NOSHORT

PF_R,PF_W,PF_X

SHR

EXE

NOWRT

NOVEC

MOD

NOSHORT

PF_R,PF_X,PF_VMS_SHARED

SHR

EXE

WRT

NOVEC

MOD

NOSHORT

PF_R,PF_W,PF_X,
PF_VMS_SHARED

NOSHR

EXE

NOWRT

VEC

MOD

NOSHORT

PF_R,PF_X,PF_VMS_VECTOR,
PF_VMS_PROTECT

NOSHR

EXE

WRT

VEC

MOD

NOSHORT

PF_R,PF_W,PF_X,
PF_VMS_VECTOR,
PF_VMS_PROTECT

SHR

EXE

NOWRT

VEC

MOD

NOSHORT

PF_R,PF_X,PF_VMS_VECTOR,
PF_VMS_PROTECT,PF_VMS_
SHARED

SHR

EXE

WRT

VEC

MOD

NOSHORT

PF_R,PF_W,PF_X,
PF_VMS_VECTOR,
PF_VMS_PROTECT,
PF_VMS_SHARED

*?

EXE

NOWRT

*

NOMOD

NOSHORT

PF_R,PF_X

*

EXE

WRT

*

NOMOD

NOSHORT

PF_R,PF_W,PF_X

NOSHR

NOEXE

NOWRT

NOVEC

MOD

NOSHORT

PF_R

NOSHR

NOEXE

NOWRT

NOVEC

NOMOD

NOSHORT

PF_R,Demand zero?

SHR

NOEXE

NOWRT

NOVEC

MOD

NOSHORT

PF_R,PF_VMS_SHARED

SHR

NOEXE

NOWRT

NOVEC

NOMOD

NOSHORT

PF_R,PF_VMS_SHARED

NOSHR

NOEXE

NOWRT

VEC

MOD

NOSHORT

PF_R,PF_VMS_VECTOR,
PF_VMS_PROTECT

SHR

NOEXE

NOWRT

VEC

MOD

NOSHORT

PF_R,PF_VMS_VECTOR,
PF_VMS_PROTECT,
PF_VMS_SHARED

*

*

WRT

*

*

SHORT

PF_R,PF_W,PF_VMS_SHORT

*

*

NOWRT

*

*

SHORT

PF_R,PF_VMS_SHORT

For example, Table 3.6 summarizes the settings of some significant attributes of the user controllable sections in the module MYSUB.OBJ (see Example 3.6).
Table 3.6. Significant Attributes of User Sections from Module MYSUB

User Section

Writability

Executability

Short Data

GLOBAL_DATA

WRT

NOEXE

NOSHORT

SUB_DATA

WRT

NOEXE

NOSHORT

$CODE$

NOWRT

EXE

NOSHORT

$LITERAL$

NOWRT

NOEXE

NOSHORT

The linker puts these four sections into three segments because only two have compatible attributes.
  • The GLOBAL_DATA and SUB_DATA sections have identical attributes, including the WRT attribute.

  • The $CODE$ and $LITERAL$ sections have the NOWRT attribute and differ in the EXE attribute.

The linker collects all these sections in segments in the named cluster MYSUB_CLUS, as requested with the CLUSTER= option in Example 3.6.

The linker performs similar processing of the sections in the default cluster in Example 3.6. The Image Segment Synopsis section of the map file lists the clusters the linker created and lists the segments it created for each cluster. This map section also describes the layout of the image in memory, including the base address of each segment within the image. Example 3.7illustrates an excerpt of the Image Segment Synopsis section from the map file produced with the sample link (Example 3.6). Note that for x86-64 and I64, the listing does not include clusters for shareable images, like the VSI C Run-Time Library.
Example 3.7. Segment Information in a Map File
                                   +------------------------+
                                   ! Image Segment Synopsis !
                                   +------------------------+
Seg#  Cluster            Type       Base Addr     Protection  Attributes
----  -------            ----       ---------     ----------  ----------
   0  MYSUB_CLUS         LOAD       00010000      READ WRITE
   1                     LOAD       00020000      READ ONLY   EXECUTABLE
   2                     LOAD       00030000      READ ONLY
   3                     LOAD       00040000      READ ONLY   [UNWIND] 12
   4  DEFAULT_CLUSTER    LOAD       00050000      READ WRITE
   5                     LOAD       00060000      READ ONLY   EXECUTABLE
   6                     LOAD       00070000      READ ONLY
   7                     LOAD       00080000      READ ONLY   [UNWIND] 12
   8                     LOAD       00090000      READ ONLY   SHORT 1
   9                     DYNAMIC  Q-00000000
                                    80000000      READ ONLY 1

1

Linker created segments which can not be controlled by the user (see Section 3.4.3).

2

UNWIND is not a segment attribute and is therefore printed in brackets. Marking the unwind segment here, helps to differentiate this segment from segments into which other sections are collected.

For more information about the image segment synopsis section of a map file, see Chapter 5.

To find out which sections the linker placed in each segment, look at the Program Section Synopsis section of the map file. This section lists all the sections in each cluster and lists the contributions (the number of bytes) to each section from each object module. By comparing the base address of the sections with the base address of the segments in the Image Segment Synopsis section, you can tell in which segment the sections appear. Example 3.8 is an excerpt from the Program Section Synopsis section of the map file produced by the sample link operation (Example 3.6).
Example 3.8. Section Information in a Map File
                               +--------------------------+
                               ! Program Section Synopsis !
                               +--------------------------+
Psect Name Module/Image   Base     End       Length            Attributes 1
---------- ------------   ----     ---       ------            ----------
GLOBAL_DATA             00010000 00010003 00000004 (   4.) NOEXE,  WRT
           MYSUB        00010000 00010003 00000004 (   4.) Initializing Contribution
SUB_DATA                00010010 00010013 00000004 (   4.) NOEXE,  WRT
           MYSUB        00010010 00010013 00000004 (   4.) Initializing Contribution
$CODE$                  00020000 0002008F 00000090 ( 144.)   EXE,NOWRT
           MYSUB        00020000 0002006F 00000070 ( 112.)
           <Linker>     00020070 0002008F 00000020 (  32.)
$LITERAL$               00030000 0003000C 0000000D (  13.) NOEXE,NOWRT
           MYSUB        00030000 0003000C 0000000D (  13.)
$LINKER UNWIND$         00040000 00040017 00000018 (  24.) NOEXE,NOWRT
           MYSUB        00040000 00040017 00000018 (  24.)
$LINKER UNWINFO$        00040018 0004002F 00000018 (  24.) NOEXE,NOWRT
           MYSUB        00040018 0004002F 00000018 (  24.)
ADD_DATA                00050000 00050003 00000004 (   4.) NOEXE,  WRT
           MYADD        00050000 00050003 00000004 (   4.) Initializing Contribution
$CODE$                  00060000 000602CF 000002D0 ( 720.)   EXE,NOWRT
           MYTEST       00060000 000601BF 000001C0 ( 448.)
           MYADD        000601C0 0006022F 00000070 ( 112.)
           <Linker>     00060230 000602CF 000000A0 ( 160.)
$LITERAL$               00070000 0007003C 0000003D (  61.) NOEXE,NOWRT
           MYTEST       00070000 00070027 00000028 (  40.)
           MYADD        00070030 0007003C 0000000D (  13.)
$LINKER UNWIND$         00080000 00080047 00000048 (  72.) NOEXE,NOWRT
           MYTEST       00080000 0008002F 00000030 (  48.)
           MYADD        00080030 00080047 00000018 (  24.)
$LINKER UNWINFO$        00080048 000800A7 00000060 (  96.) NOEXE,NOWRT
           MYADD        000601C0 0006022F 00000070 ( 112.)
           <Linker>     00060230 000602CF 000000A0 ( 160.)
$LITERAL$               00070000 0007003C 0000003D (  61.) NOEXE,NOWRT
           MYTEST       00070000 00070027 00000028 (  40.)
           MYADD        00070030 0007003C 0000000D (  13.)
$LINKER UNWIND$         00080000 00080047 00000048 (  72.) NOEXE,NOWRT
           MYTEST       00080000 0008002F 00000030 (  48.)
           MYADD        00080030 00080047 00000018 (  24.)
$LINKER UNWINFO$        00080048 000800A7 00000060 (  96.) NOEXE,NOWRT
           MYTEST       00080048 0008008F 00000048 (  72.)
           MYADD        00080090 000800A7 00000018 (  24.)
$LINKER SDATA$          00090000 000900B7 000000B8 ( 184.) NOEXE,NOWRT,SHORT
           <Linker>     00090000 000900B7 000000B8 ( 184.)

1

To fit on a page, the attribute column of the Program Section Synopsis is reduced to show only the attributes listed in Table 3.6.

For more information about the Program Synopsis Section of a map file, see Section 5.2.4.

3.3.5. Allocating Memory for Segments

When it creates a segment, the linker allocates enough memory for the image segment to accommodate all the sections it contains. Each section definition includes its size.

The linker aligns segments on CPU-specific page boundaries. Within a segment, the linker assigns to each section a virtual address relative to the base address of the segment.

Concatenated Sections

If the sections have the concatenated (CON) attribute set, the linker positions the sections one after the other within a segment, inserting padding bytes between the sections if necessary to achieve the alignment requirement of a particular contribution to a section. The linker retains the alignment specified for each section contribution but uses the largest alignment of a contributing module as the alignment of the whole section.

With a PSECT_ATTR= option you can align the section within the segment. However, aligning the section does not influence the alignment of the individual contributions to the section. The linker follows the compiler's alignment specification when it aligns each individual contribution. If you specify a smaller alignment for a section than any compiler-assigned alignment from all contributions, the linker issues a warning.

Overlaid Program Sections

If the sections have the overlaid (OVR) attribute set, the linker uses the same start address for the sections so that they occupy the same virtual memory (that is, the sections overlay each other). For overlaid sections, the linker allocates enough space to accommodate the largest of all the section contributions. Note that the linker does not generate a warning message if the contributions specify different size allocations.

Any module can initialize the contents of an overlaid program section. However, the x86-64 and I64 linkers only allow compatible initializations for the same section data. See Section 3.4.1 for an explanation of a compatible initialization.

Assigning Virtual Addresses

The linker allocates virtual memory to all the segments beginning at a page size boundary.

The x86-64 linker places code segments in the P2 region by default and uses the default page size of 2000 hexadecimal. The /SEGMENT=CODE=P0 option can be specified to place code segments in the P0 region. Non-code segments (without the ALLOC_64BIT attribute specified) are placed in the P0 region by default.

The I64 linker places segments in the P0 region by default and uses the default page size of 10000 hexadecimal. The /SEGMENT=CODE=P2 option can be specified to place segments in the P2 region.

For x86-64 and I64 linking, you can specify the page size value using the /BPAGE qualifier. For information about the /BPAGE qualifier, see Chapter 10.

On x86-64 systems, the first P0 segment is placed at 2000 hexadecimal. On I64 systems, the first P0 segment is placed at 10000 hexadecimal, leaving the first page unused as a guard page. The first P2 segment (for example, containing sections with the ALLOC_64BIT attribute) is placed at 80000000 hexadecimal. However, all segment base addresses are only suggestions for the OpenVMS image activator. The image activator can determine a different base address for each segment (within the address region) to map the segment. This is always the case for shareable images. This is also the case for all images being installed as resident images, where the INSTALL utility determines the addresses. Unlike the Alpha and VAX platforms, executable images can also have their segment base addresses determined by the image activator or the INSTALL utility.

An image not activated by the OpenVMS image activator might need a specific base address for the first segment. For such an image, you can specify this address with the /BASE_ADDRESS qualifier. (For information about the /BASE_ADDRESS qualifier, see Chapter 10).

Because the linker processes clusters in the order in which they appear in the cluster list, the virtual address space of the final image will generally contain contiguous segments of consecutive clusters on the basis of their order in the cluster list.

After allocating memory for all segments in a cluster, the linker relocates their contents by performing the following processing:
  1. Relocating each section in the segment. The linker adds the starting virtual address of the segment to the relative offset of the section from the base of the segment.

  2. Relocating each global symbol in the section. The linker adds the newly calculated section virtual address to the relative offset of the global symbols from the base of the section.

3.3.6. Segment Attributes

When creating segments, the linker assigns attributes to the segment based on the attributes of the sections it contains. The segment attributes describe certain characteristics of the portion of memory they represent, for example, the protection characteristics. For example, a segment that contains sections with the writability attribute also has the writability attribute set. Tables 3.4 and 3.5 include the segment attributes associated with a segment that contains sections with a particular set of attributes. Table 3.7 lists all the segment attributes. Segment attributes, like section attributes, are Boolean values that are either on or off.

Table 3.7. Segment Attributes

Attribute

Symbol (prefix PHDR$V_)

Function

Executability

PF_X

The mapping of the EXE attribute from the section.

Write

PF_W

The mapping of the WRT attribute from the section.

Readability

PF_R

All segments have this attribute set.

Modified if Relocated

PF_VMS_NOWRIT_RELOC

The attribute is set by the linker if the segment contents is changed when relocated. The image activator sets the protection to NOWRT after the relocation.

Initial Code

PF_VMS_INITALCODE

This attribute is reserved to OpenVMS.

Resident

PF_VMS_RESIDENT

This attribute is reserved to OpenVMS.

Vectored

PF_VMS_VECTOR

The mapping of the VEC attribute from the section.

Protected

PF_VMS_PROTECT

Protect indicates that a section is protected. The linker sets the PF_VMS_PROTECT attribute whenever PF_VMS_VECTOR is set. PROTECT is also set if the /PROTECT qualifier is used, or if the cluster that the segment is spawned from came after a PROTECT=YES option (and before a PROTECT=NO option).

Modified by Fix-Ups

PF_VMS_NOWRIT_FIXUP

The attribute is set by the linker if the segment contents is changed for fix-ups. The image activator sets the protection to NOWRT after the fix-ups are applied.

Short Data?

PF_VMS_SHORT

The mapping of the SHORT attribute from the section.

Shared

PF_VMS_SHARED

The SHR mapping of the SHR attribute from the sections.

The Image Segment Synopsis section of a map file lists the attributes of each segment created in the Protection and Attributes columns. See Example 3.7 for an illustration and see Table 3.3 for the display names in these columns. You can also get a listing of all the segments created by the linker by using the ANALYZE/IMAGE utility. The output generated by this utility includes a list of all the segments that make up the image, with their attributes. An excerpt from the analysis of the image file MYTEST.EXE is shown in Example 3.9.
Example 3.9. Image Segment Descriptions in an ANALYZE/IMAGE Display
SEGMENT HEADER ENTRY 0.
Offset    Description                    Hex (<bitmask>)  Interpretation
------    -----------                    ---------------  --------------
00000000  Segment Type:                         00000001  PHDR$K_PT_LOAD
00000004  Segment Flags:                        00000006 1
          Segment is writeable:                 <00000002> PHDR$M_PF_W
          Segment is readable:                  <00000004> PHDR$M_PF_R
00000008  Offset to Segment Data:       0000000000000400 2
00000010  Memory Virtual Address:       0000000000010000 3
00000018  Page Fault Cluster Size:      0000000000000000 4
00000020  Segment Size in File:         0000000000000014 5
00000028  Segment Size in Memory:       0000000000000014 6
00000030  Alignment Constraint:         0000000000000010
SEGMENT HEADER ENTRY 1. (0001)               56. (0038) bytes
Offset    Description                    Hex (<bitmask>)  Interpretation
------    -----------                    ---------------  --------------
00000000  Segment Type:                         00000001  PHDR$K_PT_LOAD
00000004  Segment Flags:                        00000005 1
          Segment is executable:                <00000001> PHDR$M_PF_X
          Segment is readable:                  <00000004> PHDR$M_PF_R
00000008  Offset to Segment Data:       0000000000000600 2
00000010  Memory Virtual Address:       0000000000020000 3
00000018  Page Fault Cluster Size:      0000000000000000 4
00000020  Segment Size in File:         0000000000000090 5
00000028  Segment Size in Memory:       0000000000000090 6
00000030  Alignment Constraint:         0000000000000010
   .
   .
   .
The items in the following list correspond to the numbers in Example 3.9:

1

The settings of segment attributes. Table 3.7 lists these attributes.

2

The offset in the image file in bytes, at which the segment begins.

3

The virtual base address assigned to the segment by the linker. Note that at run-time the image activator may decide to map this segment at a different address.

4

The number of page lets that should be mapped in when the initial page fault occurs. You can set this value by using the CLUSTER= option.

5

The size of the segment in the image file, expressed in bytes. Note that demand zero segments have a file size of zero but a nonzero memory size.

6

The size of the segment in the memory, expressed in bytes. For the shown segments, both sizes are identical so they are not demand zero segments.

3.3.7. Controlling Segment Creation

You can control how the linker combines sections into segments in the following ways:
  • By modifying the attributes of sections

  • By using the SOLITARY attribute

  • By using the /SEGMENT_ATTRIBUTES qualifier

  • By putting object modules into named clusters

  • By collecting sections

3.3.7.1. Modifying Section Attributes

The linker combines sections in the same cluster into the same segment if they have the same settings for the significant section attributes. To force the linker to put the sections into different segments, change the attributes of one of the sections by using the PSECT_ATTR= option.

For example, in the sample link operation, the GLOBAL_DATA section has the WRT attribute. But its contents, the variable global_data, serves as a constant (initialized but never changed). If you want the GLOBAL_DATA section to appear in a read-only segment, change the writability attribute. For example, in the following link of the sample programs, the writability attribute is set to NOWRT.
$ LINK/MAP/FULL MYTEST,MYADD,SYS$INPUT/OPT
CLUSTER=MYSUB_CLUS,,,MYSUB
PSECT_ATTR=GLOBAL_DATA,NOWRT
Ctrl/Z
Example 3.10 shows the image and program section synopsis for the second link.
Example 3.10. Image and Program Section Synopsis of Second Link
                               +--------------------------+
                               ! Program Section Synopsis !
                               +--------------------------+
Psect Name Module/Image   Base     End       Length            Attributes
---------- ------------   ----     ---       ------            ----------
SUB_DATA                00010000 00010003 00000004 (   4.) NOEXE,  WRT,NOVEC,  MOD
             MYSUB      00010000 00010003 00000004 (   4.) Initializing Contribution
$CODE$                  00020000 0002008F 00000090 ( 144.) EXE,NOWRT,NOVEC,    MOD
             MYSUB      00020000 0002006F 00000070 ( 112.)
             <Linker>   00020070 0002008F 00000020 (  32.)
$LITERAL$               00030000 0003000C 0000000D (  13.) NOEXE,NOWRT,NOVEC,  MOD
             MYSUB      00030000 0003000C 0000000D (  13.)
GLOBAL_DATA             00030010 00030013 00000004 (   4.) NOEXE,NOWRT,NOVEC,  MOD
             MYSUB      00030010 00030013 00000004 (   4.) Initializing Contribution
$LINKER UNWIND$         00040000 00040017 00000018 (  24.) NOEXE,NOWRT,NOVEC,  MOD
             MYSUB      00040000 00040017 00000018 (  24.)
   .
   .
   .

Note that there is no change in the number and attributes of the segments. However, the GLOBAL_DATA section moved into an existing read-only segment. (It also moved in the address space.) The GLOBAL_DATA section is now in the same segment as the read-only $LITERAL$ section, which it follows, based on alphabetical order (for a comparison, see Example 3.8).

3.3.7.2. Alternate Way to Modify Section Attributes

With the /SEGMENT_ATTRIBUTE qualifier, you can change some attributes for a class of sections. The keywords SHORT_DATA, CODE, and SYMBOL_VECTOR define obvious classes of sections: all sections with the SHORT, all sections with the EXE attribute, and the symbol vector section. The attribute to change depends on the class.

For short data sections, you can set WRT. For executable sections, you can set or clear the ALLOC_64BIT attribute. For the I64 symbol vector, you can set or clear the SHORT attribute. For the x86-64 symbol vector, setting or clearing the SHORT attribute is ignored. To be compatible with other DCL command qualifiers, for the first two classes, more descriptive names are used: WRITE for WRT, P0 for NOALLOC_64BIT, P2 for ALLOC_64BIT. For information about the /SEGMENT_ATTRIBUTE qualifier, see Chapter 10.

With /SEGMENT_ATTRIBUTE, the section attributes are changed before the sections are collected into segments. As a result, the effect is the same as using the PSECT_ATTR= for each member of the class. However, /SEGMENT_ATTRIBUTE can do more because even the linker-generated sections are members of the classes (for example, $LINKER SDATA$ and $LINKER SYMBOL_VECTOR$).

On I64, to move all code into P2 space, you can use the /SEGMENT_ATTRIBUTE=CODE=P2 command qualifier. On x86, to move all code into P0 space, you can use the /SEGMENT_ATTRIBUTE=CODE=P0 command qualifier. Please note, that if you use clusters in the same link command (with linker options) and if EXE sections are put on specific clusters, setting ALLOC_64BIT does not change the per cluster segment creation. You then will see more than one executable segment with base addresses in P2 space.

For I64 linking, the /SEGMENT_ATTRIBUTE=SHORT_DATA=WRITE command qualifier allows you to combine the read-only and the read-write short data segments into a single segment, reclaiming up to 65,535 bytes of unused, read-only space (default value for /BPAGE). When setting SHORT_DATA to WRITE, your program may accidentally write to formerly read-only data. Therefore, this qualifier is recommended only if your short data segment has reached the limit of 4 MB.

On I64, the linker stores the shareable image's symbol vector into the read-only short data segment by default. That is, the linker created section $LINKERSYMBOL_VECTOR$ has the SHORT attribute. By specifying /SEGMENT_ATTRIBUTE=SYMBOL_VECTOR=NOSHORT, the linker clears the SHORT attribute of the section and, therefore, collects the symbol vector into a read-only data segment of the default cluster. If the shareable image has no read-only data segment, one is created. This frees up the symbol vector entries from the short data. This qualifier is recommended only if your short data segment has reached the limit of 4 MB.

3.3.7.3. Manipulating Cluster Creation

In general, the linker creates segments on a per-cluster basis; that is, only sections within a particular cluster can contribute to segment creation. (The linker can collect sections with the global attribute from all clusters into a single segment. However, there is one exception: sections with the I64 SHORT attribute can not be collected.) To ensure that a section appears in a particular segment, put the section in a specific cluster.

For example, in the sample link operation illustrated in Example 3.6, the linker puts all the sections in the object module MYSUB.OBJ in the cluster named MYSUB_CLUS because the CLUSTER=option is specified. If you wanted to group all of the sections that contain code from all the other clusters into the MYSUB_CLUS cluster, you could specify the COLLECT= option, as in the following example.

Note

Section naming conventions are language processor specific. By convention, most OpenVMS language processors put the code they generate into sections named $CODE$. An exception is the VSI C++ compiler which puts code into a section named .text.
$ LINK/MAP/FULL MYTEST, MYADD, SYS$INPUT/OPT
CLUSTER=MYSUB_CLUS,,,MYSUB
COLLECT=MYSUB_CLUS,$CODE$
Ctrl/Z

3.3.7.4. Isolating a Section into a Segment

You can specify that the linker places a particular section into its own segment. This can be useful for programs that map data into predefined locations within an image.

To isolate a section into a segment, specify the SOLITARY attribute of the section using the PSECT_ATTR= option. For example, to isolate the GLOBAL_DATA section in the sample link into its own segment, specify the following:
$ LINK/MAP/FULL MYTEST,MYADD,SYS$INPUT/OPT
CLUSTER=MYSUB_CLUS,,,MYSUB
PSECT_ATTR=GLOBAL_DATA,SOLITARY
Ctrl/Z

When mapping data into an existing location in the virtual memory of your program using the Create and Map Global Section ($CRMPSC) system service or the Map Global Section ($MGBLSC) system service, you must specify an address range (in the inadr argument) that is aligned on a CPU-specific page boundary. Because the linker aligns segments on CPU-specific page boundaries and the section in which the global section is to be mapped is the only section in the segment, you ensure that the start address of the location is page aligned. In addition, because x86-64 and I64 systems must map at least an entire page of memory at a time, using the SOLITARY attribute allows you to ensure that no other data is in the segment. By default, the linker creates the next segment on the next page boundary so that no data can be overwritten.

Note that SHORT sections can not be isolated. That is, an attempt to set the SOLITARY attribute to a SHORT section is ignored by the I64 linker and a warning is issued.

3.4. Initializing an Image on x86-64 and I64 Systems

After allocating memory for the image, the linker initializes the image by writing the binary contents into the segment buffers, that is, by copying section data from the object modules. In addition, the linker inserts the addresses of symbols within the image wherever they are referenced.

3.4.1. Handling of Initialized Overlaid Sections

On x86-64 and I64 systems, the ELF object language does not implement the feature of the Alpha and VAX object language which allows the initialization of portions of the sections. When an initializations made, the entire section is initialized. Subsequent initializations of this section can be performed only if they are compatible. A subsequent initialization is compatible if the number of initializers are less or equal to the existing ones and all the values match or if there are more initializers than the existing ones but all the existing values match.

The linker receives entire sections from the compilers that are already initialized. The linker reads all the applicable module initializations to the section and checks for compatible initializations. If they are not compatible, the linker issues the following error message:
%ILINK-E-INVOVRINI, incompatible multiple initializations for
 overlaid section
        section:  <section name>
        module:   <module name for first overlaid section>
        file:  <file name for first overlaid section>
        module:  <module name for second overlaid section>
        file:  <file name for second overlaid section>

In this message, the linker lists the first module, which contributes an initialization, and the first module with an incompatible initialization. Note that this is not a full list of all incompatible initializations; it is simply the first one that the linker encounters.

In the Program Section Synopsis of the linker map, each module with an initialization is flagged as Initializing Contribution. Use this information to identify and resolve all the incompatible initializations.

Example 3.11 shows the additional information in the map file shown in Example 3.12.
Example 3.11. Compatible Initializations
$ cre one.c
#pragma extern_model common_block
int common_data[]={0,1,2,3};
int main (void) {return 1;}
Ctrl/Z
$ cc one
$ cre two.c
#pragma extern_model common_block
int common_data[]={0,1};
Ctrl/Z
$ cc two
$ cre three.c
#pragma extern_model common_block
int common_data[]={0,1,2,3,4,5,6,7};
Ctrl/Z
$ cc  three
$ link/map one,two,three
$
Example 3.12 shows the program section synopsis of the linker map for Example 3.11. Note that the Align and Attributes fields normally continue after the Length field but were modified to fit on the page.
Example 3.12. Linker Map Showing Program Section Synopsis
                               +--------------------------+
                               ! Program Section Synopsis !
                               +--------------------------+

Psect Name Module/Image   Base     End       Length            Attributes
---------- ------------   ----     ---       ------            ------------

COMMON_DATA             00010000 0001001F 00000020 (  32.) OVR,NOEXE, WRT,NOVEC, MOD
           ONE          00010000 0001000F 00000010 (  16.) Initializing Contribution
           TWO          00010000 00010007 00000008 (   8.) Initializing Contribution
           THREE        00010000 0001001F 00000020 (  32.) Initializing Contribution
Example 3.13 shows an incompatible initialization and the resulting linker message.
Example 3.13. Incompatible Initialization
$ cre four.c
#pragma extern_model common_block
int common_data[]={0,1,0,0};
Ctrl/Z
$ cc /extern=common four
$ link one,two,three,four
%ILINK-E-INVOVRINI, incompatible multiple initializations for
 overlaid section
        section: COMMON_DATA
        module: ONE
        file: DISK$USER:[JOE]ONE.OBJ;1
        module: FOUR
        file: DISK$USER:[JOE]FOUR.OBJ;1

Note that the sources use a #pragma to force the extern common model. For OpenVMS, the default extern model is the relaxed reference/definition (ref/def) model. In that model, only one explicit initialization is allowed. That is, even identical initializations result in a linker MULDEF message.

3.4.2. Writing the Binary Contents of Segments

An object module contains sections with compiler-initialized data. The linker copies the data into the corresponding segment buffer. For overlaid sections, subsequent data overwrites already existing data. With the compatibility check for overlaid sections, (as explained in Section 3.4.1) the linker ensures, that existing data is only overwritten with identical values.

If the compilers initialized data with binary zeros, the buffer contains zeros as well. To save some disk space, the linker can check a segment buffer contents for trailing zeros. This time-consuming operation is not performed by default. You can request it with the PER_PAGE keyword for the /DEMAND_ZERO qualifier. Similar to a demand-zero section, the trailing zeros are not written to the image file. The amount of trailing demand-zero bytes for such a segment is expressed as the difference between the memory size (including these zeros) and the file size (excluding them). For information about the PER_PAGE keyword and the /DEMAND_ZERO qualifier, see Chapter 10.

An object module can contain information to express link time calculations for addresses, offsets or values. For example, an offset between two global variables defined in two different object modules can be calculated by the linker and can be used to initialize another global variable. The link time expressions in the object modules are implemented in object relocations. The linker processes them similar to the other object relocations. The calculation is done in a linker internal accumulator and the results written into the corresponding buffer of the segment.

When this processing is complete, the linker has written the binary contents of all code and data sections into segment buffers in its own address space.

3.4.3. Other Image Segments

This section describes other segments created by the x86-64 and I64 linkers:
  • Global Offset Table segments (x86-64 only)

  • Unwind segments (I64 only)

  • Short data segments (I64 only)

  • Signature segments (I64 only)

  • Dynamic segments

Section 3.4.3.1

Section 3.4.3.2

Section 3.4.3.3

Section 3.4.3.4

Section 3.4.3.5

3.4.3.1. Global Offset Table Segments (x86-64 Only)

The x86-64 linker creates Global Offset Table (GOT) segments when required by code. They contain addresses of procedures and data. The code uses these addresses to access data and call procedures.

Each code segment in an x86-64 image usually has an associated GOT segment adjacent to it in memory. There are no linker options or qualifiers to control placement of a GOT.

3.4.3.2. Unwind Segments (I64 Only)

Creation of the unwind segments can not be controlled with linker options or qualifiers. You can indirectly influence where they appear by moving code sections. For each cluster with a code segment there is an unwind segment. That is, to move all unwind information into one segment you can collect all code sections on one cluster. Both, the sections and the segments, are listed in the corresponding sections of the linker map.

3.4.3.3. Short Data Segment (I64 Only)

The I64 linker usually creates two short data segments. One of them is read-only and the other is read-write. They must be placed by the image activator at addresses that are the same relative distance apart as the linker originally put them in the image. In other words, they must be relocated together as if they were one segment. Note that the qualifier /SEGMENT_ATTRIBUTE=SHORT=WRITE can be used to combine the two short data segments into one read-write segment.

3.4.3.4. Signature Segment (I64 Only)

In case the generated image needs to interoperate with translated images, the I64 linker may create another segment to save procedure signature information. Such a segment is only necessary if the signature can not be stored with the function descriptor (because the signature is greater than 8 bytes, a quadword). Signatures describe the calling interface for translated images and are described in Section 3.2.1.5.

3.4.3.5. Dynamic Segment

The x86-64 and I64 linkers create a segment with image activator information, referred to as the dynamic segment. This segment contains the necessary information about the shareable images on which the image depends, including the required match control and pointers to the fix-ups. It contains linker flags, for example, if the image was linked with /DEBUG and (by default) should run under the control of the OpenVMS debugger. For shareable images, the dynamic segment contains a pointer to the symbol vector. For all images, it includes fix-up and image relocation information.

The linker flags are initially set by the linker. For x86-64 and I64 images, you can display the settings using the SHOW IMAGE command. The SET IMAGE command enables you to manipulate individual flags or to restore the initial linker setting. If you change the flags, you change the behavior of the image at activation or run-time.

Note

Changing linker flags might result in unexpected image behavior.

Table 3.8 shows the flags set by the linker.
Table 3.8. Linker Flags

Flag?

Description

Set by Linker Qualifier or Option

CALL_DEBUG

SYS$IMGSTA checks this flag to determine whether it calls the debugger.

See Table 3.9

DBG_IN_DSF

Debug information is present in the DSF file.

See Table 3.9

DBG_IN_IMG

Debug information is present in the image file.

See Table 3.9

EXE_INIT

Image has a pointer to EXE$INITIALIZE.

Reserved to OpenVMS

IMGSTA

Image execution is to begin by calling SYS$IMGSTA. The image activator includes SYS$IMGSTA as the first address in the (traditional VMS style) transfer vector.

See Table 3.9

INITIALIZE

Image has a pointer to LIB$INITIALIZE.

If at least one of the input object modules has a reference to LIB$INITIALIZE.

MAIN

Image has a main transfer address.

In at least one of the input object modules a procedure was flagged as a main entry point by the corresponding language processor.

MKTHREADS

Enable multiple kernel thread use.

/THREADS_ENABLE=MULTIPLE_
KERNEL_THREADS

NOP0BUFS

No P0 buffers for RMS image I/O.

IOSEGMENT=,NOP0BUFS

P0IMAGE

Image is loaded only to P0 space.

/P0IMAGE

SIGNATURES

TIE Signatures are present.

/NONATIVE_ONLY

TBK_IN_DSF

Traceback records are present in the DSF file.

See Table 3.9

TBK_IN_IMG

Traceback records are present in the image file.

See Table 3.9

UPCALLS

User thread up calls are enabled.

/THREADS_ENABLE=UPCALLS

Table 3.9 shows flags determined by a combination of linker qualifiers.
Table 3.9. Flag Settings Determined by /TRACEBACK, /DEBUG, and /DSF

Qualifier

IMGSTA?

CALL_
DEBUG?

TBK_IN
_IMG?

DBG_IN
_IMG?

TBK_IN
_DSF?

DBG_IN
_DSF?

/NoTrace /NoDebug /NoDSF

0

0

0

0

0

0

/Trace /NoDebug /NoDSF

1

0

1

0

0

0

/NoTrace /Debug /NoDSF

1

1

1

1

0

0

/Trace /Debug /NoDSF

1

1

1

1

0

0

/NoTrace /NoDebug /DSF

0

0

0

0

1

1

/Trace /NoDebug /DSF

1

0

1

0

1

1

/NoTrace /Debug /DSF

1

1

1

0

1

1

/Trace /Debug /DSF

1

1

1

0

1

1

  • On x86-64 and I64 systems, the value of SYS$IMGSTA is not included in the image's transfer array; only a flag that indicates it is to be called. The image activator already knows the value of SYS$IMGSTA.

  • Linker flags do not appear in a DSF file. DSF files are not activated by the image activator (they have no dynamic segment and, therefore, no linker flags field).

  • When /DSF is specified along with /TRACEBACK or /DEBUG, the VMS_LF_TBK_IN_IMG (traceback in image) flag is set. This is a difference in behavior from Alpha, where traceback records are not included in the image when /TRACEBACK/DSF or /DEBUG/DSF is specified. Note that debugger records do not get copied to an image whenever /DEBUG/DSF is specified. Here, /DEBUG causes only the VMS_LF_IMGSTA bit to be set in the image.

The dynamic segment contains additional data taken from the linker qualifier keywords or values, or option arguments. Other than these, you can not influence the creation or contents of the dynamic segment.

Note that the linker, by default, assigns a P2 base address for the dynamic segment. The image activator needs the dynamic segment at image activation time, the segment is not used at run-time. The image activator maps the dynamic segment at the proposed P2 address and processes its contents. The image activator maps the dynamic segments of the shareable images as well, also into P2 space. When all of the information of all these dynamic segments is processed, the image activator may unmap all of these segments.

Fixing Up Addresses, Relocating Images

While the linker assigns addresses to the segments of executable and shareable images in memory, their actual final address is determined by the image activator. Because the linker does not know the actual address that an image will be loaded, it cannot initialize external symbol references nor even symbol references internal to the image itself. In both cases, the image requires a virtual address to make the reference.

In the first case, the image needs to refer to external symbols which are usually resolved from shareable images that will be loaded in the future when the image is activated. For such symbols, the linker creates fix-ups that the image activator uses to resolve these external symbolic references.

In the second case, internal symbolic references, the linker creates image relocations that the image activator must use to relocate the image. These relocations are used if the image activator uses a load address different from the one proposed for it, which is the case for all shareable images.

The linker combines the fix-ups and image relocations with the activation in formation in the dynamic segment.

The linker generates fix-ups for symbol references to a shareable image. These references are to global data (by value or by reference) or to global procedures, which the shareable image offers. Depending on the type, the linker generates fix-ups for currently undetermined values or address data in an image segment. The image activator processes these fix-ups. At activation-time, the values and addresses of global data and procedures from the shareable image are known. Then, the image activator fills in the data in the segment to contain the values from the shareable image.

This collaboration of the linker and the image activator makes images independent of the implementation of a public interface, which is manifested in the shareable image and its symbol vector.

The linker generates image relocations for address data of resolved symbol references within the generated image. The address value has to change if the linker-proposed load address changes at image activation time. If the image activator determines a different load address, it uses the linker provided relocations to adjust the address data.

This combined effort of the linker and the image activator preserves the position independence of the images.

3.4.4. Keeping the Size of Image Files Manageable

On OpenVMS, uninitialized static data is initialized with bytes of zeros. Language processors usually do not provide explicit bytes of zeros for uninitialized static data within the object file. Instead, they create conceptual sections filled with bytes of zeros. In ELF, these are sections with a section type specified as SHT_NOBITS (equivalent to the traditional NOMOD section attribute). These sections occupy virtual memory when the image is activated but do not occupy any space in the object file. As these sections are collected together, they will generate demand-zero segments in the image file that will occupy virtual memory at image activation time but do not occupy space in the image file (just as the NOBITS sections do in object files).

When a reference is made to data in a demand-zero segment at run-time, the operating system will map an in-memory page of zeros rather than having to access the image file on disk to load a page of zeros (a much slower process). Along with that benefit, demand-zero segments keep the image file size smaller.

If one or more contributions to a section do not have the NOMOD attribute set,the section is considered a non-demand-zero section and will be collected into anon-demand-zero segment.

On OpenVMS x86-64 and I64 systems, the linker can create demand-zero segments for both executable and shareable images. However, sections with the SHR and the NOMOD attributes set are not sorted into demand-zero segments in shareable images.

At run-time, uninitialized static data is identical to zero-initialized data. However, x86-64 and I64 language processors supply actual sections with bytes of zeros for static data explicitly initialized to zero in your source code. Such sections are not collected into demand-zero segments. However, the linker can search these non-demand-zero segment buffers for whole pages of trailing zero data and create demand-zero pages from them. Because this process, called trailing demand-zero compression, can be time-consuming, it is not done by default. To have this processing done, you must specify the PER_PAGE keyword in the /DEMAND_ZERO qualifier.

Trailing demand-zero compression reduces the size of the image file and usually enhances the performance of the program. As with demand-zero segments, a run-time reference made to data in a demand-zero page will cause the operating system to map an in-memory page of zeros rather than having to go out to disk for a block of zeros.

3.4.4.1. Controlling Demand-Zero Image Segment Creation

On x86-64 and I64 systems, you can force the linker to allocate disk blocks for demand-zero segments by specifying the /NODEMAND_ZERO qualifier. The linker initializes the segment data with zeros and writes the segment data into the image file. Note that the linker still sorts the sections with the NOMOD attribute into separate segments.

To control which sections are placed in demand-zero segments, you must reset the NOMOD attribute of the section by using the PSECT_ATTR=option. The NOMOD attribute cannot be set by the programmer in source code or with linker options, but it can be cleared with PSECT_ATTR=psect-name, MOD.

If you set the EXE or VEC attributes for a section for which the compiler has set the NOMOD attribute, the linker issues a warning and sets the section attributes back to NOEXE and NOVEC. The linker creates a read-only demand-zero segment for a segment with the NOWRT attribute. See Chapter 10 for more information.

To request trailing zero compression, you have to use the PER_PAGE keyword for the /DEMAND_ZERO qualifier.

The DZRO_MIN= and the ISD_MAX= options are not supported on x86-64 and I64 systems. The linker ignores these options and produces informational messages. For further explanation of these options, see Chapter 10.

3.4.5. Creating ELF Sections in the Image File

Debugger and traceback sections are processed only if you requested in the LINK command that the debug information be included using the /DEBUG qualifier and that the traceback information not be excluded using the /NOTRACE qualifier. Otherwise, this information is ignored. These sections contain their information in the Debugging With Attribute Record Format, or DWARF. DWARF information is kept in several sections, identified by a few section types and distinguished by name. You are not able to control these sections with the PSECT_ATTR= or the COLLECT= option clauses. Also, the linker does not collect these sections into segments.

The DWARF sections are combined according to their section type and are usually written into the image file. You can request that the debug information go into a separate file called a debug symbol file (DSF) by using the /DSF qualifier. For information about the /DSF qualifier, see Chapter 10.

The linker saves some image information in the .note ELF section, referred to as the note section. It saves the link time and the linker ID,as well as the image name and the global symbol table name (GSTNAM). This section contains a copy of some of the original link-time value settings for additional fields that can be modified by the SET IMAGE command. Further, it contains a modification time stamp field, updated when the SET IMAGE command changes field values. Finally, it contains a modification timestamp the PATCH utility uses when it changes any data in the image file.

The linker writes global symbols into the image file under the following conditions:
  • When you request a shareable image. (If you want to ship a shareable image that cannot be linked against, use /NOGST to exclude the global symbol from the shareable image file).

  • When you request a debug version of the image.

Table 3.10 indicates where global symbol definitions are written during a link operation that uses the debugging qualifiers:
Table 3.10. Location of Global Symbols Determined by /TRACEBACK, /DEBUG, and /DSF

Qualifier

Global Symbols in Image

Global Symbols in DSF File

/NoTrace /NoDebug /NoDSF

0

0

/Trace /NoDebug /NoDSF

0

0

/NoTrace /Debug /NoDSF

1

0

/Trace /Debug /NoDSF

1

0

/NoTrace /NoDebug /DSF

0

1

/Trace /NoDebug /DSF

0

1

/NoTrace /Debug /DSF

0

1

/Trace /Debug /DSF

0

1

The linker creates the required ELF sections, to implement the symbol table. It creates a section named .symtab to contain the values and symbol attributes together with a pointer to a string section, .strtab, which contains the symbol names.

3.4.6. Writing the Main Output Files

To complete the image creation the generated data has to be written to the image file. The linker prepares all the necessary ELF header tables, which are updated, when writing segments and ELF sections. The linker writes the headers, and sections, that is the contents of the linker buffers in the following order:
  1. Temporary ELF header, temporary segment header table

  2. All segments to the image file.

  3. The traceback sections to the image or debug symbol file, unless /NOTRACEBACK specified in the LINK command.

  4. The debug sections to the image or debug symbol file, in case /DEBUG was specified in the LINK command.

  5. The remaining sections of the map to the map file, if requested in the LINK command. (These sections include all requested sections except the Object Module Synopsis, which it already wrote, and the Link Run Statistics, which it cannot write until the linking operation finishes).

  6. The global symbol table to the image file, and also to another separate file, if requested in the LINK command.

  7. The supporting ELF sections to the image file.

  8. The ELF section header table to the image file.

  9. The updated ELF header and segment header table.

  10. The link statistics to the map file, if requested in the LINK command.

Chapter 4. Creating Shareable Images (x86-64 and I64)

This chapter describes how to create shareable images on OpenVMS x86-64 and OpenVMS I64 systems and how to declare universal symbols in shareable images.

4.1. Overview of Creating Shareable Images on x86-64 and I64 Systems

To create a shareable image, specify the /SHAREABLE qualifier on the LINK command line. You can specify as input files in the link operation any of the types of input files accepted by the linker, as described in Chapter 1.

Note, however, to enable other modules to reference symbols in the shareable image, you must declare them as universal symbols. You must declare universal symbols at link time using linker options. The linker lists all universal symbols in the global symbol table (GST) of the shareable image. For x86-64 and I64 images the GST is implemented as a set of symbols in the ELF symbol table (SYMTAB) in the shareable image. The linker processes the GST of a shareable image specified as an input file in a link operation during symbol resolution. For more information about symbol resolution, see Chapter 2.

For x86-64 and I64 linking, you declare universal symbols by listing the symbols in a SYMBOL_VECTOR= option statement in a linker options file. You do not need to create a transfer vector to create an upwardly compatible shareable image, as you do with OpenVMS VAX shareable images. The symbol vector can provide upward compatibility. For more information about this topic, see Section 4.2.

The linker supports qualifiers and options that control various aspects of shareable image creation. Table 4.1 lists these qualifiers and options. For more information about linker qualifiers and options, see Chapter 10.
Table 4.1. Linker Qualifiers and Options Used to Create Shareable Images on x86-64 and I64 Systems

Qualifier

Description

/GST

Directs the linker to include universal symbols in the global symbol table (GST) of the shareable image, which is the default. When you specify the /NOGST qualifier, the linker creates an empty GST for the image. See Section 4.2.4 for more information about using this qualifier to create run-time kits.

/PROTECT

Directs the linker to protect the shareable image from write access by user or supervisor mode.

/SHAREABLE

Directs the linker to create a shareable image, when specified in the link command line. When appended to a file specification in a linker options file, this qualifier identifies the input file as a shareable image.


OptionDescription

GSMATCH=

Sets the major and minor identification numbers in the shareable image and specifies the algorithm when comparing identification numbers.

PROTECT=?

When specified with the YES keyword in a linker options file, this option directs the linker to protect the clusters created by subsequent options specified in the options file. You turn off protection by specifying the PROTECT=NO option in the options file.

SYMBOL_TABLE=?

When specified with the GLOBALS keyword, this option directs the linker to include in a symbol table file all the global symbols defined in the shareable image, in addition to the universal symbols. By default, the linker includes only universal symbols in a symbol table file associated with a shareable image (SYMBOL_TABLE=UNIVERSALS).

SYMBOL_VECTOR=

Specifies symbols in the shareable image that you want declared as universal.

4.2. Declaring Universal Symbols in x86-64 and I64 Shareable Images

To illustrate how to declare universal symbols, consider the programs in the following examples. Example 4.1 shows a shareable image test module. Example 4.2 shows the shareable image.
Example 4.1. Shareable Image Test Module: my_main.c
#include <stdio.h>
#pragma extern_model save
#pragma extern_model common_block
extern int my_data;
#pragma extern_model restore
extern int my_symbol;
extern int mysub( int, int );
main()
{
  int num1, num2, result;
  num1 = 7;
  num2 = 4;
  result = mysub( num1, num2 );
  printf("Result= %d\n", result);
  printf("Data implemented as overlaid psect= %d\n", my_data);
  printf("Global reference data is= %d\n", my_symbol);
}

Example 4.2. Shareable Image: my_math.c
#pragma extern_model save
#pragma extern_model common_block
int my_data = 5;
#pragma extern_model restore
int my_symbol = 10;
int add_data = -1;
int sub_data = -1;
int mul_data = -1;
int div_data = -1;
int myadd( int value_1, int value_2 )
{
  add_data = value_1 + value_2;
  return add_data;
}
int mysub( int value_1, int value_2 )
{
  sub_data = value_1 - value_2;
  return sub_data;}
int mymul( int value_1, int value_2 )
{
  mul_data = value_1 * value_2;
  return mul_data;
}
int mydiv( int value_1, int value_2 )
{
  div_data = value_1 / value_2;
  return div_data;
}

You must use the extern common model to make the VSI C for x86-64 or I64 compiler implement the symbol my_data as an overlaid section. The default model on VSI C is relaxed/refdef. For more information on the extern models and how they are enabled with pragmas or command qualifiers, see the VSI C User Manual.

For x86-64 and I64 linking, you declare universal symbols by listing them in a SYMBOL_VECTOR= option. For each symbol listed in the SYMBOL_VECTOR= option, the linker creates an entry in the shareable image's symbol vector and creates an entry for the symbol in the shareable image's GST. When the shareable image is included in a subsequent link operation, the linker processes the symbols listed in its GST.

To enable images that linked against a shareable image to run with various versions of the shareable image, you must specify the identification numbers of the image. By default, the linker assigns a unique identification number to each version of a shareable image. At run-time, if the ID of the shareable image as it is listed in the executable image does not match the ID of the shareable image the image activator finds to activate, the activation will abort. For information about using the GSMATCH= option to specify ID numbers, see the description of the GSMATCH= option in Chapter 10.

To implement Example 4.2 as an x86-64 or I64 shareable image, you must declare the universal symbols in the image by using the following LINK command:
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
GSMATCH=LEQUAL,1,1000
SYMBOL_VECTOR=(MYADD=PROCEDURE,-
               MYSUB=PROCEDURE,-
               MYMUL=PROCEDURE,-
               MYDIV=PROCEDURE,-
               MY_SYMBOL=DATA,-
               MY_DATA=PSECT)
Ctrl/Z

You must identify the type of symbol vector entry you want to create by specifying a keyword. The linker allows you to create symbol vector entries for procedures, data (relocatable or constant), and for global data implemented as an overlaid section.

A symbol vector entry is two quadwords (on x86-64 systems) or one quadword (on I64 systems) that contain information about the symbol that can be used in subsequent fix-up of images that are linked against the shareable image. The contents of the entry depend on what the symbol represents. If the symbol represents a procedure (=PROCEDURE), the symbol vector entry contains the procedure value, that is the function address. If the symbol represents a data item (=DATA), the symbol vector entry contains the address of the data location. If the symbol represents a data constant (=DATA), the symbol vector entry contains the actual value of the constant. If the symbol represents a section (=PSECT), the symbol vector entry contains the address of the location of the section.

The linker fills in the symbol vector with values and addresses. The address calculations are based on the assumption that the shareable image will be mapped at the default base address. This is done despite the fact that the linker cannot know where the image will be in memory at run-time. The linker also adds relocation information so that the image activator can adjust the address values based on the actual base address of the shareable image at activation time. This way, at run-time the symbol vector contains the actual code or data addresses.

When you create the shareable image (by linking it specifying the /SHAREABLE qualifier), the value of a universal symbol listed in the GST is the zero-based index of the symbol in the symbol vector (expressed as index z in Figure 4.1 (x86-64) and Figure 4.2 (I64)).

When you include this shareable image in a subsequent link operation, the linker leaves references to the procedure, data or section empty. The linker create fix-ups in the executable image that reference symbols from the shareable image. The fix-up includes the symbol’s index in the symbol vector of the shareable image.

The following example illustrates how to link the object module MY_MAIN.OBJ with the shareable image MY_MATH.EXE.
$ LINK MY_MAIN, SYS$INPUT/OPTMY_MATH/SHAREABLE
Ctrl/Z

On x86-64 systems, when an executable image calls a function in a shareable image, the call goes through one or two linker-generated code stubs. In MY_MAIN.EXE, the call to mysub is redirected by the linker to a PLT stub. The PLT stub consists of a single instruction, an indirect jump through a GOT entry. Using the symbol vector in MY_MATH.EXE, the image activator fixes up the GOT entry in MY_MAIN.EXE so it contains the procedure value for mysub. Since, in this example, the code for mysub is located in P2, the procedure value points to another linker-generated stub. This stub does an indirect jump to mysub itself.

Figure 4.1. Accessing Universal Symbols Specified Using the SYMBOL_VECTOR=Option on x86-64
Accessing Universal Symbols Specified Using the SYMBOL_VECTOR=Option on x86-64

On I64 systems, at run-time, when the image activator maps the shareable image into memory, it calculates the actual locations of the routines and relocatable data within the image and stores these values in its symbol vector. The image activator then fixes up the references to these symbols in the executable image. For a symbol representing constant data, the constant from the symbol vector is copied into the executable image. For a symbol representing relocatable data, the address of the data from the symbol vector is copied into the executable image. For a symbol representing a procedure the contents of the FD pointed to by the address in the symbol vector, the code address and the global pointer, is copied into the executable image. When the executable image makes a call to the procedure, shown as the branch (br.few) instruction sequence in Figure 4.2, control is transferred directly to the location of the procedure within the shareable image.

Figure 4.2. Accessing Universal Symbols Specified Using the SYMBOL_VECTOR=Option on I64
Accessing Universal Symbols Specified Using the SYMBOL_VECTOR=Option on I64

Note that the images are being activated by the image activator with all relocations applied, pointing out a single fix-up. That is, m and n are the virtual addresses after the image relocations are applied and gp is the relocated global pointer value.

Note also that, unlike VAX linking, global symbols implemented as overlaid sections are not universal by default. Instead, you control which of these symbols is a universal symbol by including it in the SYMBOL_VECTOR=option, specifying the PSECT keyword. The example declares the section my_data as a universal symbol.

4.2.1. Symbol Definitions Point to Shareable Image Sections

On x86-64 and I64 systems, the linker cannot overlay sections that are referenced by symbol definitions with shareable image sections of the same name.

For example, the VSI C compiler generates symbol definitions when the relaxed ref/def extern model is used (the default).

For hard symbol definitions, the compiler creates an overlaid section defining the memory requirements for that symbol. For tentative symbol definitions, there is no virtual memory allocated by the compiler. At link time, if there is no virtual memory for a symbol found, the linker creates an overlaid section defining the memory.

If an overlaid section was created for a symbol definition, such a section cannot be overlaid with shareable image sections that are created when you link a shareable image and use the PSECT keyword in your SYMBOL_VECTOR option. For more information on the extern models, see VSI C User Manual.

If the linker detects this condition, it issues the following error:
%LINK-E-SHRSYMFND, shareable image psect <name> was pointed
to by a symbol definition
%LINK-E-NOIMGFIL, image file not created

The link continues, but no image is created. To work around this restriction, change the symbol vector keyword to DATA, or recompile your C program with the qualifier /EXTERN=COMMON.

For more information, see the VSI C User Manual.

If the section specified in a SYMBOL_VECTOR= option does not exist, the linker issues a warning, places zeros in the symbol vector entry and does not create an entry for the section in the image's GST.

The linker maintains separate name spaces for global symbol names and section names. As described in Chapter 2, the section names are not used to resolve an undefined symbol. Because of the different name spaces, it is possible to specify an identical name in a symbol vector option when exporting a global symbol and a section. This depends on the main module's extern model and which entry in the symbol vector resolves or overlays a reference from the main module.

Note

Although this is correct linker behavior, using identical names in this manner can create confusion. As such, VSI discourages the use of this feature.

4.2.2. Creating Upwardly Compatible Shareable Images

The SYMBOL_VECTOR= option allows you to create upwardly compatible shareable images. You can create a shareable image that can be modified, recompiled, and relinked without causing the images that were linked against previous versions of the image to be relinked.

To ensure upward compatibility when using a SYMBOL_VECTOR= option, you must preserve the order and placement of the entries in the symbol vector with each relinking. Do not delete existing entries and only add new entries at the end of the list. If you use multiple SYMBOL_VECTOR= option statements in a single options file to declare the universal symbols, you must also maintain the order of the SYMBOL_VECTOR= option statements in the options file. If you specify SYMBOL_VECTOR= options in separate options files, make sure the linker always processes the options files in the same order. (The linker creates only one symbol vector for an image).

Use the GSMATCH mechanism to record any changes you make. GSMATCH handles the changes as follows:
  • Major changes or incompatible changes, different orders of existing symbol vector entries, or deletion of entries most likely will result in a mismatch of the major ID number.

  • Minor changes or compatible changes, or addition of new entries should result in a match of the major ID number but in a mismatch of the minor ID number.

By using the major and minor IDs in this manner, along with the LEQUAL keyword, you can create upwardly compatible shareable images. For example, a main image linked against minor ID 2 of a shareable image is not allowed to run against the shareable image with a minor ID less than 2, if the shareable image was linked with the keyword LEQUAL. For more information, see the description of the GSMATCH= option in Chapter 10.

4.2.3. Deleting Universal Symbols Without Disturbing Upward Compatibility

To delete a universal symbol without disturbing the upward compatibility of an image, use the PRIVATE_PROCEDURE or PRIVATE_DATA keywords. In the following example, the symbol mysub is deleted using the PRIVATE_PROCEDURE keyword:
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
GSMATCH=LEQUAL,1,1000
SYMBOL_VECTOR=(MYADD=PROCEDURE,-
               MYSUB=PRIVATE_PROCEDURE,-
               MYMUL=PROCEDURE,-
               MYDIV=PROCEDURE,-
               MY_SYMBOL=DATA,-
               MY_DATA=PSECT)
Ctrl/z

When you specify the PRIVATE_PROCEDURE or PRIVATE_DATA keyword in the SYMBOL_VECTOR= option, the linker creates symbol vector entries for the symbols but does not create an entry for the symbol in the GST of the image. The symbol still exists in the symbol vector and none of the other symbol vector entries have been disturbed. Images that were linked with previous versions of the shareable image that reference the symbol still work, but the symbol is not available for new images to link against.

Using the PRIVATE_PROCEDURE keyword, you can replace an entry for an obsolete procedure with a private entry for a procedure that returns a message that explains the status of the procedure.

4.2.4. Creating Run-Time Kits

If you use shareable images in your application, you may want to ship a run-time kit with versions of these shareable images that cannot be used in link operations.

To do this, you must first link your application, declaring the universal symbols in the shareable images using the SYMBOL_VECTOR= option so that references to these symbols can be resolved. After the application is linked, you must then relink the shareable images so that they have fully populated symbol vectors but empty global symbol tables (GSTs). The fully populated symbol vectors allow your application to continue to use the shareable images at run-time. The empty GSTs prevent other images from linking against your application.

To create this type of shareable image for a run-time kit (without having to disturb the SYMBOL_VECTOR= option statements in your application's options files), relink the shareable image after development is completed, specifying the /NOGST qualifier on the LINK command line. When you specify the /NOGST qualifier, the linker builds a complete symbol vector, containing the symbols you declared universal in the SYMBOL_VECTOR= option, but does not create entries for the symbols that you declared universal in the GST of the shareable image. For more information about the /GST qualifier, see Chapter 10.

4.2.5. Specifying an Alias Name for a Universal Symbol

For x86-64 and I64 linking, a universal symbol can have a name, called a universal alias, different from the name contributed by the object module in which it is defined. You specify the universal alias name when you declare the global symbol as a universal symbol using the SYMBOL_VECTOR= option. The universal alias name precedes the internal name of the global symbol, separated by a slash (/). In the following example, the global symbol mysub is declared as a universal symbol under the name sub_alias.
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
GSMATCH=LEQUAL,1,1000
SYMBOL_VECTOR=(MYADD=PROCEDURE,-
               SUB_ALIAS/MYSUB=PROCEDURE,-
               MYMUL=PROCEDURE,-
               MYDIV=PROCEDURE,-
               MY_SYMBOL=DATA,-
               MY_DATA=PSECT)
Ctrl/Z

You can specify universal alias names for symbols that represent procedures or data; you cannot declare a universal alias name for a symbol implemented as an overlaid section. In link operations in which the shareable image is included, the calling modules must refer to the universal symbol by its universal alias name to enable the linker to resolve the symbolic reference.

The alias mechanism can also be used to map case sensitive symbols to case insensitive ones. With C and C++, case sensitivity becomes more important. You may want to create a shareable image that contains both symbols,so that object modules from traditional programming languages as MACRO and FORTRAN can link against your image as well as modules which compile from open sources and usually expect case sensitive names. In the following link operation for Example 4.2, for each routine or data, uppercase and lowercase symbols are defined with the alias mechanism, which are written into the GST.
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
CASE_SENSITIVE=YES
SYMBOL_VECTOR=(MYADD=PROCEDURE,-
               myadd/MYADD=PROCEDURE,-
               MYSUB=PROCEDURE,-
               mysub/MYSUB=PROCEDURE,-
               MYMUL=PROCEDURE,-
               mymul/MYMUL=PROCEDURE,-
               MYDIV=PROCEDURE,-
               mydiv/MYDIV=PROCEDURE,-
               MY_SYMBOL=DATA,-
               my_symbol/MY_SYMBOL=DATA,-
               MY_DATA=PSECT)CASE_SENSITIVE=NO
Ctrl/Z

In a privileged shareable image, calls from within the image that use the alias name result in a fix-up and subsequent vectoring through the privileged library vector (PLV), which results in a mode change. Calls from within the shareable image that use the internal name are done in the caller's mode. (Calls from external images always result in a fix-up). For more information about creating a PLV, see the VSI OpenVMS Programming Concepts Manual, Volume I.

4.3. Improving the Performance of Installed Shareable Images

On x86-64 and I64 systems, you can improve the performance of an installed shareable image by installing it as a resident image (by using the /RESIDENT qualifier of the Install utility). INSTALL loads the executable and read-only segments of resident images into physical memory, with virtual addresses in system space. Data or code of such images is directly accessed from memory. That is, at run-time image pages do not need to be read from the image file. See the documentation on the Install utility for more information about installing images as resident images.

4.4. Linking User-Written System Services

User-written system services allow user-mode programs to call routines that can perform functions that require privileges. These services are implemented in shareable images. Because of the privileged code, these images are also referred to as privileged shareable images. For security reasons, the privileged code and associated data must be protected from manipulations. Therefore, such images are also called protected shareable images.

As you would create any other shareable image, create a privileged shareable image by specifying the /SHAREABLE qualifier in the LINK command. However, because the privileged routine entry points in privileged shareable images must be routed through the OpenVMS system service dispatcher in order to change mode to a more privileged mode, declaring these entry points as universal requires additional steps:
  • Protect the privileged shareable image from user-mode or supervisor-mode write access — Create a protected shareable image by specifying the /PROTECT qualifier. If you need to protect only certain segments in a privileged shareable image, use the PROTECT= option. For more information about this option, see Chapter 10.

  • Create a Privileged Library Vector (PLV) and put it in a protected section — Create a PLV for a privileged shareable image. The image activator uses the information in the PLV to set up the change of mode code. You can create a protected shareable image by specifying the /PROTECT qualifier. For information about creating a PLV, see the VSI OpenVMS Programming Concepts Manual, Volume I.


Note

On x86-64 and I64 systems, it is recommended to protect the entire image, rather than parts of the image (that is, individual image segments). Partial protection requires that you verify that all data to be protected is in the protected segment. Compilers for x86-64 and I64 put data in different types of sections. By doing so, it becomes difficult to control protection setting.

For example, compilers for I64 put some data into short data sections. The linker then must collect these sections into short data segments, which cannot be collected into user-defined clusters (the only clusters that you can protect with the linker option). That is, for partially protected images, you need control over that location that the compiler puts all your data. The compiler of your choice might not offer a reliable method to do so, therefore, it is recommended to protect the entire image.

Chapter 5. Interpreting an Image Map File (x86-64 and I64)

This chapter describes how to interpret information in an image map created by the linker on OpenVMS x86-64 and OpenVMS I64 systems. It describes the combinations of linker qualifiers used to produce a map.

For information about interpreting an image map file on OpenVMS Alpha and OpenVMS VAX systems, see Chapter 9.

5.1. Overview of x86-64/I64 Linker Map

At your request, the linker can generate information that describes the contents of the image and the linking process. This information, called an image map, can be helpful when determining programming and link-time errors, studying the layout of the image in virtual memory, and keeping track of global symbols.

You can obtain the following types of information about an image from its image map:
  • The names of all modules included in the link operation, both explicitly in the LINK command and implicitly from libraries

  • The names, sizes, and other information about the segments that comprise the image

  • The names, sizes, and locations of sections within an image

  • The names and values of all the global symbols referenced in the image, including the name of the module in which the symbol is defined and the names of the modules in which the symbol is referenced

  • Statistical summary information about the image and the link operation itself

You determine which information the linker includes in a map file by specifying qualifiers in the LINK command line. If you specify the /MAP qualifier, the map file includes certain information by default (called a default map). You can also request a map file that contains less information about the image (called a brief map) or a map file that contains more information about the image (called a full map). Table 5.1 lists the LINK command qualifiers that affect map file production.
Table 5.1. LINK Command Map File Qualifiers

Qualifier

Description

/MAP

Directs the linker to create a map file. This is the default for batch jobs. /NOMAP is the default for interactive link operations.

/BRIEF

When used in combination with the /MAP qualifier, directs the linker to create a map file that contains only a subset of the default map sections.

/FULL

When used in combination with the /MAP qualifier, directs the linker to create a map file that contains extensive information of the image in the map file. To tailor the full information to your needs, you can use keywords to add or suppress specific information. The default value for /FULL is SECTION_DETAILS.
  • DEMANGLED_SYMBOLS — Directs the linker to add a translation table of mangled and demangled (source code) names. You can request this section if you use a programming language, whose language processor performs name mangling (for example, Ada and C++) and the compiler provides the necessary information within the object modules. The table contains names of global definitions, procedures and data. Note that /DNI (to process display name information) must be present, which is by default. See Section 5.4 for more information.

  • GROUP_SECTIONS — Directs the linker to list all processed groups (ELF COMDATs). For example, C++ includes groups in its object modules and shareable images. Note when linking against C++ shareable images, all groups of these images will be listed; even for short programs this will create a long list.

  • [NO]SECTION_DETAILS — Directs whether or not the linker suppresses zero length contributions in the Program Section Synopsis.

  • ALL — The ALL keyword is equivalent to specifying all of the above listed keywords.

/CROSS_
REFERENCE

When used in combination with the /MAP qualifier, directs the linker to replace the Symbols By Name section with a Symbol Cross-Reference section, in which all the symbols in each module are listed with the modules in which they are called. You cannot request this type of listing in a brief map file.

5.2. Components of an x86-64/I64 Image Map File

The linker formats the information it includes in a map file into sections. Table 5.2 lists the sections of a map file in the order in which they appear in the file. The table also indicates whether the section appears in a brief map, full map, or default map file.
Table 5.2. x86-64/I64 Image Map Sections

Section Name

Description

Default Map

Full Map

Brief Map

Object and Image Synopsis?

Lists all the object modules included in the image and the shareable images referenced in the order they are processed by the linker.

Yes

Yes

Yes

Cluster Synopsis

Lists all the clusters created by the linker

Yes

Image Segment Synopsis

Lists the image segments that were created

Yes

COMDAT Group Synopsis

Lists the processed groups ordered by group name

Keyword

GROUP_
SECTIONS

Program Section Synopsis?

Lists the sections and their attributes.

Yes

Yes

Symbol Cross Reference?

Lists each symbol name, its value, the name of the module that defined it, and the names of the modules that refer to it.

Yes /CROSS

Yes /CROSS

Symbols By Value

Lists all the symbols with their values in hexadecimal representation.

Yes

Cross Reference Footnotes

If the cross reference or the symbol value lists contain shortened name, this section is automatically created and the full names are listed.

Yes

Yes

Mangled/Demangled Symbols

Lists all the mangled symbols with their demangled (source code) names.

Keyword

DEMANGLED_
SYMBOLS

Image Synopsis

Presents statistics and other information about the output image.

Yes

Yes

Yes

Link Run Statistics

Presents statistics about the link run that created the image. Quota usage keeps track of quotas being used by the linker and may suggest which quota should be increased to improve performance.

Yes

Yes

Yes

5.2.1. Object and Image Synopsis Section

The first section that appears in a map file is the Object and Image Synopsis, which lists the name of each object or shareable image included in the link operation in the order in which they were processed. This section of the map file also includes other information about each module, arranged in columns. Example 5.1 shows the Object and Image Synopsis map.

This section corresponds to the OpenVMS Alpha section titled Object Module Synopsis. To compare with the linker map on Alpha, see Section 9.2.1.
Example 5.1. Object and Image Synopsis
                                           +---------------------------+
                                           ! Object and Image Synopsis !
                                           +---------------------------+
1               2                                3               4     5                 6
Module/Image     File        Ident       Attributes      Bytes  Creation Date     Creator
------------     ----        -----    ----------------   -----  -------------     -------
GETJPI                       V1.0         Lkg     Dnrm    280   8-MAR-2019 15:50  VSI C X7.4-151
                 DISK$USER:[JOE]GETJPI.OBJ;1
DECC$SHR                     V8.3-00      Lkg               0  28-FEB-2019 10:57  Linker I02-68
                 SYS$COMMON:[SYSLIB]DECC$SHR.EXE;1
SYS$PUBLIC_VECTORS           X-3          Sel Lkg           0  28-FEB-2019 10:56  Linker I02-68
                 SYS$COMMON:[SYSLIB]SYS$PUBLIC_VECTORS.EXE;1


                 Key for Attributes
                +------------------------------------------+
                ! Sel  - Module was selectively searched   !
                ! Lkg  - Contains call linkage information !
                ! Dnrm - Denormal IEEE FP model            !
                +------------------------------------------+ 

1

Module/Image. The name of each object module or shareable image included in the link operation. The modules/images are listed in the order in which the linker processed them. (Note that the order of processing can be different from the order in which the files were specified in the command line. For more information about how the linker processes input files, see Chapter 2). If the linker encounters an error during its processing of an object module or shareable image, an error message appears on the line directly following the line containing the name of that module or image. This column corresponds to the Module Name column on the Alpha linker map.

2

File. Full file specification of the input file, including device and directory. The specification is printed on a separate line. It starts at the File column and continues across the other columns. If the specification is longer than 111 characters, it is shortened by dropping the device portion of the file specification or both the device and directory portions of the file specification.

3

Attributes. The attributes displays four subcolumns of module attributes. An explanation of the abbreviations used appears in the Key for Attributes legend that appears at the end of the Object and Image Synopsis section:

The first of the four subcolumns indicates whether the symbol search of the module was selective. If the symbol search was selective, the abbreviation Sel appears. If the symbol search of the module was not selective, this subcolumn is left blank.

The second subcolumn indicates whether the module has call linkage information. If the module has call linkage information, Lkg appears. If the module does not have call linkage information, this subcolumn is left blank.

The third subcolumn indicates whether the module was compiled with the Reduced Floating Point model. If it was, the abbreviation RFP appears. If the module was not compiled with the Reduced Floating Point model, this subcolumn is left blank. This designation is suppressed for shareable images.

The fourth subcolumn indicates the whole program Floating Point mode for the module. Several abbreviations can appear in this column. For example Dnrm, the denormal IEEE FP model.

The following example lists all of the possible abbreviations for this subcolumn in the Keys for Attributes legend. The Bytes, Creation Date and Creator columns are omitted from this example; refer to the preceding map example for the entire Object and Image Synopsis.

Module/Image      File           Ident               Attributes
------------      ----           -----            ----------------
NONE                              V1.0                 Lkg
                  DISK1:[JOE]NONE.OBJ;1
NOFLOAT_CASE                                           Lkg RFP
                  DISK1:[JOE]NOFLOAT.OBJ;1
DNORM_CASE                                             Lkg     Dnrm
                  DISK1:[JOE]DENORM_W.OBJ;1
FAST_CASE                                              Lkg     Fast
                  DISK1:[JOE]FAST_W.OBJ;1
NEPCT_CASE                                             Lkg     Inex
                  DISK1:[JOE]INEXACT_W.OBJ;1
SPCL_CASE                                              Lkg     Spcl
                  DISK1:[JOE]SPECIAL_W.OBJ;1
UNDER_CASE                                             Lkg     Undr
                  DISK1:[JOE]UNDERFLOW_W.OBJ;1
DG_FL_CASE                                             Lkg     VXfl
                  DISK1:[JOE]VAXFLOAT_W.OBJ;1
DECC$SHR                          V8.2-00              Lkg
                  RESD$:[SYSLIB]DECC$SHR.EXE;1
SYS$PUBLIC_VECTORS                X-2              Sel Lkg
                  RESD$:[SYSLIB]SYS$PUBLIC_VECTORS.EXE;1



                 Key for Attributes
                +------------------------------------------+
                ! Sel  - Module was selectively searched   !
                ! Lkg  - Contains call linkage information !
                ! RFP  - Conforms to the reduced FP model  !
                ! VXfl - VAX Float FP model                !
                ! Dnrm - Denormal IEEE FP model            !
                ! Fast - Fast IEEE FP model                !
                ! Inex - Inexact IEEE FP model             !
                ! Undr - Underflow-to-zero IEEE FP model   !
                ! Spcl - Special FP model                  !
                +------------------------------------------+ 

4

Bytes. The number of bytes the object module contributes to the image. Because shareable images do not contribute to the image the value 0 (zero) appears in this column.

5

Creation Date. The date and time the module or image was created.

6

Creator. Identification of the language processor or other utility that created the module or image.

5.2.2. Cluster Synopsis Section

The Cluster synopsis section (Example 5.2) shows clusters that were created for and used by the linker, the order in which they were processed, and Global Section Match (GSMATCH) criteria.
Example 5.2. Cluster Synopsis
                                                +------------------+
                                                ! Cluster Synopsis !1
                                                +------------------+
2                              3
Cluster                         Match       Majorid   Minorid
-------                         -----       -------  ----------
MYCLU
DEFAULT_CLUSTER
DECC$SHR                        LESS/EQUAL        1           1
SYS$PUBLIC_VECTORS              EQUAL          9525   361572293

1

Cluster Synopsis. On x86-64 and I64 systems, there are separate map sections titled Cluster Synopsis and Image Segment Synopsis. The Cluster Synopsis section on x86-64 and I64 does not contain segment information.

2

Cluster. The Cluster column shows the names of the clusters created for and used by the linker, and the order in which they were processed. STARLET.OLB is an exception. It is on the default cluster but its processing is postponed after processing IMAGELIB.OLB. See Chapter 2 for more information on processing default libraries.

3

Match, Majorid, and Minorid. The Match, Majorid, and Minorid columns show the GSMATCH criteria along with the major and minor version numbers, if this information is available. For more information, see the GSMATCH= option in Chapter 10.

5.2.3. Image Segment Synopsis Section

The Image Segment Synopsis section of the linker map file (Example 5.3) lists the image segments created by the linker. The image segments appear in the order in which the linker created them. The order of the segments depends on the order of the clusters as shown in the linker's image cluster synopsis (see Section 5.2.2). On x86-64 and I64 systems, segments of the shareable images which are included in the link operation are not listed in the Image Segment Synopsis.

This section of the image map includes other information about the image segments, formatted in columns. To compare with the Alpha Image Section Synopsis map, see Section 9.2.3.
Example 5.3. Image Segment Synopsis
                                             +------------------------+
                                             ! Image Segment Synopsis !1
                                             +------------------------+
2     3                    4        5       6          7        8    9          10
Seg#  Cluster            Type    Pglts   Base Addr  Disk VBN  PFC  Protection  Attributes
----  -------            ----    -----   ---------  --------  ---  ----------  ----------
   0  MYCLU              LOAD        1    00010000         2    0  READ WRITE
   1                     LOAD        1    00020000         0    0  READ WRITE  DEMAND ZERO
   2                     LOAD        1    00030000         3    0  READ ONLY   EXECUTABLE,SHARED
   3                     LOAD        1    00040000         4    0  READ ONLY   SHARED
   4                     LOAD        1    00050000         5    0  READ ONLY   [UNWIND]
   5  DEFAULT_CLUSTER    LOAD        1    00060000         6    0  READ ONLY   SHORT11
   6                     DYNAMIC     2  Q-00000000
                                          80000000         7    0  READ ONLY


              Key for special characters above
                +----------------------+
                !   Q  - Quad Value    !
                +----------------------+

1

The Image Segment Synopsis section shows each segment as it was created.

2

Seg#. The image's segment number, indicating segments in the order the linker created them and used in image relocations and image fix-ups that are applied to a segment by the image activator.

Using the ANALYZE/IMAGE/SEGMENT=DYNAMIC command, you can format the dynamic segment, which includes the image relocations and fix-ups. The following extract of the ANALYZE shows how the segment numbers are used for image relocations:
Segment Offset Modified:   0000000000000050  imr$q_rela_offset
Image Relocation Type:             00000081  imr$l_type
Segment Being Modified:            00000003  imr$l_rela_seg
Image Relocation Addend:   0000000000000000  imr$q_addend
Symbol Segment Offset:     0000000000000000  imr$q_sym_offset
Symbol Segment Number:             00000000  imr$l_sym_seg
Virtual Address Affected:  0000000000040050

3

Cluster. The name of each cluster the linker created, listed in the order in which the linker created them. For better readability, the cluster name is only shown for the first segment in the cluster.

4

Type. The type of the segment, indicating if a segment will be in memory at run-time (LOAD), or if the segment is used to activate the image (DYNAMIC).

5

Pagelets. The length of each segment, expressed in pagelets (512-byte quantities).

6

Base Address. The base address assigned to the segment. Note that all segments are relocatable, the image activator may relocate the base address.

7

Disk VBN (virtual block number). The virtual block number of the image file on disk where the segment begins. The number 0 indicates that the segment is not in the image file. This is the case for demand-zero segments.

8

Page fault cluster (PFC). The number of pagelets read into memory by the operating system when the initial page fault occurs for that segment. The number 0 indicates that the system parameter PFCDEFAULT determines this value, rather than the linker.

9

Protection. The protection attributes of the segment:

Keyword

Meaning

READ ONLY

Indicates that the segment is protected against write access.

READ WRITE

Indicates that the segment allows both read and write access.

10

Attributes. A keyword phrase that characterizes the settings of certain attributes of the image segment, such as the attributes that affect paging.

The following table lists the keywords used by the linker to indicate these characteristics of an image segment:

Keyword

Meaning

DEMAND ZERO

Indicates that the segment is a demand-zero segment. For more information, see Section 3.4.4.

DZRO COMPRESSED

Indicates that a segment had the trailing pagelets containing zeros compressed. For more information, see Section 3.4.4.

EXECUTABLE

Indicates that the segment contains code.

FIXED OFFSET?

Indicates that this segment position relative to the previous segment must be maintained when the image is loaded and activated.

PROTECTED

Indicates that a segment at run-time will be protected from user-mode and supervisor-mode write access. The image activator ensures the protection when the segment is in memory. For more information, see Section 4.4.

SHARED

Indicates that a segment can be shared between several processes.

SHORT?

Indicates a short data segment, data which is addressed with small offsets from the global pointer. For more information, see Section 3.4.3.3.

VECTOR

Indicates that a segment contains privileged change-mode vectors or message vectors.

[UNWIND]

Indicates that a segment contains unwind information. Please note that UNWIND is not an attribute. The linker flags this segment for better readability because all other attributes may be identical to other segments. For more information, see Section 3.2.1.7.

The linker may use more than one keyword to describe a segment. For example, to describe a segment that contains code, the linker uses the READ ONLY and EXECUTABLE keywords.

11

(I64 specific) If the module was compiled with /TIE and the image is linked /NONATIVE_ONLY and if the image contains nonstandard signatures, a separate segment appears immediately after the short data segment that contains them.

5.2.4. Program Section Synopsis Section

The Program Section Synopsis section lists the sections that comprise the image, along with information about the size of the section, its starting- and ending-addresses, and its attributes. The Module Name column in this map section lists the modules that contribute to each section. Example 5.4 shows the Program Section Synopsis.
Example 5.4. Program Section Synopsis
                                            +--------------------------+
                                            ! Program Section Synopsis !
                                            +--------------------------+

Psect Name1    Module/Image2    Base3    End4         Length5     Align6               Attributes7
----------      ------------      ----     ---           ------       -----                 ----------
ITMLET                          00010000 0001000F 00000010 (    16.) OCTA  4 OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC, MOD
                GETJPI          00010000 0001000F 00000010 (    16.) OCTA  4 Initializing Contribution8
FILLEN                          00020000 00020003 00000004 (     4.) OCTA  4 OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC,NOMOD
                <Linker>9      00020000 00020003 00000004 (     4.) OCTA  4
FILLM                           00020010 00020013 00000004 (     4.) OCTA  4 OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC,NOMOD
                <Linker>        00020010 00020013 00000004 (     4.) OCTA  4
IOSB                            00020020 00020023 00000004 (     4.) OCTA  4 OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC,NOMOD
                <Linker>        00020020 00020023 00000004 (     4.) OCTA  4
STATUS                          00020030 00020033 00000004 (     4.) OCTA  4 OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC,NOMOD
                <Linker>        00020030 00020033 00000004 (     4.) OCTA  4
$CODE$                          00030000 0003015F 00000160 (   352.) OCTA  4 CON,REL,LCL, SHR, EXE,NOWRT,NOVEC, MOD
                GETJPI          00030000 0003015F 00000160 (   352.) OCTA  4
$LINKER C$0                     00030160 0003019F 00000040 (    64.) OCTA  4 CON,REL,LCL, SHR, EXE,NOWRT,NOVEC, MOD
                <Linker>10      00030160 0003019F 00000040 (    64.) OCTA  4
$LITERAL$                       00040000 00040012 00000013 (    19.) OCTA  4 CON,REL,LCL,  SHR,NOEXE,NOWRT,NOVEC, MOD
                GETJPI          00040000 00040012 00000013 (    19.) OCTA  4
$LINKER UNWIND$                 00050000 0005002F 00000030 (    48.) QUAD  3 CON,REL,LCL,NOSHR,NOEXE,NOWRT,NOVEC, MOD
                GETJPI          00050000 0005002F 00000030 (    48.) QUAD  3
$LINKER UNWINFO$                00050030 0005005F 00000030 (    48.) QUAD  3 CON,REL,LCL,NOSHR,NOEXE,NOWRT,NOVEC, MOD
                GETJPI          00050030 0005005F 00000030 (    48.) QUAD  3
$LINKER SYMBOL_VECTOR$          00060000 00060007 00000008 (     8.) OCTA  4 CON,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC, MOD,SHORT
                <Linker Option> 00060000 00060007 00000008 (     8.) OCTA  4
$LINKER SDATA$                  00060008 000600AF 000000A8 (   168.) OCTA  4 CON,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC, MOD,SHORT
                <Linker>        00060008 000600AF 000000A8 (   168.) OCTA  4

There are two types of line entries: first type is a section entry (Psect Name); the second type are individual module contributions to that section (Module/Image).

1

Psect Name. The name of each section in the image in ascending order of its base virtual address.

2

Module/Image. The names of the modules that contribute to the section whose name appears on the line directly above in the Psect Name column. If a shareable image appears in this column, the section is overlaid onto the section in the shareable image.

3

Base. The starting virtual address of the section or of a module that contributes to a section. If the section is overlaid onto a section in a shareable image, the virtual address is taken from the shareable image.

4

End. The ending virtual address of the section or of a module that contributes to a section. If the section is overlaid onto a section in a shareable image, the virtual address is taken from the shareable image.

5

Length. For the section entry line, the total length of the section in bytes; for the individual module contribution lines, the length of the individual contribution in bytes.

6

Align. The type of alignment used for the entire section or for an individual section contribution. The alignment is expressed in two ways. In the first column, the alignment is expressed using a predefined keyword, such as OCTA. In the second column, the alignment is expressed as an integer that is the power of 2 that creates the alignment. For example, octaword alignment would be expressed as the keyword OCTA and as the integer 4 (because 24 = 16). For more information on the effects of alignment with the PSECT= option see Chapter 10. If the linker does not support a keyword to express an alignment, it puts the text 2 ** in the column in which the keyword usually appears. When read with the integer in the second column, it expresses these alignments, such as 25 = 32.

7

Attributes. The attributes associated with the section. For a complete list of all the possible attributes, see Chapter 3.

8

The linker indicates which modules made initializations (if there were any) to sections which have the attributes OVR, REL and GBL with the designation Initializing Contribution. If you get multiple initialization errors, the linker will have two or more sections marked with the designation Initializing Contribution, in order to help you debug an instance that has many contributors.

9

The linker contributes storage for common or relaxed ref/def symbols. It is marked with <Linker> under the Module/Image header. The section name is always named after the symbol. (In this example map the C module was compiled with the default switch /EXTERN=RELAXED, and the variables ITMLST, FILLEN, FILLIM and IOSB are relaxed ref/def symbols).

10

The linker makes a contribution to the code section containing trampolines (instructions with larger branches within the same code segment) or code to branch to another segment (either inside or outside the image). It is marked with <Linker> under the Module/Image header.

Note

If a routine is extracted from the default system library to resolve a symbolic reference, the Program Section Synopsis section in a full map contains information about the program sections comprising that routine. The Program Section Synopsis section in a default map does not.

5.2.5. Symbol Cross-Reference Section

The Symbol Cross-Reference section is a superset of the Symbols By Name section. It is produced in place of the Symbols By Name section when you specify the /CROSS_REFERENCE qualifier. It lists all symbols referenced in the image, along with the module in which they are defined and with all the modules that reference them. Example 5.5 shows how the Symbol Cross-Reference Section formats this information.
Example 5.5. Symbol Cross-Reference
                                             +------------------------+
                                             ! Symbol Cross Reference !
                                             +------------------------+
1               2                 3                        4
Symbol          Value              Defined By                Referenced By ...
------          -----              ----------                -----------------
DECC$TXPRINTF   00000496-X5       DECC$SHR                  GETJPI
ELF$TFRADR      00060050-R      WK-GETJPI
FILLEN          00020000-R         GETJPI                    GETJPI
FILLM           00020010-R         GETJPI                    GETJPI
GETJPI (U)      00000000           <Linker Option>
INTERNAL_GETJPI 00060098-R         GETJPI
IOSB            00020020-R         GETJPI                    GETJPI
ITMLST          00010000-R         GETJPI
STATUS          00020030-R         GETJPI                    GETJPI
SYS$GETJPIW     0000009A-X         SYS$PUBLIC_VECTORS        GETJPI

1

Symbol. The name of the global symbol.

2

Value. The value of the global symbol, expressed in hexadecimal. The linker appends characters to the end of the symbol value to describe other characteristics of the symbol. For an explanation of these symbols, see Section 5.2.6.

3

Defined By. The name of the module in which the symbol is defined. For example, the symbol ITMLST is defined in the module named GETJPI.

4

Referenced By... . The name or names of all the modules that contain at least one reference to the symbol.

5

On x86-64 and I64 systems, the designation of an external symbol is always X (external). The linker can not know whether or not an external symbol is relocatable or not. As a result, the designation R (relocatable) can not be attached.

5.2.6. Symbols By Value Section

The Symbols By Value section lists all the global symbols in the image in ascending order by value. The linker formats the information into columns. Example 5.6 shows the Symbols By Value map section.

Example 5.6. Symbols by Value
                                                +------------------+
                                                ! Symbols By Value !
                                                +------------------+
1               2
Value           Symbols...
-----           ----------
00000000        GETJPI (U)
0000009A      X-SYS$GETJPIW
00000496      X-DECC$TXPRINTF
00010000      R-ITMLST
00020000      R-FILLEN
00020010      R-FILLM
00020020      R-IOSB
00020030      R-STATUS
00060050      R-ELF$TFRADR
00060098      R-INTERNAL_GETJPI

              Key for special characters above3
                +----------------------+
                !   *  - Undefined     !
                !  (U) - Universal     !
                !   R  - Relocatable   !
                !   X  - External      !
                !   C  - Code Address  !
                !  WK  - Weak          !
                ! UxWk - Unix-Weak     !
                +----------------------+

1

Value. The value of each global symbol, expressed in hexadecimal, in ascending numerical order.

2

Symbols... . The names of the global symbols. If more than one symbol has the same value, the linker lists them on more than one line. The characters prefixed to the symbol names indicate other characteristics of the symbol, such as its scope.

3

Keys for Special Characters. The keys for special characters used in the Symbols column are defined as follows:
  • On x86-64 and I64, the special character C appears for code address. On I64, when a function does not have a function descriptor assigned by the linker, its value is its code address.

  • On x86-64 and I64 systems, universal symbols appear once with a suffix of (U) defined by <Linker Option> to indicate the external value, and again, possibly with the prefix or suffix R, that indicates their internal value. The external value is the index into the symbol vector. If you had a symbol vector with an alias name, the alias name appears with the universal value, and the internal name appears with the internal value.

    For example:
    symbol_vector=(getjpi/internal_getjpi=procedure)
    yields:
       00000000        GETJPI (U)
       00050098      R-INTERNAL_GETJPI

    Note that the OpenVMS Alpha prefixes and suffixes A and I (for Alias and Internal) are not used by OpenVMS x86-64 and I64.

  • WK designates a weak symbol.

  • UxWk designates a UNIX-style weak symbol, which is similar to an OpenVMS weak symbol. However, more than one symbol with a UNIX-style weak definition can be processed when linking multiple modules without producing a multiple definitions error. UNIX-style weak symbols are currently produced by the C++ compiler. For more information about symbol types, see Chapter 2.

5.2.7. Image Synopsis Section

The Image Synopsis section contains miscellaneous information about the image, such as its name and identification numbers, and a summary of various attributes of the image, such as the number of files used to build the image. Example 5.7 illustrates the format of this section of a map file. The list following the example provides more information about items in this section that are not self-explanatory.
Example 5.7. Image Synopsis
                                                 +----------------+
                                                 ! Image Synopsis !
                                                 +----------------+

Virtual memory allocated:1              00010000 0006FFFF 00060000 (393216. bytes, 768. pages)
64-Bit Virtual memory allocated:2       00000000 00000000 00000000
                                         80000000 80010000 00010000 (65536. bytes, 128. pages)
Stack size:3                                           0. pages
Image header virtual block limits:4             1.        1. (    1. block)
Image binary virtual block limits:5             2.        8. (    7. blocks)
Image name and identification:           GETJPI V1.0
Number of files:                                5.
Number of modules:                              3.
Number of program sections:                     8.
Number of global symbols:                    3364.
Number of cross references:                    17.
Number of image segments:                       7.
Transfer address from module:                GETJPI
User transfer FD address:6               00000000 00060050
User transfer code address:7             00000000 00030000
Initial FP mode:                        00000000 09800000 (IEEE DENORM_RESULTS)
Number of code references to shareable images:        2.
Image type:                    SHAREABLE. Global Section Match=EQUAL, Ident, Major=9533, Minor=3817251083
Reduced Floating Point model (RFP):  Image does not use RFP model
Map format:                          FULL WITH CROSS REFERENCE in file DISK$USER:[JOE]GETJPI.MAP;1
Estimated map length:                443. blocks

1

Virtual memory allocated. This line contains the following information:
  • The starting address of the image (base address)

  • The ending address of the image

  • The total size of the image, expressed in bytes, in hexadecimal radix

The numbers in parentheses at the end of the line indicate the total size of the image, expressed in bytes and in pagelets. Both these values are expressed in decimal.

2

64-Bit Virtual memory allocated. The next two lines contain information on the image portions in P2 space. The virtual addresses are printed by column,in two rows, with the high order digits in the first row. The values are as in the preceding line: the starting-address, the ending-address, the size. Sections with the attribute ALLOC_64BIT are collected into P2 space (For more information on collecting sections and assigning virtual addresses see Chapter 3). The linker usually places the image activator information (dynamic segment) into the 64-bit space. Therefore, for all x86-64 and I64 images, 64-bit virtual memory is usually allocated.

3

Stack size.

4

Image header virtual block limits. For x86-64 and I64 images, the header blocks contain the ELF header and the segment header table. This is usually one disk block.

5

Image binary virtual block limits. For x86-64 and I64 images, the binary blocks contain the image binaries (the segments) and other sections, depending on the type of image. There can be traceback and debug information as well as symbol tables. Also, the section header table describing such sections is counted here.

6

(I64 specific) User transfer FD address. The virtual address of the function descriptor (FD) for the main entry. This is an address in the short data segment.

7

User transfer code address. The virtual address of the first code instruction in the main entry. This is an address in an executable segment.

5.2.8. Link Run Statistics Section

The Link Run Statistics section contains miscellaneous statistical information about the link operation, such as performance indicators. Example 5.8 shows the formatting of this section.

Note that the link command line and the linker options are part of the Link Run Statistics Section.

1

Quota usage. For x86-64 and I64, includes Quota usage information in the Link Run Statistics section. This information can help you to keep track of the quotas that are being used by the linker. If quota issues occur, the linker is usually able to work around them. However, the linker outputs a special message to the Quota Usage section indicating what quota should be increased to improve performance. For example:
Performance of this link operation could be improved by increasing quotas
   Quota related to status return:  %SYSTEM-SECTBLFUL, process or global
   section table is full
2688 extra file I/O operations performed due to current process quota(s)
36 performed on object files; 2652 performed on library files

2

Library searches were for symbols not in the library searched. When resolving undefined symbols, libraries are searched for definitions (see Chapter 2 for more information on symbol resolution). The printed number shows how often undefined symbols are not found in a library. For example, assume that module MAIN references the symbols MY_ADD and MY_SUB, which are defined by modules in ADDLIB.OLB and SUBLIB.OLB. Using the link command:
$ LINK MAIN, MAINLIB/LIB, ADDLIB/LIB, SUBLIB/LIB
if the MY_ADD and MY_SUB symbols are not found in MAINLIB, MY_SUB is not found in ADDLIB. This results in "3 library searches for symbols not in the library searched".

3

The number of global symbols written into a shareable image corresponds to the procedure and data entries in the symbol vector option. In this example, there is only a single entry in the symbol vector option.

5.3. Shortened Names with Footnotes in the Cross-Reference

Some sections of the linker map have tables with a fixed amount of space for their columns. The Symbol Cross-Reference and the Symbols By Value map sections are examples. If names exceed the given column size, the linker prints a shortened name. On x86-64 and I64, for the cross reference and the symbol value list the linker attaches a footnote, referring to the full name. If there are footnotes attached to any name, the linker automatically adds a Cross-Reference Footnotes section. The footnote section contains the footnote index and the full name, wrapped to several lines, if necessary.

The following example demonstrates how to read the footnotes. The long names were constructed for demonstration purpose only. In Example 5.9, the qualifiers /MAP/CROSS/FULL were specified to get both the cross-reference and the symbol value list.

Example 5.9. Shortened Symbol and Module Names
                                             +------------------------+
                                             ! Symbol Cross Reference !
                                             +------------------------+
1                                                 2
Symbol                    Value              Defined By                            Referenced By ...
------                    -----              ----------                            -----------------
a_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_long_variable_name...[1]
                          00010000-R         A_VERY_LONG_MODULE_NAME_JUST_F...[2]

                                                +------------------+
                                                ! Symbols By Value !
                                                +------------------+
                3
Value           Symbols...
-----           ----------
00010000      R-a_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_lon...[1]

1

In the symbol cross reference, the symbol name does not fit on one line. The name is shortened, which is shown with the trailing ellipses. And index of the footnote is in the rightmost column.

2

In the symbol cross reference, the module name exceeds the size for the column Defined By. Again, ellipses show that the names is shortened and an index of the footnote is attached.

3

The same symbol shows in the Symbols By Value section. Even less space is provided to fit the symbol into the Symbols... column. The name, therefore, is shortened with ellipses and a footnote index is attached. Because this is the same symbol as in the Cross-Reference Section (although more shortened), the same index points to the same full name, and the entry in the footnote section.

Example 5.10 shows an example of a Cross Reference Footnotes section, automatically added by the linker.
Example 5.10. Cross Reference Footnotes
                                           +---------------------------+
                                           ! Cross Reference Footnotes !
                                           +---------------------------+
       1
Index  Full Symbol Name
-----  ----------------
    1  a_very_very_very_very_very_very_very_very_very_very_very_very_very
       _very_very_long_variable_name
       _used_only_for_demonstration_purpose
    2  A_VERY_LONG_MODULE_NAME_JUST_FOR_DEMO

1

In this example, the full name does not fit into the footnote column. The full symbol name will be wrapped to multiple lines, as necessary.

5.4. Translation Table for Mangled Names

Some compilers mangle symbol names to implement language features (for example,overloading) or to use shortened, unique names. Ada and C++ compilers, for example, do so. The linker receives only mangled names from the compilers for resolving symbols and for exporting universal symbols. There is no general rule to derive a mangled name from a source codename or vice versa. If you need to know the source code name for a given mangled name, you need the demangler support from that programming language processor.

Recent compilers are able to add demangling information to the object modules. With this information and the language specific demangler routines (usually available with run-time libraries), the linker can create a translation table for mangled names. To obtain this table, use the DEMANGLED_SYMBOLS keyword for the /FULL qualifier when requesting a map. The linker lists all the global symbol definitions from the input object modules with their source code names. Example 5.11 shows a translation table in the linker map.
Example 5.11. Mangled/Demangled Symbols
                                           +---------------------------+
                                           ! Mangled/Demangled Symbols !
                                           +---------------------------+

Symbol = Source Code Name
-------------------------
CX3$ZN4RW22RWRDNRYXCHNGI2LM6VES1
  = "int __rw::__rw_ordinary_exchange<int, int>(int&, int const&)"
CX3$_Z10DESCENDINGRIS_2OLL9N5
  = "descending(int&, int&)"2
CX3$_Z6MYSWAPIIEVRT_S1_1658A7V
  = "void myswap<int>(int&, int&)"2
CX3$_Z9ASCENDINGRIS_162K6TK
  = "ascending(int&, int&)"2
CXXL$ZN4RW10RWGARDC1ERNS1UGN3D2
  = "__rw::__rw_guard::$complete$__rw_guard(__rw::__rw_mutex_base&)"
CXXL$ZN4RW10RWGARDC2EPNS05KBR8A
  = "__rw::__rw_guard::$subobject$__rw_guard(__rw::__rw_mutex_base*)"
CXXL$ZN4RW10RWGARDC9EPNS20LCU4S
  = "__rw::__rw_guard::__rw_guard(__rw::__rw_mutex_base*)"
CXXL$ZN4RW10RWGARDC9ERNS2NGDC8S
  = "__rw::__rw_guard::__rw_guard(__rw::__rw_mutex_base&)"
CXXL$ZN4RW17RWSTTCMTXB8C19J9SHI
  = "__rw::__rw_static_mutex<bool>::_C_mutex"
CXXL$ZN4RW17RWSTTCMTXJ8C1AJH16C
  = "__rw::__rw_static_mutex<unsigned int>::_C_mutex"
CXXL$ZN4RW20RWTMCXCHNGII0DCUDA8
  = "int __rw::__rw_atomic_exchange<int, int>(int&, int const&, __rw::__rw_mutex_base&)"
CXXL$ZNKST15BSCSTRAMBFCS03029KV
  = "std::basic_streambuf<char, std::char_traits<char> >::_C_write_avail() const"
CXXL$ZNKST5CTYPEICE5WDNC2S864U0
  = "std::ctype<char>::widen(char) const"

1

The translation table is sorted by the mangled names. Sorting the names by the source code name is not helpful. For example, the C++ source code function names contain the return type, which would determine the sort order rather than the function names.

Note that the mangled names might contain a dollar sign ($) character. This does not necessarily indicate an OpenVMS reserved name.

2

The table only contains global symbol definitions from the object modules included in the link. However, there might be more names than expected; the compiler may generate some names (for example, when implementing C++ templates). In the map extract, "descending(int&, int&)", "void myswap <int>(int&, int&)"and "ascending(int&, int&)" are the user-defined template functions from the example Example 2.3. Other names are C++ generated names.

Chapter 6. Understanding Symbol Resolution (Alpha and VAX)

This chapter describes how the linker performs symbol resolution on OpenVMS Alpha and OpenVMS VAX systems.

For information on performing symbol resolution on OpenVMS x86-64 and OpenVMS I64 systems, see Chapter 2.

As one of its primary tasks, the linker must resolve symbolic references between modules. This chapter describes how you can control the process to ensure that the linker resolves symbolic references as you intend.

6.1. Overview

Programs are typically made up of many interdependent modules. For example, one module may define a symbol to represent a program location or data element that is referenced by many other modules. The linker is responsible for finding the correct definition of each symbol referenced in all the modules included in the link operation. This process of matching symbolic references with their definitions is called symbol resolution.

6.1.1. Types of Symbols

Symbols can be categorized by their scope, that is, the range of modules over which they are intended to be visible. Some symbols, called local symbols, are meant to be visible only within a single module. Because the definition and the references to these symbols must be confined to a single module, language processors such as compilers can resolve these references.

Other symbols, called global symbols, are meant to be visible to external modules. A module can reference a global symbol that is defined in another module. Because the value of the symbol is not available to the compiler processing the source file, it cannot resolve the symbolic reference. Instead, a compiler creates a global symbol directory (GSD) in an object module that lists all of the global symbol references and global symbol definitions it contains.

In shareable images, symbols that are intended to be visible to external modules are called universal symbols. A universal symbol in a shareable image is the equivalent of a global symbol in an object module. Note, however, that only those global symbols that have been declared as universal are listed in the global symbol table (GST) of the shareable image and are available to external modules to link against.

Language processors determine whether a symbol is local or global. For example, in VAX FORTRAN, statement numbers are local symbols and module entry points are global symbols. In other languages, you can explicitly specify whether a symbol is local or global by including or excluding particular attributes in the symbol definition. Note also that some languages allow you to specify symbols as weak or strong (see Section 6.5 for more information).

You must explicitly declare universal symbols as part of the link operation in which the shareable image is created. For more information about declaring universal symbols, see Chapter 8.

Note

In some VSI programming languages, certain types of global symbols, such as external variables in C and COMMON data in FORTRAN, are not listed in the GSD as global symbol references or definitions. Because these data types implement virtual memory that is shared, the languages implement them as program sections that are overlaid. These symbols appear as program section definitions in the GSD, not as a symbol definition or reference. (Compilers use program sections to define the memory requirements of an object module). The linker does not include program section definitions in its symbol resolution processing. For information about how the linker processes program sections, see Chapter 7.

On VAX systems, the VAX C language extensions globalref and globaldef allow you to create external variables that appear as symbol references and definitions in the GSD. For more information, see the VAX C documentation.

On Alpha systems, the VSI C compiler supports the globalref and globaldef language extensions. In addition, VSI C supports command line qualifiers and source code pragma statements that allow you to control whether it implements external variables as program sections or as global symbol references and definitions. For more information, see the VSI C documentation.

6.1.2. Linker Symbol Resolution Processing

During its first pass through the input files specified in the link operation,the linker attempts to find the definition for every symbol referenced in the input files. By default, the linker processes all the global symbols defined and referenced in the GSD of each object module and all the universal symbols defined and referenced in the GST of each shareable image. The definition of the symbol provides the value of the symbol. The linker substitutes this value for each instance where the symbol is referenced in the image.

The value of a symbol depends on what the symbol represents. A symbol can represent a routine entry point or a data location within an image. For these symbols, the value of the symbol is an address. A symbol can also represent a data constant (for example, X = 10). In this case, the value of the symbol is its actual value (in the example, the value of X is 10).

For symbols that represent addresses in object modules, the value is expressed initially as an offset into a program section. This is how language processors express addresses. Later in its processing, when the linker combines the program sections contributed by all the object modules into the image sections that define the virtual memory layout of the image, it determines the actual value of the address. For information about how the linker determines the virtual memory layout of an image, see Chapter 7.

For symbols that represent addresses in a shareable image, the value of the symbol at link time is architecture specific.

For Alpha images, at link time, the value of a symbol in a shareable image (as listed in the GST of the image) is the offset of the symbol's entry in the symbol vector of the image. A symbol vector entry is a pair of quadwords that contain information about the symbol. The contents of these quadwords depend on whether the symbol represents a procedure entry point, data location, or a constant. Figure 6.1 illustrates the contents of a symbol vector entry for each of these three types of symbols. Note that, at link time, a symbol vector entry for a procedure entry point or a data location is expressed as an offset into the image. At image activation time, when the image is loaded into memory and the base address of the image is known, the image activator converts the image offset into a virtual address. Figure 6.1 shows the contents of the symbol vector at link time and at image activation time.

Figure 6.1. Symbol Vector Contents
Symbol Vector Contents

Note that the linker does not allow programs to make procedure calls to symbols that represent data locations.

For VAX images, at link time, the value of a symbol in a shareable image (as listed in the GST of the image) is the offset into the image of the routine or data location, if the symbol was declared universal using the UNIVERSAL=option. If the symbol was declared universal using a transfer vector, the value of the symbol is the offset into the image of the transfer vector entry. If the symbol represents a constant, the GST contains the actual value of the constant.

The actual value of an address symbol in a shareable image is determined at run-time by the image activator when it loads the shareable image into memory. The image activator relocates all the address references within a shareable image when it loads the image into memory. Once it has determined the absolute values of these addresses, the image activator fixes up references to these addresses in the image that linked against the shareable image. Previously, the linker created fix-ups that flag to the image activator where it must insert the actual addresses to complete the linkage of a symbolic reference to its definition in an image. The linker listed these fix-ups in the fix-up section it creates for the image. For more information about shareable images, see Chapter 8.

For VAX images, you can specify the address at which you want a shareable image loaded into memory by using the BASE= option. When you specify this option, the linker can calculate the absolute addresses of symbols within the shareable image because the base address of the shareable image is known. By specifying a base address, you eliminate the need for the image activator to perform fix-ups and relocations.

Note, however, that basing a shareable image can potentially destroy upward compatibility between the shareable image and other images that were linked against it.

Figure 6.2 illustrates the interdependencies created by symbolic references among the modules that make up an application. In the figure, arrows point from a symbol reference to a symbol definition. (The statements do not reflect a specific programming language.)

The linker creates an image even if it cannot find a definition for every symbol referenced in the input files it processes. The linker reports these undefined symbols as in the following example, if at least one of these unresolved references is a strong reference. (For information about strong and weak symbolic references, see Section 6.5). The linker includes the message in the map file, if a map file was requested.
$ link  my_main  ! The module MY_MATH is omitted
%LINK-W-NUDFSYMS, 1 undefined symbols:
1 %LINK-I-UDFSYM,         MYSUB
2 %LINK-W-USEUNDEF, undefined symbol MYSUB referenced
        in psect $CODE offset %X0000001A
        in module MY_MAIN file WORK:[PROGRAMS]MY_MAIN.OBJ;1

1

The linker issues an informational message for each symbol for which it cannot find a definition.

2

The linker issues a warning message for each instance where an undefined symbol is referenced in the image.

If you run an image that contains undefined symbols and the symbols are never accessed, the program will run successfully. If you run an image that contains undefined symbols and the image accesses the symbols at run-time, the image will abort, in most cases, with an access violation because the linker assigns the value zero to undefined symbols, as in the following example:
$ run my_main
%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=00000000,
PC=00001018, PSL=03C00000
%TRACE-F-TRACEBACK, symbolic stack dump follows
module name     routine name                 line   rel PC    abs PC
MY_MAIN         main                          15   00000018  00001018

6.2. Input File Processing for Symbol Resolution

The linker can include object modules, shareable images, and libraries in its symbol resolution processing. For VAX images, the linker can also include a symbol table file in its symbol resolution processing. (Options files, in which linker options and input files are specified, are not included in symbol resolution).

By default, when the linker processes an object module or shareable image, it includes all the symbol definitions from the object module or shareable image in its processing. However, if you append the /SELECTIVE_SEARCH qualifier to the object module or shareable image file specification, the linker includes in its processing only those symbols from the object module or shareable image that define symbols referenced in a previously processed input file. For more information about selectively processing input files, see Section 6.2.4.

Table 6.1 summarizes how the linker processes these different types of input files when performing symbol resolution. The following sections provide more detail on the linker's processing of each type of input file.
Table 6.1. Linker Input File Processing

Input File

How Processed

Object file (.OBJ)

By default, the linker processes all the symbol definitions and references listed in the GSD of the module. If you append the /SELECTIVE_SEARCH qualifier to the input file specification, the linker includes in its processing only those symbol definitions from the GSD that resolve symbolic references found in previously processed input files.

Shareable image file (.EXE)

By default, the linker processes all symbol definitions and references listed in the GST of the image. Note, however, to avoid cluttering the map file of the resultant image, the linker lists only those symbol definitions in the map file that are referenced by other modules.

If you append the /SELECTIVE_SEARCH qualifier to the input file specification,the linker includes in its processing only those symbol definitions from the GST that resolve symbolic references found in previously processed input files.

Symbol table file (.STB)?

By default, the linker processes all the symbol definitions and references in the GSD of the module. If you append the /SELECTIVE_SEARCH qualifier to the input file specification, the linker includes in its processing only those symbol definitions from the module that resolve symbolic references found in previously processed input files.

Library files (.OLB)

The linker searches the name table of the library for symbols that are undefined in previously processed input files. (A library file's name table lists all the symbols available in all of the modules it contains). If the linker finds the definition of a symbol referenced by a previously processed input file, it includes in the link operation the module in the library that contains the definition of the symbol. Once the object module or shareable image is included in the link operation, the linker processes it as any other object module or shareable image.

If you append the /INCLUDE qualifier to a library file specification, the linker does not search the library's name table to find undefined symbolic references. Instead, the linker simply includes the specified object module or shareable image specified as a parameter to the /INCLUDE qualifier.

You cannot process a library file selectively. However, if the Librarian utility's /SELECTIVE_SEARCH qualifier was specified when the object module or shareable image was inserted into the library, the linker will process the module selectively when it extracts it from the library.

6.2.1. Processing Object Modules

The way the linker processes object modules to resolve symbolic references illustrates how the linker processes most other input files. (Symbol table files are object modules. The GST of a shareable image, which the linker processes in symbol resolution, is also created as an object module appended to the shareable image).

For example, the program in Example 6.1 references the symbol mysub.
Example 6.1. Module Containing a Symbolic Reference: my_main.c
#include <stdio.h>
int mysub();
main()
{
   int num1, num2, result;
   num1   = 5;
   num2   = 6;
   result = 0;
   result = mysub( num1, num2 );
   printf("Result is: %d\n", result);
}
mysub, which Example 6.1 references, is defined in the program in Example 6.2.
Example 6.2. Module Containing a Symbol Definition: my_math.c
int myadd(int value_1,int value_2) {
   int result;
   result = value_1 + value_2;
   return( result);
}
int mysub(int value_1,int value_2)
   int result;
   result = value_1 - value_2;
   return( result);
}
int mymul(int value_1,int value_2)
   int result;
   result = value_1 * value_2;
   return( result);
}
int mydiv(int value_1,int value_2)
   int result;
   result = value_1 / value_2;
   return( result);
}
The GSD created by the language processor for the object module MY_MAIN.OBJ lists the reference to the symbol mysub. Because object modules cannot be examined using a text editor, the following representation of the GSD is taken from the output of the ANALYZE/OBJECT utility. The example is from the analysis of an OpenVMS Alpha object module. Differences between the format of the symbol reference between VAX object files and Alpha object files are highlighted in the list following the example.
4.  GLOBAL SYMBOL DIRECTORY (EOBJ$C_GSD) 1, 344 bytes
               .
               .
               .
        9)  Global Symbol Specification (EGSD$C_SYM) 2
                data type: DSC$K_DTYPE_Z (0)
                symbol flags:
                        (0)  EGSY$V_WEAK      0
                        (1)  EGSY$V_DEF       0
                        (2)  EGSY$V_UNI       0
                        (3)  EGSY$V_REL       0
                        (4)  EGSY$V_COMM      0
                        (5)  EGSY$V_VECEP     0 3
                        (6)  EGSY$V_NORM      0 4
                symbol: "MYSUB"

1

For VAX object files, the symbol for the global symbol directory is OBJ$C_GSD.

2

For VAX object files, the symbol for a global symbol specification is GSD$C_SYM.

3

For VAX object files, this field is not included.

4

For VAX object files, this field is not included. For Alpha object files, the value of this field is always zero for symbolic references.

The GSD created by the language processor for the object module MY_MATH.OBJ contains the definition of the symbol mysub, as well as the other symbols defined in the module. The definition of the symbol includes the value of the symbol.

The following excerpt from an analysis of the OpenVMS Alpha object module (performed using the ANALYZE/OBJECT utility) shows the format of a GSD symbol definition entry. Note that, in an OpenVMS Alpha object module, a symbol definition is listed as a Global Symbol Specification.
4.  GLOBAL SYMBOL DIRECTORY (EOBJ$C_GSD), 46 bytes
        .
        .
        .
        9)  Global Symbol Specification (EGSD$C_SYM)
                data type: DSC$K_DTYPE_Z (0)
                symbol flags:
                        (0)  EGSY$V_WEAK      0
                        (1)  EGSY$V_DEF       1
                        (2)  EGSY$V_UNI       0
                        (3)  EGSY$V_REL       1
                        (4)  EGSY$V_COMM      0
                        (5)  EGSY$V_VECEP     0
                        (6)  EGSY$V_NORM      1 1
           2   psect: 3
           3   value: 64 (%X'00000040')
           4   code address psect: 5
           5   code address: 8 (%X'00000008')
                symbol: "MYSUB"
                 .
                 .
                 .

1

The value of the EGSY$V_NORM flag is 1 if the symbol represents a procedure. The value is set to zero if the symbol represents data.

2

The index of the program section that contains the procedure descriptor for mysub.

3

The location of the procedure descriptor expressed as the offset from the starting address of the program section that contains the procedure descriptor.

4

Index of program section that contains the code entry point.

5

The location of the code entry point, expressed as the offset from the starting address of the program section that contains the entry point.

The following excerpt from an analysis of the OpenVMS VAX object module (performed using the ANALYZE/OBJECT utility) shows the format of a GSD symbol definition entry. Note that, on VAX systems, a symbol definition is listed as an Entry Point Symbol and Mask Definition record.
4.  GLOBAL SYMBOL DIRECTORY (OBJ$C_GSD), 46 bytes
        .
        .
        .
        2)  Entry Point Symbol and Mask Definition (GSD$C_EPM)
                data type: DSC$K_DTYPE_Z (0)
                symbol flags:
                        (0)  GSY$V_WEAK       0
                        (1)  GSY$V_DEF        1
                        (2)  GSY$V_UNI        0
                        (3)  GSY$V_REL        1
                        (4)  GSY$V_COMM       0
                psect: 0
                value: 0 (%X'0000000C')
                entry mask: <>
                symbol: "MYSUB"
                  .
                  .
                  .

The value of the symbol is expressed as an offset into a program section.

When you link the modules shown in Example 6.1 and Example 6.2 together to create an image, you specify both object modules on the command line, as in the following example:
$ LINK MY_MAIN, MY_MATH 

When the linker processes these object modules, it reads the contents of the GSDs, obtaining the value of the symbol from the symbol definition.

Note that, for Alpha images, in the map file associated with the image, the value of the symbol mysub is the location within the image of the procedure descriptor for the routine. The procedure descriptor contains the address of the routine within the image.

For VAX images, the value of the symbol mysub is represented in the map file as the location of the entry point mask.

6.2.2. Processing Shareable Images

When the linker processes a shareable image specified as input in a link operation, it processes all the symbol definitions and references in the GST of the image. The GST contains all the universal symbols defined in the shareable image. Because the linker creates the GST of a shareable image in the format of an object module, the processing of shareable images for symbol resolution is similar to the processing of object modules. Note that the linker includes in the map file only those symbols that resolve references to avoid cluttering the listing with extraneous symbols.

For example, the program in Example 6.2 (in Section 6.2.1) can be implemented as a shareable image. (For information about creating a shareable image, see Chapter 8). The shareable image can be included in the link operation as in the following example:
$ LINK/MAP/FULL   MY_MAIN, SYS$INPUT/OPT
MY_MATH/SHAREABLE

The GST created by the linker for the shareable image MY_MATH.EXE contains the definition of the symbol mysub, as well as the other symbols defined in the module.

Because images cannot be examined using a text editor, the following representations of the GST are taken from the output of the ANALYZE/IMAGE utility.

For Alpha images, the universal symbol mysub in the shareable image MY_MATH.EXE appears in the GST of the image as a Universal Symbol Specification record, as illustrated in the following example:
SHAREABLE IMAGE - GLOBAL SYMBOL TABLE
            .
            .
            .
4.  GLOBAL SYMBOL DIRECTORY (EOBJ$C_EGSD), 200 bytes
            .
            .
            .
        3) Universal Symbol Specification (EGSD$C_SYMG)
                data type: DSC$K_DTYPE_Z (0)
                symbol flags:
                        (0)  EGSY$V_WEAK      0
                        (1)  EGSY$V_DEF       1
                        (2)  EGSY$V_UNI       1
                        (3)  EGSY$V_REL       1
                        (4)  EGSY$V_COMM      0
                        (5)  EGSY$V_VECEP     0
                        (6)  EGSY$V_NORM      1
                psect: 0
                value: 16 (%X'00000010')
                symbol vector entry (procedure)
                        %X'00000000 00010008'
                        %X'00000000 00000040'
                symbol: "MYSUB"
            .
            .
            .

Note that the value of the symbol, as it appears in the Universal Symbol Specification, is the location of the symbol's entry in the image's symbol vector, expressed as an offset from the base of the symbol vector. The symbol vector entry contains the address of mysub's entry point and the address of its procedure descriptor. These locations are expressed as offsets from the base of the image. The entry for a symbol in the GST of an image is a duplicate of the symbol's entry in the symbol vector.

For VAX images, the universal symbol mysub in the shareable image MY_MATH.EXE appears in the GST of the image as an Entry Point Symbol and Mask Definition record, as illustrated in the following example:
SHAREABLE IMAGE - GLOBAL SYMBOL TABLE
            .
            .
            .
        2)  Entry Point Symbol and Mask Definition (GSD$C_EPM)
                data type: DSC$K_DTYPE_Z (0)
                symbol flags:
                        (0)  GSY$V_WEAK       0
                        (1)  GSY$V_DEF        1
                        (2)  GSY$V_UNI        1
                        (3)  GSY$V_REL        1
                        (4)  GSY$V_COMM       0
                psect: 0
                value: 8 (%X'00000008')
                entry mask: <>
                symbol: "MYSUB"
            .
            .
            .

Note that the flag GSY$V_UNI is set for universal symbols to distinguish them from global symbols in object modules that use the same record format.

Implicit Processing of Shareable Images

For VAX linking, when you specify a shareable image in a link operation, the linker not only processes the shareable image you specify, but also all the shareable images that the shareable image has been linked against. (A shareable image contains a global image section descriptor [GISD] for each shareable image to which it has been linked).

For Alpha linking, the linker does not process the shareable images that the shareable image you specify has been linked against. (Shareable images on Alpha systems still contain GISDs for each shareable image that they have been linked against, however). If your application's build procedure depends on implicit processing of shareable images, you may need to add these shareable images to your linker options file.

6.2.4. Processing Input Files Selectively

By default, the linker processes all the symbol definitions and references in an object module or a shareable image specified as input in a link operation. However, if you append the /SELECTIVE_SEARCH qualifier to an input file specification, the linker processes from the input file only those symbol definitions that resolve references in previously processed input files.

Processing input files selectively can reduce the amount of time a link operation takes and can conserve the linker's use of virtual memory. Note, however, that selective processing can also introduce dependencies on the ordering of input files in the LINK command.

Note

Processing files selectively does not affect the size of the resultant image; the entire object module is included in the image even if only a subset of the symbols it defines is referenced. (Shareable images do not contribute to the size of an image).

For example, in the link operation in Section 6.2.2, the linker processes the shareable image MY_MATH.EXE before it processes the object module MY_MAIN.OBJ because of the way in which the linker clusters input files. (For information about how the linker clusters input files, see Section 6.3.2.1). When it processes the shareable image, the linker includes on its list of symbol definitions all the symbols defined in the shareable image. When it processes the object module MY_MAIN.OBJ and encounters the reference to the symbol mysub, the linker has the definition to resolve the reference.

If you append the /SELECTIVE_SEARCH qualifier to the shareable image file specification and all of the other input files are specified on the command line, the link will fail. In the following example, because the linker has no symbols on its undefined symbol list when it processes the shareable image file MY_MATH.EXE, it does not include any symbol definitions from the shareable image in its processing. When it subsequently processes the object module MY_MAIN.OBJ that references the symbol mysub, the linker cannot resolve the reference to the symbol. For information about how to correct this link operation, see Section 6.3.2.1.
$ LINK MY_MAIN, SYS$INPUT/OPT
MY_MATH/SHAREABLE/SELECTIVE_SEARCH
Ctrl/Z
%LINK-W-NUDFSYMS, 1 undefined symbol:
%LINK-I-UDFSYM,         MYSUB
%LINK-W-USEUNDEF, undefined symbol MYADD referenced
        in psect $CODE offset %X00000011
        in module MY_MAIN file WORK:[PROGRAMS]MY_MAIN.OBJ;6
To process object modules or shareable images in a library selectively, you must specify the /SELECTIVE_SEARCH qualifier when you insert the module in the library. The following example creates the library MYMATH_LIB.OLB and inserts the file MY_MATH.OBJ into the library. For more information about using the Librarian utility, see the VSI OpenVMS Command Definition, Librarian, and Message Utilities Manual.
$ LIBRARY/CREATE/INSERT MYMATH_LIB MY_MATH/SELECTIVE_SEARCH

6.3. Ensuring Correct Symbol Resolution

For many link operations, the order in which the input files are specified in the LINK command is not important. However, in complex link operations that specify many library files or process input files selectively, to ensure that the linker resolves all the symbolic references among the input files as you intend, you may need to be aware of the order in which the linker processes the input files. To control the order in which the linker processes input files, you must understand how the linker parses the command line.

6.3.1. Understanding Cluster Creation

As it parses the command line, the linker groups the input files you specify into clusters and places these clusters on a cluster list. A cluster is an internal linker construct that determines image section creation. The position of an input file in a cluster and the position of that cluster on the linker's cluster list determine the order in which the linker processes the input files you specify.

The linker always creates at least one cluster, called the default cluster. The linker may create additional clusters, called named clusters, depending on the types of input files you specify and the linker options you specify. If it creates additional clusters, the linker places them on the cluster list ahead of the default cluster, in the order in which it encounters them in the options file. The default cluster appears at the end of the cluster list. (Within the default cluster, input files appear in the same order in which they are specified on the LINK command line).

Clusters for shareable images specified in shareable image libraries appear after the default cluster on the cluster list because they are created later in linker processing, when the linker knows which shareable images in the library are needed for the link operation.

The linker groups input files into clusters according to file type. Table 6.2 lists the types of input files accepted by the linker and describes how the linker processes them when creating clusters.
Table 6.2. Linker Input File Cluster Processing

Input File

Cluster Processing

Object file (.OBJ)

Placed in the default cluster unless explicitly placed in a named cluster using the CLUSTER= option.

Shareable image file (.EXE)

Always placed in a named cluster.

Symbol table file (.STB)?

Placed in the default cluster unless explicitly placed in a named cluster using the CLUSTER= option.

Library files (.OLB)

Placed in the default cluster unless explicitly placed in a named cluster using the CLUSTER= option. If the library contains shareable images and the linker includes a shareable image from the library in the link operation, the linker creates a new cluster for the shareable image.

The linker puts input files included in a link operation from a library using the /INCLUDE qualifier in the same cluster as the library.

The linker puts modules extracted from any default user library that is an object library and from STARLET.OLB in the default cluster. However, because they are shareable images, the linker puts modules extracted from IMAGELIB.OLB into new clusters at the end of the cluster list (after the default cluster).

Options file (.OPT)

Not placed in a cluster.

The following example illustrates how the linker puts the various types of input files in clusters. To see which clusters the linker creates for this link operation, look at the Image Section Synopsis section of the image map file. Figure 6.3 illustrates the clusters created for this link operation.
$ DEFINE LNK$LIBRARY  SYS$DISK:[]MY_DEFAULT_LIB.OLB
$ LINK  MY_MAIN.OBJ, MY_LIB.OLB/LIBRARY, SYS$INPUT/OPT
CLUSTER=MY_CLUS,,,MY_PROG.OBJ
MY_SHARE.EXE/SHAREABLE
MY_SHARE_LIB.OLB/LIBRARY
MY_TAB.STB
Figure 6.3. Clusters Created for Sample Link
Clusters Created for Sample Link

The linker processes input files in cluster order: processing each input file starting with the first file in the first cluster, then the second, and so on, until it has processed all files in the first cluster. Then it does the same for the second cluster, and the next, and so on, until it has processed all files in all clusters.

6.3.2. Controlling Cluster Creation

You can control in which cluster the linker places an input file by using either of the following linker options:
  • CLUSTER= option

  • COLLECT= option

6.3.2.1. Using the CLUSTER= Option to Control Clustering

The 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 6.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.
$ link/executable=my_main sys$input/opt
CLUSTER=mymain_clus,,,my_main
my_math/shareable/selective_search
Ctrl/Z

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:

                               +------------------------+
                               ! Object Module Synopsis !
                               +------------------------+
Module Name     Ident              Bytes      File
-----------     -----              -----      -----
MY_MAIN         V1.0                  105 MY_MAIN.OBJ;1
MY_MATH         V1.0                   12 MY_MATH.EXE;1
   .
   .
   .

6.3.2.2. Using the COLLECT= Option to Control Clustering

You 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.

6.4. Resolving Symbols Defined in the OpenVMS Executive

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 Chapter 10.

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 6.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 6.4. Linker Processing of Default Libraries and SYS$BASE_IMAGE.EXE
Linker Processing of Default Libraries and SYS$BASE_IMAGE.EXE

6.5. Defining Weak and Strong Global Symbols

In 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 reports the undefined symbol and assigns the symbol a value, which usually results in a run-time error for accessing the data or calling the routine.

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:
  • The linker will not search library modules that have been specified with the /LIBRARY qualifier or default libraries (user-defined or system) solely to resolve a weak reference. If, however, the linker resolves a strong reference to another symbol in such a module, it will also use that module to resolve any weak references.

  • If the linker cannot locate the definition needed to resolve a weak reference, it assigns the symbol a value of 0, but does not report an error (as it does if the reference is strong). If, however, the linker reports any unresolved strong references, it will also report any unresolved weak references.

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 7. Understanding Image File Creation (Alpha and VAX)

This chapter describes how the linker creates an image on OpenVMS Alpha and OpenVMS VAX systems. The linker creates images from the input files you specify in a link operation. You can control image file creation by using linker qualifiers and options.

7.1. Overview of Creating Images on Alpha/VAX Systems

After the linker has resolved all symbolic references between the input files specified in the LINK command (described in Chapter 6), the linker knows all the object modules and shareable images that are required to create the image. For example, the linker has extracted from libraries specified in the LINK command those modules that contain the definitions of symbols required to resolve symbolic references in other modules. The linker must now combine all these modules into an image.

To create an image, the linker must perform the following processing:
  • Determine the memory requirements of the image. The memory requirements of an image are the sum of the memory requirements of each object module included in the link operation. The language processors that create the object modules specify the memory requirements of an object module as program section definitions. A program section represents an area of memory that has a name, a length, and other characteristics, called attributes, which describe the intended or permitted usage of that portion of memory. Section 7.2 describes program sections.

    The linker processes the program section definitions in each object module,combining program sections with similar attributes into an image section. Each image section specifies the size and attributes of a portion of the virtual memory of an image. The image activator uses the image section attributes to determine the characteristics of the physical memory pages into which it loads the image, such as protection.

    Figure 7.1 illustrates how memory requirements are communicated from the language processor to the linker and from the linker to the image activator. Section 7.3 provides more information about this process.

    Figure 7.1. Communication of Image Memory Requirements on Alpha/VAX
    Communication of Image Memory Requirements on Alpha/VAX

    Note that shareable images included in link operations have already been processed by the linker. These images are separate images with their own memory requirements, as specified by their own image sections. The linker does, however, create special global image section descriptors (GISDs) for each shareable image to which an image has been linked. The image activator activates these shareable images at run-time.

  • Initialize the image. When image sections are first created, they are empty. In this step of linker processing, the linker fills the image sections with the machine code and data, as specified by the Text Information and Relocation (TIR) commands in the object module. Section 7.4 provides more information about this process.

    For Alpha linking, the linker also attempts to optimize the performance of an image by replacing Jump to Subroutine (JSR) instruction sequences with the more efficient Branch to Subroutine (BSR) instruction sequences.

After creating image sections and filling them with binary code and data, the linker writes the image to an image file. Section 7.4.1 describes this process. To keep the size of image files manageable, the linker does not allocate space in the image file for image sections that have not been initialized with any data unless this function has been disabled (that is, the linker does not write pages of zeros to the image file). The linker can create demand-zero image sections, which the operating system initializes at run-time when a reference to the image section requires the operating system to move the pages into memory. Section 7.4.3 describes how the linker creates demand-zero image sections.

7.2. Creating Program Sections (Alpha/VAX)

Language processors create program sections and define their attributes. The number of program sections created by a language processor and the attributes of these program sections are dependent upon language semantics. For example, some programming languages implement global variables as separate program sections with a particular set of attributes. Programmers working in high-level languages typically have little direct control over the program sections created by the language processor. Medium- and low-level languages provide programmers with more control over program section creation. For more information about the program section creation features of a particular programming language, please refer to the appropriate OpenVMS programming language documentation.

In general, the linker does not create program sections. However, for Alpha linking, the linker creates a special program section for a shareable image, named $SYMVECT, which contains the symbol vector of the shareable image.

Program Section Attributes

The language processors define the attributes of the program sections they create and communicate these attributes to the linker in program section definition records in the global symbol directory (GSD) in an object module. (The GSD also contains global symbol definitions and references, as described in Chapter 6).

Program section attributes control various characteristics of the area of memory described by the program section, such as the following:
  • Access. Using program section attributes, compilers can prohibit some types of access, such as write access. Using other program section attributes, compilers can allow access to the program section by more than one process.

  • Positioning. By specifying certain program section attributes, compilers can specify to the linker how it should position the program section in memory.

Program section attributes are Boolean values, that is, they are either on or off. Table 7.1 lists all program section attributes with the keyword you can use to set or clear the attribute, using the PSECT_ATTR=option. For more information about using the PSECT_ATTR= option, see Section 7.3.6.

For example, to specify that a program section should have write access,specify the writability attribute as WRT. To turn off an attribute, specify the negative keyword. Some attributes have separate keywords that express the negative of the attribute. For example, to turn off the global attribute (GBL), you must specify the local attribute (LCL). Note that the alignment of a program section is not strictly considered an attribute of the program section. However, because you can set it using the PSECT_ATTR= option, it is included in the table.
Table 7.1. Program Section Attributes (Alpha/VAX)
AttributeKeywordDescription

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:

Power of 2KeywordMeaning
0BYTEAlignment on byte boundaries.
1WORDAlignment on word boundaries.
2LONGAlignment on longword boundaries.
3QUADAlignment on quadword boundaries.
4OCTAAlignment on octaword boundaries.
9Alignment on 512-byte boundaries.
13Alignment on 8 KB boundaries.
14Alignment on 16 KB boundaries.
15Alignment on 32 KB boundaries.
16Alignment on 64 KB boundaries.
PAGEAlignment on the default target page size, which is 64 KB for Alpha linking and 512 bytes for VAX linking. You can override this default by specifying the /BPAGE qualifier.

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 Chapter 10.

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 7.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 VSI 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 to OpenVMS.

User/Library

USR/LIB

Reserved to OpenVMS. 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 7.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 7.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 7.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 7.4 presents an excerpt from the analysis of the object module MYTEST.OBJ. Only the program section definitions are included in the excerpt.
Example 7.4. Program Sections Generated by Example 7.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"
             .
             .
             .

Note that you can also determine the program sections in an object module after a link operation by looking at the Program Section Synopsis section of an image map file, as illustrated in Example 7.7.

1

Alignment specifies the address boundary at which the linker places a module's contribution to the program section.

2

Attribute flags indicate which program section attributes are set. The attributes are listed by their full symbolic name, that is, each abbreviation is preceded by the character string GPS$V_. Note that, for attributes that are turned off by specifying different keywords, only the keyword that sets the attribute is listed. For example, you can see whether the program section is overlaid by checking attribute flag number 2. If the value is 1, the program section is overlaid; if the value is 0, the program section must be concatenated. Table 7.1 lists all the program section attributes. Note that the solitary attribute is not included in the GSD of an object module because that attribute is not set by language processors.

For Alpha linking, the program section display includes several additional attribute flags. The COM attribute is reserved to OpenVMS. The NOMOD attribute indicates that the program section does not contain initialized data. The linker gathers program sections with this attribute into demand-zero image sections. Section 7.4.3 describes how the linker creates demand-zero image sections.

3

Allocation indicates the number of bytes required for the program section.

4

Symbol indicates the name of the program section.

Figure 7.2 illustrates the program sections created by the VAX C compiler for the programs in Examples 7.1, 7.2, and 7.3. (The shaded areas represent the settings of the program section attributes the linker considers when sorting the program sections into image sections in an executable image. See Section 7.3.3 for more information about how the linker creates image sections).

Figure 7.2. Program Sections Created for Examples 7.1, 7.2, and 7.3
Program Sections Created for Examples 7.1, 7.2, and 7.3

7.3. Creating Image Sections

To create the image sections that define the memory requirements and page protection characteristics of an image, the linker processes the program section definitions in the object modules specified in the link operation. The number and type of image sections the linker creates depend on the number of clusters the linker creates when processing the LINK command and on the attributes of the program sections in the object modules in each cluster. Section 7.3.1 describes how the clustering of input files affects image section creation. Section 7.3.2 describes the effects of program section attributes on image section creation.

7.3.1. Processing Clusters to Create Image Sections

To create image sections, the linker processes the program section definitions in the input files you specify in the LINK command. The linker processes these input files on a cluster-by-cluster basis (as described in Section 6.3.1).

In general, only program sections in a particular cluster can contribute to a particular image section. However, the linker crosses cluster boundaries when processing program sections with the global (GBL) attribute. When the linker encounters a program section with the global attribute, it searches all the previously processed clusters for a program section with the same name and attributes and, if it finds one, places the new definition of the global program section in the same cluster as the first definition of the program section.

The linker processes input files in the order in which they appear in the clusters, making two passes through the cluster list.

On its first pass, the linker processes based clusters. Based clusters specify the location within memory at which the linker must position them. A based cluster can be a cluster that contains a based shareable image or a cluster, created by the CLUSTER= option, in which a base address was specified.

For VAX linking, you can also use the BASE= option to specify the base address of the default cluster.

For more information about creating based clusters, see the descriptions of the CLUSTER= and BASE= options in Chapter 10.

After processing based clusters, the linker then processes non based clusters. The linker ignores non based (position-independent) shareable image clusters because they are allocated virtual memory at run-time.

A LINK command to create an image using the object modules in Section 7.2 is shown in Example 7.5.
The CLUSTER= option in this LINK command causes the linker to create a cluster named MYSUB_CLUS, which contains the object module MYSUB.OBJ. The linker also creates a cluster for the C Run-Time Library shareable image VAXCRTL.EXE. The linker puts the object modules MYTEST.OBJ and MYADD.OBJ in the default cluster. These clusters appear on the linker's cluster list in the following order:
  1. MYSUB_CLUS

  2. VAXCRTL

  3. DEFAULT_CLUSTER

The linker always processes the default cluster last. (For Alpha linking, you do not need to explicitly include the C Run-Time Library shareable image in the link operation because it resides in the default system shareable image library IMAGELIB.OLB, which the linker processes by default).

7.3.2. Combining Program Sections into Image Sections

The linker creates image sections by grouping together program sections with similar attributes. Within an image section, the linker organizes program sections alphabetically by name. If more than one object module contributes to the same program section, the linker lays out their contributions in the order it processes them.

Figure 7.3 shows how the linker groups the program sections in the object modules from the sample link into image sections, based on the setting of their significant attributes. In the figure, the settings of these significant attributes are represented by shading. (The figure considers attributes that are significant when creating executable images, not shareable images. Section 7.3.3 provides more information about which program section attributes are significant).

Note, in the figure, that the overlaid contributions from MYSUB.OBJ and MYTEST.OBJ to the program section, GLOBAL_DATA, both appear in the MYSUB_CLUS cluster, even though the object module MYTEST.OBJ is in the default cluster. The linker puts all contributions to a global program section in the cluster in which it is first defined.

Figure 7.3. Combining Program Sections into Image Sections
Combining Program Sections into Image Sections

7.3.3. Processing Significant Program Section Attributes (Alpha/VAX)

When combining program sections into image sections, the linker considers only a subset of program section attributes. The set of significant attributes varies according to the type of image being created. When creating an executable image, the linker considers all combinations of the following attributes when combining program sections into image sections:
  • Writability (WRT/NOWRT)

  • Executability (EXE/NOEXE)

  • Protected vector (VEC/NOVEC)

  • Unmodified (NOMOD/MOD) (Alpha linking only)

When creating a shareable image, the linker considers all combinations of the following attributes when combining program sections into image sections:
  • Writability (WRT/NOWRT)

  • Executability (EXE/NOEXE)

  • Shareability (SHR/NOSHR)

  • Position independence (PIC/NOPIC)

  • Protected vector (VEC/NOVEC)

  • Unmodified (NOMOD/MOD) (Alpha linking only)

The linker creates only one large image section for system images, so combining program sections by attributes is not applicable.

Tables 7.2 and 7.3 list all the possible combinations of program section attributes for executable images and shareable images. Note that the order in which the combinations appear in the table (each row) is the same order in which the linker processes them. For example,the linker first processes all program sections with the NOWRT, NOEXE, and NOVEC attributes, creating an image section of program sections with these attributes. The linker then processes all program sections with the WRT, NOEXE, and NOVEC attributes, creating an image section for these program sections. The linker continues this processing until all the combinations of significant attributes have been processed and all the program sections in the cluster have been placed in an image section.

The tables include only program sections that are relocatable (with the REL attribute). Absolute program sections (with the ABS attribute), by definition, can have no allocation (they contain only constants) and cannot contribute to an image section.

For OpenVMS Alpha images, the tables assume that the images are linked using the /DEMAND_ZERO qualifier, which is the default. (When this qualifier is specified, the linker groups program sections that do not contain any data into demand-zero image sections, allocating memory for the image section but not writing zeros to disk). If the image is linked with the /NODEMAND_ZERO qualifier, the linker allocates space for the image section in the image file. Note that the /NODEMAND_ZERO qualifier does not affect how the linker sorts program sections; it proceeds exactly as specified by the table. However, when the image is written, the linker allocates disk space for the image section and fills the space with zeros.

The tables also show how a particular combination of program section attributes determines the attributes of the image section in which it is placed. For more information about image section attributes, see Section 7.3.5.
Table 7.2. Mapping Program Section Attributes to Image Section Attributes for Executable Images

Significant Psect Attribute Settings?

Type of Isect

Isect Attributes Set?

NOWRT

NOEXE

NOVEC

?MOD

NORMAL

WRT

NOEXE

NOVEC

?MOD

"

WRT, CRF

NOWRT

EXE

NOVEC

?MOD

"

?EXE

WRT

EXE

NOVEC

?MOD

"

WRT, CRF, ?EXE

NOWRT

NOEXE

VEC

?MOD

"

VECTOR, PROTECT

WRT

NOEXE

VEC

?MOD

"

WRT, VECTOR, PROTECT, CRF

NOWRT

EXE

VEC

?MOD

"

VECTOR, PROTECT, ?EXE

WRT

EXE

VEC

?MOD

"

WRT, VECTOR, PROTECT, ?EXE

?NOWRT

?NOEXE

?NOVEC

?NOMOD

"

DZRO

?WRT

?NOEXE

?NOVEC

?NOMOD

"

WRT, DZRO?


Table 7.3. Mapping Program Section Attributes to Image Section Attributes for Shareable Images

Significant Psect Attribute Settings?

Type of Isect

Isect Attributes Set?

NOWRT

NOEXE

SHR

NOPIC

NOVEC

?MOD

SHRFXD

WRT

NOEXE

SHR

NOPIC

NOVEC

?MOD

"

WRT

NOWRT

EXE

SHR

NOPIC

NOVEC

?MOD

"

?EXE

WRT

EXE

SHR

NOPIC

NOVEC

?MOD

"

WRT, ?EXE

        

NOWRT

NOEXE

NOSHR

NOPIC

NOVEC

?MOD

PRVFXD

WRT

NOEXE

NOSHR

NOPIC

NOVEC

?MOD

"

WRT, CRF

NOWRT

EXE

NOSHR

NOPIC

NOVEC

?MOD

"

?EXE

WRT

EXE

NOSHR

NOPIC

NOVEC

?MOD

"

WRT, CRF, ?EXE

        

NOWRT

NOEXE

SHR

PIC

NOVEC

?MOD

SHRPIC

PIC

WRT

NOEXE

SHR

PIC

NOVEC

?MOD

"

WRT, PIC

NOWRT

EXE

SHR

PIC

NOVEC

?MOD

"

PIC, ?EXE

WRT

EXE

SHR

PIC

NOVEC

?MOD

"

WRT, PIC, ?EXE

      

NOWRT

NOEXE

NOSHR

PIC

NOVEC

?MOD

PRVPIC

PIC

WRT

NOEXE

NOSHR

PIC

NOVEC

?MOD

"

WRT, CRF, PIC

NOWRT

EXE

NOSHR

PIC

NOVEC

?MOD

"

PIC, ?EXE

WRT

EXE

NOSHR

PIC

NOVEC

?MOD

"

WRT, CRF, PIC, ?EXE

        

NOWRT

NOEXE

SHR

NOPIC

VEC

?MOD

SHRFXD

VECTOR, PROTECT

WRT

NOEXE

SHR

NOPIC

VEC

?MOD

"

WRT, VECTOR, PROTECT

NOWRT

EXE

SHR

NOPIC

VEC

?MOD

"

VECTOR, PROTECT, ?EXE

WRT

EXE

SHR

NOPIC

VEC

?MOD

"

WRT, VECTOR, PROTECT, ?EXE

    

NOWRT

NOEXE

NOSHR

NOPIC

VEC

?MOD

PRVFXD

VECTOR, PROTECT

WRT

NOEXE

NOSHR

NOPIC

VEC

?MOD

"

WRT, CRF

NOWRT

EXE

NOSHR

NOPIC

VEC

?MOD

"

VECTOR, PROTECT, ?EXE

WRT

EXE

NOSHR

NOPIC

VEC

?MOD

"

WRT, CRF, VECTOR, PROTECT, ?EXE

        

NOWRT

NOEXE

SHR

PIC

VEC

?MOD

SHRPIC

PIC, VECTOR, PROTECT

WRT

NOEXE

SHR

PIC

VEC

?MOD

"

WRT, PIC, VECTOR, PROTECT

NOWRT

EXE

SHR

PIC

VEC

?MOD

"

PIC, VECTOR, PROTECT, ?EXE

WRT

EXE

SHR

PIC

VEC

?MOD

"

WRT, PIC, VECTOR, PROTECT, ?EXE

        

NOWRT

NOEXE

NOSHR

PIC

VEC

?MOD

PRVPIC

PIC, VECTOR, PROTECT

WRT

NOEXE

NOSHR

PIC

VEC

?MOD

"

WRT, CRF, PIC, VECTOR, PROTECT

NOWRT

EXE

NOSHR

PIC

VEC

?MOD

"

PIC, VECTOR, PROTECT, ?EXE

WRT

EXE

NOSHR

PIC

VEC

?MOD

"

WRT, CRF, PIC, VECTOR, PROTECT, ?EXE

        

?NOWRT

?NOEXE

?SHR

?NOPIC

?NOVEC

?NOMOD

SHRFXD

?WRT

?NOEXE

?SHR

?NOPIC

?NOVEC

?NOMOD

"

WRT

        

?NOWRT

?NOEXE

?NOSHR

?NOPIC

?NOVEC

?NOMOD

PRVFXD

DZRO

?WRT

?NOEXE

?NOSHR

?NOPIC

?NOVEC

?NOMOD

"

WRT, DZRO?

        

?NOWRT

?NOEXE

?NOSHR

?PIC

?NOVEC

?NOMOD

PRVPIC

DZRO

?WRT

?NOEXE

?NOSHR

?PIC

?NOVEC

?NOMOD

"

WRT, DZRO?, PIC

        

?NOWRT

?NOEXE

?SHR

?PIC

?NOVEC

?NOMOD

SHRPIC

PIC

?WRT

?NOEXE

?SHR

?PIC

?NOVEC

?NOMOD

"

WRT, PIC

For example, Table 7.4 summarizes the settings of the significant attributes of the program sections in the module MYADD.OBJ. (Because this is an OpenVMS VAX object module, the MOD attribute is not considered).
Table 7.4. Significant Attributes of Program Sections in MYSUB_CLUS Cluster
 

Writability

Executability

Protected Vector

$CODE

NOWRT

EXE

NOVEC

DATA

WRT

NOEXE

NOVEC

$CHAR_STRING_CONSTANTS

WRT

NOEXE

NOVEC

The linker puts both the DATA and $CHAR_STRING_CONSTANTS program sections in the same image section because they both have the same settings of significant attributes. Within the image section, the linker organizes the program sections alphabetically, so the $CHAR_STRING_CONSTANTS program section appears before the DATA program section. The linker creates a separate image section for the $CODE program section.

The linker performs similar processing of the program sections in the default cluster. The Image Section Synopsis section of the map file lists the clusters the linker created and lists the image sections it created for each cluster. This section also describes the layout of the image in memory, including the base address of each image section. Example 7.6 illustrates an excerpt of the Image Section Synopsis section from the map file produced with the sample link. The listing includes clusters for contributions for the VAX C Run-Time Library.
Example 7.6. Image Section Information in a Map File
                                             +------------------------+
                                             ! Image Section Synopsis !
                                             +------------------------+
   Cluster      Type Pages   Base Addr  Disk VBN PFC Protection and Paging
   -------      ---- -----   ---------  -------- --- ---------------------
MYSUB_CLUS         0     1    00000200        2   0  READ WRITE   COPY ON REF
                   0     1    00000400        3   0  READ ONLY
VAXCRTL            3     4    00000000-R      0   0  READ ONLY
                   3     1    00000800-R      0   0  READ ONLY
                   4     1    00000A00-R      0   0  READ WRITE   COPY ON REF
                   3    17    00000C00-R      0   0  READ ONLY
                   3   142    00002E00-R      0   0  READ ONLY
                   4    21    00014A00-R      0   0  READ WRITE   COPY ON REF
                   4     1  P-00017400-R      0   0  READ WRITE   COPY ON REF
                   2     3    00017600-R      0   0  READ WRITE   FIXUP VECTORS
LIBRTL             3   193    00000000-R      0   0  READ ONLY
                   4     8    00018200-R      0   0  READ WRITE   DEMAND ZERO
MTHRTL             3   335    00000000-R      0   0  READ ONLY
                   2     1    00029E00-R      0   0  READ WRITE   FIXUP VECTORS
DEFAULT_CLUSTER    0     1    00000600        4   0  READ WRITE   COPY ON REF
                   0     1    00000800        5   0  READ ONLY
                   0     1    00000A00        6   0  READ WRITE   FIXUP VECTORS
                 253    20    7FFFD800        0   0  READ WRITE   DEMAND ZERO

For more information about the image section synopsis section of a map file, see Section 9.2.3.

To find out which program sections the linker placed in each image section, look at the Program Section Synopsis section of the map file. This section lists all the program sections in each cluster and lists the contributions (the number of bytes) to each program section from each object module. By comparing the base-address of the program sections with the base-addresses of the image sections in the Image Section Synopsis section, you can tell in which image section the program sections appear. Example 7.7 is an excerpt from the Program Section Synopsis section of the map file produced by the sample link operation.
Example 7.7. Program Section Information in a Map File (VAX Example)
                                        +--------------------------+
                                        ! Program Section Synopsis !
                                        +--------------------------+
Psect Name Module Name   Base     End      Length        Align      Attributes
---------- -----------   ----     ---      ------        -----      ----------
$DATA                  00000200 00000203 00000004 (  4.) LONG 2 PIC,USR,CON ...
           MYSUB       00000200 00000203 00000004 (  4.) LONG 2
GLOBAL_DATA            00000204 00000207 00000004 (  4.) LONG 2 PIC,USR,OVR ...
           MYSUB       00000204 00000207 00000004 (  4.) LONG 2
           MYTEST      00000204 00000207 00000004 (  4.) LONG 2
$CODE                  00000400 0000040B 0000000C ( 12.) LONG 2 PIC,USR,CON ...
           MYSUB       00000400 0000040B 0000000C ( 12.) LONG 2
$CHAR_STRING_CONSTANTS 00000600 0000062D 0000002E ( 46.) LONG 2 PIC,USR,CON ...
           MYTEST      00000600 00000623 00000024 ( 36.) LONG 2
           MYADD       00000624 0000062D 0000000A ( 10.) LONG 2
$DATA                  00000630 00000637 00000008 (  8.) LONG 2 PIC,USR,CON ...
           MYTEST      00000630 00000633 00000004 (  4.) LONG 2
           MYADD       00000634 00000637 00000004 (  4.) LONG 2
$CODE                  00000800 00000858 00000059 ( 89.) LONG 2 PIC,USR,CON ...
           MYTEST      00000800 0000083E 0000003F ( 63.) LONG 2
           MYADD       00000840 00000858 00000019 ( 25.) LONG 2
   .
   .
   .

For more information about the program synopsis section of a map file, see Section 9.2.4.

7.3.4. Allocating Memory for Image Sections

When it creates an image section, the linker allocates enough memory for the image section to accommodate all the program sections it contains. Each program section definition includes its size.

The linker aligns image sections on CPU-specific page boundaries. Within an image section, the linker assigns to each program section a virtual address relative to the base address of the image section.

Concatenated Program Sections

If the program sections have the concatenated (CON) attribute set, the linker positions the program sections one after the other within an image section, inserting padding bytes between the program sections if necessary to achieve the alignment requirement of a particular contribution to a program section. The linker retains the alignment specified for each program section contribution but uses the largest alignment of a contributing module as the alignment of the whole program section.

Overlaid Program Sections

If the program sections have the overlaid (OVR) attribute set, the linker uses the same start address for the program sections so that they occupy the same virtual memory (that is, the program sections overlay each other). For overlaid program sections, the linker allocates enough space to accommodate the largest of all the program section contributions. Note that the linker does not generate a warning message if the contributions specify different size allocations.

Any module can initialize the contents of an overlaid program section. However, the final contents of the program section are determined by the last contributing module. Therefore, the order in which you specify the input modules is important.

Assigning Virtual Addresses

The linker keeps track of free (available) virtual addresses by maintaining a free virtual memory list. For each cluster, the linker determines the number of pages required, searches the list beginning at the lowest virtual address for a contiguous number of pages large enough to contain the cluster, allocates those addresses to the cluster, then removes those addresses from the list.

The linker allocates virtual memory to the first cluster beginning at a page size boundary for executable images in the P0 region of the user's virtual address space, unless the cluster is based, in which case it allocates virtual memory beginning at the specified address. For VAX linking,the default is 512 (200 hexadecimal). However, you can specify the page size using the /BPAGE qualifier. For information about the /BPAGE qualifier, see Chapter 10.

On its first pass through the cluster list, the linker allocates virtual addresses to any based user clusters or based shareable image clusters on the cluster list, removing the allocated addresses from the free virtual memory list as it proceeds. On its second pass, it repeats this procedure for non based user clusters. (Remember that non based shareable image clusters will have memory allocated for them at run-time).

Because the linker processes clusters in the order of their appearance on the cluster list, the virtual address space of the final image will generally contain contiguous image sections of consecutive clusters on the basis of their order in the cluster list. The presence of based clusters, however,may prevent such an outcome, and for this reason they are not recommended.

After allocating memory for a cluster, the linker relocates its contents by performing the following processing:
  1. Relocating each image section. The linker adds the starting virtual address of the cluster to the relative offset of the image section from the cluster base and places the result in the appropriate field of the image section descriptor (ISD).

  2. Relocating each program section in the image section. The linker adds the newly calculated starting virtual address of the image section to the relative offset of the program section from the base of the image section.

  3. Relocating each global symbol in the program section. The linker adds the newly calculated program section virtual address to the relative offset of the global symbols from the base of the program section.

7.3.5. Image Section Attributes

When it creates image sections, the linker assigns attributes to the image section based on the attributes of the program sections it contains. The image section attributes describe certain characteristics of the portion of memory they represent, for example, the protection characteristics. For example, an image section that contains program sections with the writability attribute also has the writability attribute set. Tables 7.2 and 7.3 include the image section attributes associated with an image section that contains program sections with a particular set of attributes. Table 7.5 lists all the image section attributes. Image section attributes, like program section attributes, are Boolean values that are either on or off.

Table 7.5. Image Section Attributes
AttributeSymbolFunction

Global

[E]ISD$M_GBL

GBL is set when the ISD came from a shareable image. On both VAX and Alpha systems, the first ISD of a shareable image is included in the base image for use by the image activator. For VAX linking, if the shareable image is based, all of its ISDs are included in the image being linked.

Copy On Reference

[E]ISD$M_CRF

CRF is set whenever the psect attributes are WRT and not SHR. CRF is also set by the linker whenever it creates fix-ups to the section (which require the image activator to write to it).

Demand Zero

[E]ISD$M_DZRO

Demand zero is set for VAX linking for executable images if:
  • The section was never written to with a TIR (Text and Information Relocation) command.

  • The section resulted from compression of empty pages from an existing section.

Demand zero is set for Alpha executable and Alpha shareable images if the user has not specified /NODEMAND_ZERO and if:
  • The section was never written to with an ETIR command.

  • The program sections in the section have the NOMOD bit set.

DZRO is always set for stack ISDs on both Alpha images and VAX images.

Executability

[E]ISD$M_EXE

The EXE attribute is inherited from the program section.

Write

[E]ISD$M_WRT

The WRT attribute is inherited from the program section. WRT is also set by the linker if fix-ups are made to the section. When this is done, the linker also generates a change protection fix-up so that the image activator can change the protection back to NOWRT after the fix-up is applied.

Match Control

ISD$M_MATCHCTL

This is used only for VAX images. It is not an attribute. MATCHCTL is a 3-bit field inside the flags field. It contains the match control bits. For Alpha images, this information is contained in a completely separate field.

Last Cluster

[E]ISD$M_LASTCLU

LASTCLU is set only for sections in executable images. LASTCLU indicates that an image section was generated off of the last cluster (which was not a shareable image cluster) in the cluster list. If FIXUPVEC is set, LASTCLU is clear.

Initial Code

[E]ISD$M_INITALCODE

This attribute is reserved to OpenVMS.

Based

[E]ISD$M_BASED

BASED indicates that the section is based. This is set when BASE= is specified in the options file. This attribute may also be set if based shareable images are encountered during linking. This attribute is present but not used for Alpha linking.

Fix-Up Vectors

[E]ISD$M_FIXUPVEC

FIXUPVEC marks the section that contains the image activator fix-ups. This section is created by the linker. The attribute cannot be set by the user.

Resident

[E]ISD$M_RESIDENT

This attribute is reserved to OpenVMS.

Vectored

[E]ISD$M_VECTOR

VECTOR indicates a vectored section,either a message section or a privileged library vector.

Protected

[E]ISD$M_PROTECT

Protect indicates that a section is protected. The linker sets the PROTECT attribute whenever VECTOR is set. PROTECT is also set if the /PROTECT qualifier is used, or if the cluster that the section is spawned from came after a PROTECT=YES option (and before a PROTECT=NO option).

The linker uses type designations instead of image section attributes to propagate the SHR and PIC program section attributes. The linker assigns the type designation [E]ISD$K_NORMAL for image sections in executable images. Image sections in shareable images can be any of the following types:

Image Section Type

Attribute Settings

Share fixed ([E]ISD$K_SHRFXD)

SHR, NOPIC

Private fixed ([E]ISD$K_PRVFXD)

NOSHR, NOPIC

Share position-independent ([E]ISD$K_SHRPIC)

SHR, PIC

Private position-independent ([E]ISD$K_PRVPIC)

NOSHR, PIC

The Image Section Synopsis section of a map file lists the attributes of each image section created in the Protection and Paging column. See Example 7.6 for an illustration. You can also get a listing of all the image sections created by the linker by using the ANALYZE/IMAGE utility. The output generated by this utility includes a list of all the image sections that make up the image, with their attributes. An excerpt from the analysis of the image file MYTEST.EXE is shown in Example 7.8.
Example 7.8. Image Section Descriptions in an ANALYZE/IMAGE Display
Image Section Descriptors (ISD)
1)1  image section descriptor (16 bytes)
  2  page count: 1
  3  base virtual address: %X'00000200' (P0 space)
  4  page fault cluster size: default
  5  IS flags:
    (0)  ISD$V_GBL        0
    (1)  ISD$V_CRF        1
    (2)  ISD$V_DZRO       0
    (3)  ISD$V_WRT        1
    (7)  ISD$V_LASTCLU    0
    (8)  ISD$V_INITALCODE 0
    (9)  ISD$V_BASED      0
    (10) ISD$V_FIXUPVEC   0
    (11) ISD$V_RESIDENT   0
    (17) ISD$V_VECTOR     0
    (18) ISD$V_PROTECT    0
  6  section type: ISD$K_NORMAL
  7  base VBN: 2
                        .
                        .
                        .
  9)  image section descriptor (31 bytes)
 page count: 193
 base virtual address: %X'00000000' (P0 space)
 page fault cluster size: default
 IS flags:
    (0)  ISD$V_GBL        1
    (1)  ISD$V_CRF        0
    (2)  ISD$V_DZRO       0
    (3)  ISD$V_WRT        0
    (7)  ISD$V_LASTCLU    0
    (8)  ISD$V_INITALCODE 0
    (9)  ISD$V_BASED      0
    (10) ISD$V_FIXUPVEC   0
    (11) ISD$V_RESIDENT   0
    (17) ISD$V_VECTOR     0
    (18) ISD$V_PROTECT    0
   section type: ISD$K_SHRPIC
   base VBN: 0
  8  global section major id: %X'01', minor id: %X'00000E'
  9  match control: ISD$K_MATLEQ
  10  global section name: "LIBRTL_001"

1

The size of the image section descriptor.

2

The size of the image section, expressed in pages. For Alpha images, the value is expressed in bytes.

3

The start address assigned to the image section by the linker. Note that this address is an offset from the beginning of the image, which is assumed to start at virtual address zero. (The linker always inserts an empty page at the beginning of every executable image). Note also that the linker does not assign a start address for image sections representing shareable images because this information cannot be determined until run-time, when the shareable image is loaded into memory by the image activator.

4

The number of pagelets that should be mapped in when the initial page fault occurs. You can set this value by using the CLUSTER= option.

5

The settings of image section attributes. Table 7.5 lists these attributes.

6

The type of image section, based on the combination of image section attributes.

7

The virtual block in the image file at which the image section begins.

8

Image sections that represent shareable images include the global section identification number, which specifies the identification number of the shareable image.

9

Image sections that represent shareable images also include a match control field that identifies the match control algorithm the image activator should apply to the global image section identification number when it activates the shareable image this ISD describes.

10

Image sections that represent shareable images include the global section name field, which is the name of the shareable image. The _001" is appended to the name by the linker to indicate which ISD in the image this represents.

7.3.6. Controlling Image Section Creation

You can control how the linker combines program sections into image sections in the following ways:
  • By modifying the attributes of program sections

  • By putting object modules into named clusters

  • By using the SOLITARY attribute

7.3.6.1. Modifying Program Section Attributes

The linker combines program sections in the same cluster into the same image section if they have the same settings for the significant program section attributes. To force the linker to put the program sections into different image sections, change the attributes of one of the program sections by using the PSECT_ATTR= option.

For example, in the sample link operation, the DATA program section and the $CHAR_STRING_CONSTANTS program section are combined into the same image section. If you want the $CHAR_STRING_CONSTANTS program section to appear in a different image section, change one of the significant attributes. For example, in the following link of the sample programs, the writability attribute is set to NOWRT. (For Alpha linking, you do not need to explicitly specify the C Run-Time Library in the link operation because it resides in the default system shareable image library [IMAGELIB.OLB], which the linker processes by default).
$ LINK/MAP/FULL MYTEST,MYADD,SYS$INPUT/OPT
CLUSTER=MYSUB_CLUS,,,MYSUB
PSECT_ATTR=$CHAR_STRING_CONSTANTS,NOWRT
SYS$LIBRARY:VAXCRTL/SHARE
Ctrl/Z
Example 7.9 presents an excerpt from the Image Section Synopsis section of the map file produced by this link.
Example 7.9. Image Section Synopsis of Second Link
   Cluster    Type Pages Base Addr Disk VBN PFC Protection and Paging ...
   -------    ---- ----- --------- -------- --- ---------------------
                .
                .
                .
DEFAULT_CLUSTER 0    1    00000600      4    0  READ ONLY
                0    1    00000800      0    0  READ WRITE   DEMAND ZERO
                0    1    00000A00      5    0  READ ONLY
                0    1    00000C00      6    0  READ WRITE   FIXUP VECTORS
              253   20    7FFFD800      0    0  READ WRITE   DEMAND ZERO
                .
                .
                .

Note that the default cluster contains one additional image section, a read-only image section beginning at virtual address 0x00000600, than the default cluster in the original link, illustrated in Section 7.3.1.

7.3.6.2. Manipulating Cluster Creation

In general, the linker creates image sections on a per-cluster basis; that is,only program sections within a particular cluster can contribute to image section creation. (The linker can collect program sections with the global attribute from all clusters into a single image section). To ensure that a program section appears in a particular image section, put the program section in a specific cluster.

For example, in the sample link operation illustrated in Example 7.5, the linker puts all the program sections in the object module MYSUB.OBJ in the cluster named MYSUB_CLUS because the CLUSTER= option is specified. If you wanted to group all of the program sections that contain code from all the other clusters into the MYSUB_CLUS cluster, you could specify the COLLECT= option, as in the following example. (By convention,VAX language processors put the code they generate into program sections named $CODE. Program section naming conventions are architecture specific).
$ LINK/MAP/FULL MYTEST, MYADD, SYS$INPUT/OPT
CLUSTER=MYSUB_CLUS,,,MYSUB
COLLECT=MYSUB_CLUS,$CODE
SYS$LIBRARY:VAXCRTL/SHARE
Ctrl/Z

7.3.6.3. Isolating a Program Section into an Image Section

You can specify that the linker place a particular program section into its own image section. This can be useful for programs that map data into predefined locations within an image.

To isolate a program section into an image section, specify the SOLITARY attribute of the program section using the PSECT_ATTR= option. For example, to isolate the GLOBAL_DATA program section in the sample link into its own image section, specify the following:
$ LINK/MAP/FULL MYTEST,MYADD,SYS$INPUT/OPT
CLUSTER=MYSUB_CLUS,,,MYSUB
PSECT_ATTR=GLOBAL_DATA,SOLITARY
Ctrl/Z

For Alpha linking, when mapping data into an existing location in the virtual memory of your program using the Create and Map Global Section ($CRMPSC) system service or the Map Global Section ($MGBLSC) system service,you must specify an address range (in the inadr argument) that is aligned on a CPU-specific page boundary. Because the linker aligns image sections on CPU-specific page boundaries and the program section in which the section is to be mapped is the only program section in the image section, you ensure that the start address of the location is page aligned. In addition,because Alpha systems must map at least an entire page of memory at a time, using the SOLITARY attribute allows you to ensure that no other data in the image section is inadvertently overwritten by the mapping. By default, the linker creates the next image section on the next page boundary so that no data can be overwritten.

7.4. Initializing an Image on Alpha/VAX Systems

After allocating memory for the image, the linker initializes the image by writing the binary contents of the image sections by processing text information and relocation (TIR) records in the object modules. These records direct the linker in the initialization of the image section by telling it what to store in the image section buffers. In addition, the linker inserts the addresses of symbols within the image wherever they are referenced.

7.4.1. Writing the Binary Contents of Image Sections

A TIR record contains object language commands, such as stack and store commands. Stack commands direct the linker to put information on its stack,and store commands direct the linker to write the information from its stack to the buffer for that image section.

During this image section initialization, the linker keeps track of the program section being initialized and the image section to which it has been allocated. The first attempt to initialize part of an image section by storing nonzero data causes the linker to allocate a buffer in its own program region to contain the binary contents of the generated image section. This allocation is achieved by the Expand Region ($EXPREG) system service, and it requires that the linker have available a virtually contiguous region of its own memory at least as large as the image section being initialized.

A buffer is not allocated for an image section until the linker executes a store command (with nonzero data) within that image section.

Debugger information (DBG) records and traceback information (TBT) records are processed only if the debugger was requested and traceback information was not excluded by the /NOTRACE qualifier in the LINK command. Otherwise, these records are ignored. The records contain stack and store object language commands (TIR records), but they are stored in the debugger symbol table (DST) instead of in an image section. (The linker expands its memory region to accommodate the DST, unless the /NOTRACEBACK qualifier was specified in the LINK command).

When the linker processes end-of-module (EOM) records, it checks that its internal stack has been collapsed to its initial state. When this processing is complete, the linker has written the binary contents of all image sections to image section buffers in its own address space.

The linker writes the contents of its buffers in the following order:
  1. All image sections to the image file.

  2. The debugger symbol table to the image file, unless /NOTRACEBACK was specified in the LINK command.

  3. The remaining sections of the map to the map file, if requested in the LINK command. (These sections include all requested sections except the Object Module Synopsis, which it already wrote, and the Link Run Statistics, which it cannot write until the linking operation finishes).

  4. The global symbol table to the image file, and also to another separate file, if requested in the LINK command.

  5. The image header to the image file.

  6. The link statistics to the map file, if requested in the LINK command.

7.4.2. Fixing Up Addresses

Executable images and based images are loaded into memory at a known location in P0 space. The linker cannot know where in memory a shareable image will be located when it is loaded into memory at run-time by the image activator. Thus, the linker cannot initialize references to symbols within the shareable image from external modules or to internal symbolic references within the shareable image itself. For shareable images, the linker creates fix-ups that the image activator must resolve when it activates the images at run-time.

The linker uses the fix-up image section in the following ways:
  • The fix-up image section adjusts the values stored by any .ADDRESS directives that are encountered during the creation of the non based shareable image. This action, together with subsequent adjustment of these values by the image activator,preserves the position independence of the shareable image.

    On Alpha systems, an error message informs you at link time that the linker is placing global symbols from shareable images in byte- or word-sized fields. The OpenVMS Alpha image header format does not allow byte or word fix-ups.

    Following is an example of the kind of error message the system displays:
    %LINK-E-NOFIXSYM, unable to perform WORD fixup for symbol TPU$_OPTIONS
            in psect $PLIT$ in module TEST_MODULE file USER:[ACCOUNT]TEST.OLB;1
    To work around the Alpha image header format restriction, move the symbolic value into a selected location at run-time rather than at link time. For example, in MACRO, rather than performing .WORD TPU$_OPTIONS, use the following instruction:
    MOVW #TPU$_OPTIONS, dest
  • For VAX linking, the fix-up image section processes all general-address-mode code references to targets in position-independent shareable images. In this way, it creates the linkage between these code references and their targets, whose locations are not known until run-time.

7.4.3. Keeping the Size of Image Files Manageable

Because neither language processors nor the linker initialize data areas in a program with zeros, leaving this task to the operating system instead, some image sections might contain uninitialized pages. To keep the size of the image file as small as possible, the linker does not write pages of zeros to disk for these uninitialized pages unless you explicitly disable this function. The linker can search image sections that contain initialized data for groups of contiguous, uninitialized pages and creates demand-zero image sections out of these pages (called demand-zero compression). Demand-zero image sections reduce the size of the image file and enhance the performance of the program. At run-time, when a reference is made that initializes the section, the operating system initializes the allocated page of physical memory with zeros (hence the name demand-zero).

The Alpha compilers identify to the linker program sections that have not been initialized by setting the NOMOD attribute of the program section. The linker groups these uninitialized program sections into a demand-zero image section.

If two modules contribute to the same program section and one contribution has the NOMOD attribute set and the other does not, the linker performs a logical AND of the NOMOD bits so that the two contributions end up in the same (non-demand-zero) image section.

Note that the linker creates demand-zero image sections only for OpenVMS VAX executable images. On OpenVMS Alpha systems,the linker can create demand-zero image sections for both executable and shareable images. Program sections with the SHR and the NOMOD attributes set are not sorted into demand-zero image sections in shareable images.

7.4.3.1. Controlling Demand-Zero Image Section Creation

When performing demand-zero compression, by default the linker searches the pages of existing image sections looking for the default minimum of contiguous, uninitialized pages. You can specify a different minimum by using the DZRO_MIN= option. For more information about the effect of this option on image size and performance, see the description of the DZRO_MIN= option in Chapter 10.

You can control demand-zero compression by specifying the maximum number of image sections that the linker can create using the ISD_MAX= option.

Chapter 8. Creating Shareable Images (Alpha and VAX)

This chapter describes how to create shareable images on OpenVMS Alpha and OpenVMS VAX systems and how to declare universal symbols in shareable images.

For information on how to create shareable images on OpenVMS x86-64 and OpenVMS I64 systems, see Chapter 4.

8.1. Overview of Creating Shareable Images on Alpha/VAX Systems

To create a shareable image, specify the /SHAREABLE qualifier on the LINK command line. You can specify as input files in the link operation any of the types of input files accepted by the linker, as described in Chapter 1.

Note, however, to enable other modules to reference symbols in the shareable image, you must declare them as universal symbols. High- and mid-level languages do not provide semantics to declare universal symbols. You must declare universal symbols at link time using linker options. The linker lists all universal symbols in the global symbol table (GST) of the shareable image. The linker processes the GST of a shareable image specified as an input file in a link operation during symbol resolution. For more information about symbol resolution, see Chapter 6.

For Alpha linking, you declare universal symbols by listing the symbols in a SYMBOL_VECTOR= option statement in a linker options file. You do not need to create a transfer vector to create an upwardly compatible shareable image. The symbol vector can provide upward compatibility. For more information about this topic, see Section 8.3.

For VAX linking, you declare universal symbols by listing the symbols in a UNIVERSAL= option statement in a linker options file. You can create shareable images that can be modified, recompiled, and relinked without causing the images that were linked against previous versions of the shareable image to be relinked. To provide this upward compatibility, you must create a transfer vector that contains an entry for each universal symbol in the image. For more information about these topics, see Section 8.2.

The linker supports qualifiers and options that control various aspects of shareable image creation. Table 8.1 lists these qualifiers and options. For more information about linker qualifiers and options, see Chapter 10.
Table 8.1. Linker Qualifiers and Options Used to Create Shareable Images

Qualifier

Description

/GST?

For Alpha images, directs the linker to include universal symbols in the global symbol table (GST) of the shareable image, which is the default. When you specify the /NOGST qualifier, the linker creates an empty GST for the image. See Section 8.3.4 for more information about using this qualifier to create run-time kits. Not supported for VAX images.

/PROTECT

Directs the linker to protect the shareable image from write access by user or supervisor mode.

/SHAREABLE

Directs the linker to create a shareable image, when specified in the link command line. When appended to a file specification in a linker options file, this qualifier identifies the input file as a shareable image.


Option

Description

GSMATCH=

Sets the major and minor identification numbers in the header of the shareable image and specifies the algorithm the linker uses when comparing identification numbers.

PROTECT=

When specified with the YES keyword in a linker options file, this option directs the linker to protect the clusters created by subsequent options specified in the options file. You turn off protection by specifying the PROTECT=NO option in the options file.

SYMBOL_TABLE=?

For Alpha linking, when specified with the GLOBALS keyword, this option directs the linker to include in a symbol table file all the global symbols defined in the shareable image, in addition to the universal symbols. By default, the linker includes only universal symbols in a symbol table file associated with a shareable image (SYMBOL_TABLE=UNIVERSALS). Not supported for VAX linking.

SYMBOL_VECTOR=?

For Alpha linking, specifies symbols in the shareable image that you want declared as universal. Not supported for VAX linking.

UNIVERSAL=?

For VAX linking, specifies symbols in the shareable image that you want declared as universal. Not supported for Alpha linking.

8.2. Declaring Universal Symbols in VAX Shareable Images

For VAX linking, you declare universal symbols by specifying the UNIVERSAL=option in an options file. List the symbol or symbols you want to be universal as an argument to the option. The symbols listed in a UNIVERSAL= option can represent procedures, relocatable data, or constants. For each symbol declared as universal, the linker creates an entry in the global symbol table (GST) of the image. At link time, when the linker performs symbol resolution, it processes the symbols listed in the GSTs of the shareable images included in the link operation.

To illustrate how to declare universal symbols, consider the programs in the following examples.
Example 8.1. Shareable Image Test Module: my_main.c
#include <stdio.h>
extern int my_data;
globalref int my_symbol;
int mysub();
main()
{
int num1, num2, result;
num1 = 5;
num2 = 6;
result = mysub( num1, num2 );
printf("Result= %d\n", result);
printf("Data implemented as overlaid psect= %d\n", my_data);
printf("Global reference data is= %d\n", my_symbol);
}

Example 8.2. Shareable Image: my_math.c
int my_data = 5;
globaldef int my_symbol = 10;
myadd(value_1, value_2)
int value_1;
int value_2;
{
int result;
result = value_1 + value_2;
return( result );
}
mysub(value_1,value_2)
int value_1;
int value_2;
{
int result;
result = value_1 - value_2;
return( result );
}
mydiv( value_1, value_2 )
int value_1;
int value_2;
{
int result;
result = value_1 / value_2;
return( result );
}
mymul( value_1, value_2 )
int value_1;
int value_2;
{
int result;
result = value_1 * value_2;
return( result );
}
To implement Example 8.2 as a shareable image, you must declare the universal symbols in the image by using the following LINK command:
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
PSECT_ATTR=my_data,NOSHR
UNIVERSAL=myadd
UNIVERSAL=mysub
UNIVERSAL=mymul
UNIVERSAL=mydiv
UNIVERSAL=my_symbol
Ctrl/Z

Note that the symbol my_data in Example 8.2 does not have to be declared universal because of the way in which VAX C implements it. Several programming languages, including VAX C and Fortran for OpenVMS VAX, implement certain external variables as program sections with the overlaid (OVR), global (GBL), and relocatable (REL) attributes. When the linker processes these object modules, it overlays the program sections so that the various object modules that reference the variable access the same virtual memory. Symbols implemented in this way are declared universal (appear in the GST of the image) by default.

In the sample link operation, the SHR attribute of the program section that implements the data symbol my_data is reset to NOSHR. If you do not reset the shareable attribute for program sections that are writable,you must install the shareable image to run the program. (The shareable attribute [SHR] determines whether multiple processes have shared access to the memory).

The following example illustrates how to link the object module MY_MAIN.OBJ with the shareable image MY_MATH.EXE. Note that the LINK command sets the shareability attribute of the program section my_data to NOSHR, as in the link operation in which the shareable was created.
$ LINK MY_MAIN, SYS$INPUT/OPT
MY_MATH/SHAREABLE
PSECT_ATTR=my_data,NOSHR
Ctrl/Z

8.2.1. Creating Upwardly Compatible Shareable Images (VAX Only)

For VAX linking, you can create a shareable image that can be modified, recompiled, and relinked without causing the images that were linked against previous versions of the image to be relinked. To provide this upward compatibility, you must ensure that the values of relocatable universal symbols within the image remain constant with each relinking.

Universal Symbols that Represent Procedures

To fix the locations of universal symbols that represent procedures in shareable image, create a transfer vector for the shareable image. In a transfer vector, you create small routines in VAX MACRO that define an entry point in the image and then transfer control to another location in memory. You declare the entry points defined in the transfer vector as the universal symbols and have each routine transfer control to the actual location of the procedures within the shareable image. As long as you ensure that the location of the transfer vector remains the same with each relinking, images that linked with previous versions of the shareable image will access the procedures at the locations they expect.

Figure 8.1 illustrates the flow of control at run-time between a main image and a shareable image in which the actual routines are declared as universal symbols (as shown in Section 8.2) and between a main image and a shareable image in which the transfer vector entry points are declared as universal symbols (as shown in Section 8.2.1.1).

Figure 8.1. Comparison of UNIVERSAL= Option and Transfer Vectors
Comparison of UNIVERSAL= Option and Transfer Vectors

Universal Symbols that Represent Data

To provide upwardly compatible symbols that represent data locations, you must also fix these locations within memory. You can accomplish this by allocating the data symbols at the end of the transfer vector file. In this way, when you fix the location of the transfer vector within an image, the data locations also remain the same.

8.2.1.1. Creating a Transfer Vector (VAX Only)

You create a transfer vector using VAX MACRO. Specify the .TRANSFER directive because it declares the symbol that you specify as its argument as a universal symbol by default. VSI recommends the following coding conventions for creating a transfer vector:
1.transfer    FOO       ;Begin transfer vector to FOO
2.mask        FOO       ;Store register save mask
3jmp          L^FOO+2   ;Jump to routine

1

The .TRANSFER directive causes the symbol, named FOO in the example, to be added to the shareable image's global symbol table. (You do not need to also specify the symbol in a UNIVERSAL= statement in a linker options file).

2

The .MASK directive causes the assembler to allocate 2 bytes of memory, find the register save mask accompanying the entry point (FOO in the example), and store the register save mask of the procedure. (According to the OpenVMS calling standard, procedure calls using the CALLS or CALLG instructions include a word, called the register save mask, whose bits represent which registers must be preserved by the routine).

3

The JMP instruction transfers control to the address specified as its argument. In the example, this address is two bytes past the routine entry point FOO (the first two bytes of the routine are the register save mask).

It is recommended to use a jump instruction (for example, JMP L^) in the transfer vector. Transferring control with a BSBW or JSB instruction results in saving the address of the next instruction from the transfer vector on the stack. In addition, the displacement used by the BSBW instruction must be expressible in 16 bits, which may not be sufficient to reach the target routine. Also, to avoid making the image position dependent, do not use an absolute mode instruction.

Note that the preceding convention assumes that the routine is called using the procedure call format, the default for most high-level language compilers. If a routine is called as a subroutine, using the JSB instruction, you do not need to include the .MASK directive. When creating a transfer vector for a subroutine call, VSI recommends adding bytes of padding to the transfer vectors. This padding makes a subroutine transfer vector the same size as a transfer vector for a procedure call. If you need to replace a subroutine transfer vector with a procedure call transfer vector, you can make the replacement without disturbing the addresses of all the succeeding transfer vectors.

The following example illustrates a subroutine transfer vector that uses the .BLKB directive to allocate the padding:
.TRANSFER FOO ;Begin transfer vector to FOO
JMP L^FOO ;Jump to routine
.BLKB 2 ;Pad vector to 8 bytes
To ensure upward compatibility, follow these guidelines when creating a transfer vector:
  • Preserve the order and placement of entries in a transfer vector. Once you establish the order in which entries appear in a transfer vector, do not change it. Images that were linked against the shareable image depend on the location of the symbol in the transfer vector.

    You can reserve space within a transfer vector for future growth by specifying dummy transfer vector entries at various positions in a transfer vector.

  • Add new entries to the end of a transfer vector. When including universal data in a transfer vector file, use padding to leave adequate room for future growth between the end of the transfer vector and the beginning of the list of universal data declarations.

A transfer vector for the program in Example 8.2 is illustrated in Example 8.3.
Example 8.3. Transfer Vector for the Shareable Image MY_MATH.EXE
.transfer myadd
.mask myadd
jmp l^myadd+2
.transfer mysub
.mask mysub
jmp l^mysub+2
.transfer mymul
.mask mymul
jmp l^mymul+2
.transfer mydiv
.mask mydiv
jmp l^mydiv+2
.end
Assemble the transfer vector file to create an object module that can be included in a link operation:
$ MACRO MY_MATH_TRANS_VEC.MAR 

8.2.1.2. Fixing the Location of the Transfer Vector in Your Image (VAX Only)

For VAX linking, you include a transfer vector in a link operation as you would any other object module. However, to ensure upward compatibility,you must make sure that the transfer vector always appears in the same location in the image. The best way to accomplish this is to make the transfer vector always appear at the beginning of the image by forcing the linker to process it first. If you put the transfer vector file in a named cluster, using the CLUSTER=option, and specify it as the first option in an options file that can generate a cluster, the transfer vector will appear at the beginning of the file. For more information about controlling cluster creation, see Section 6.3.

The following example illustrates how to include the transfer vector in the link operation, using the CLUSTER= option, so that the linker processes it first:
$ LINK/SHAREABLE   MY_MATH, SYS$INPUT/OPT
1 GSMATCH=lequal,1,1000
2 CLUSTER=trans_vec_clus,,,MY_MATH_TRANS_VEC.OBJ
Ctrl/Z

1

To enable images that linked against a shareable image to run with various versions of the shareable image, you must specify the identification numbers of the image. By default, the linker assigns a unique identification number to each version of a shareable image. At run-time, if the ID of the shareable image as it is listed in the executable image does not match the ID of the shareable image the image activator finds to activate, the activation will abort. For information about using the GSMATCH= option to specify ID numbers, see the description of the GSMATCH= option Chapter 10.

2

This CLUSTER= option causes the linker to create the named cluster TRANS_VEC_CLUS and to put the transfer vector file in this cluster.

8.2.2. Creating Based Shareable Images (VAX Linking Only)

For VAX linking, you can create a based shareable image by specifying the BASE= option in a linker options file. In a based image, you specify the starting address at which you want the linker to begin allocating memory for the image. For more information about the BASE= option, see Chapter 10.

VSI does not recommend using based shareable images.

Based shareable Alpha images are not supported.

8.3. Declaring Universal Symbols in Alpha Shareable Images

For Alpha linking, you declare universal symbols by listing them in a SYMBOL_VECTOR= option. For each symbol listed in the SYMBOL_VECTOR= option,the linker creates an entry in the shareable image's symbol vector and creates an entry for the symbol in the shareable image's global symbol table (GST). When the shareable image is included in a subsequent link operation, the linker processes the symbols listed in its GST.

To implement Example 8.2 as an Alpha shareable image, you must declare the universal symbols in the image by using the following LINK command:
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
GSMATCH=lequal,1,1000
SYMBOL_VECTOR=(myadd=PROCEDURE,-
mysub=PROCEDURE,-
mymul=PROCEDURE,-
mydiv=PROCEDURE,-
my_symbol=DATA,-
my_data=PSECT)
Ctrl/Z

You must identify the type of symbol vector entry you want to create by specifying a keyword. The linker allows you to create symbol vector entries for procedures, data (relocatable or constant), and for global data implemented as an overlaid program section.

A symbol vector entry is a pair of quadwords that contains information about the symbol. The contents of these quadwords depends on what the symbol represents. If the symbol represents a procedure, the symbol vector entry contains the address of the procedure entry point and the address of the procedure descriptor. If the symbol represents a data location, the symbol vector entry contains the address of the data location. If the symbol represents a data constant, the symbol vector entry contains the actual value of the constant.

When you create the shareable image (by linking it specifying the /SHARE qualifier), the value of a universal symbol listed in the GST is the offset of its entry into the symbol vector (expressed as the offset z in Figure 8.2).

When you include this shareable image in a subsequent link operation, the linker puts this value in the linkage pair in the linkage section of the executable image that references the symbol. A linkage pair is a data structure defined by the VSI OpenVMS Calling Standard.

At run-time, when the image activator loads the shareable image into memory, it calculates the actual locations of the routines and relocatable data within the image and stores these values in the symbol vector. The image activator then fixes up the references to these symbols in the executable image that references symbols in the shareable image, moving the values from the symbol vector in the shareable image into the linkage section in the executable image. When the executable image makes the call to the procedure, shown as the Jump-to-Subroutine (JSR) instruction sequence in Figure 8.2, control is transferred directly to the location of the procedure within the shareable image.

Figure 8.2. Accessing Universal Symbols Specified Using the SYMBOL_VECTOR=Option
Accessing Universal Symbols Specified Using the SYMBOL_VECTOR=Option

Note that, unlike VAX linking, global symbols implemented as overlaid program sections are not universal by default. Instead, you control which of these symbols is a universal symbol by including it in the SYMBOL_VECTOR=option, specifying the PSECT keyword. The example declares the program section my_data as a universal symbol.

You must specify the qualifier /EXTERN_MODEL=COMMON on the compile command line to make the VSI C for OpenVMS Alpha compiler implement the symbol as an overlaid program section. If you do not specify the COMMON keyword, the default keyword is RELAXED_REFDEF.

8.3.1. Symbol Definitions Point to Shareable Image Psects (Alpha Only)

On Alpha systems, the linker cannot overlay program sections that are referenced by symbol definitions with shareable image program sections of the same name. The C compiler generates symbol definition records that contain the index of an overlaid program section when the relaxed ref-def extern model is used (the default).

Shareable image program sections are created when you link a shareable image and use the PSECT keyword in your SYMBOL_VECTOR option.

If the linker detects this condition, it issues the following error:
%LINK-E-SHRSYMFND, shareable image psect <name> was pointed to
by a symbol definition
%LINK-E-NOIMGFIL, image file not created

The link continues, but no image is created. To work around this restriction, change the symbol vector keyword to DATA, or recompile your C program with the qualifier /EXTERN=COMMON.

For more information, see the VSI C for OpenVMS Alpha documentation.

The name of a symbol implemented as an overlaid program section can duplicate the name of a symbol representing a procedure or data location. If the program section specified in a SYMBOL_VECTOR= option does not exist, the linker issues a warning, places zeros in the symbol vector entry, and does not create an entry for the program section in the image's GST.

8.3.2. Creating Upwardly Compatible Shareable Images (Alpha Only)

The SYMBOL_VECTOR= option allows you to create upwardly compatible shareable images without requiring you to create transfer vectors as for VAX images.

However, as with transfer vectors, to ensure upward compatibility when using a SYMBOL_VECTOR= option, you must preserve the order and placement of the entries in the symbol vector with each relinking. Do not delete existing entries. Add new entries only at the end of the list. If you use multiple SYMBOL_VECTOR= option statements in a single options file to declare the universal symbols, you must also maintain the order of the SYMBOL_VECTOR= option statements in the options file. If you specify SYMBOL_VECTOR= options in separate options files, make sure the linker always processes the options files in the same order. (The linker creates only one symbol vector for an image).

Note, however, that there is no need to anchor the symbol vector at a particular location in memory, as you would anchor a transfer vector for a VAX link. The value at link time of a universal symbol in an Alpha shareable image is its location in the symbol vector, expressed as an offset from the base of the symbol vector, and the location of the symbol vector is stored in the image header. (For VAX linking, the value of a universal symbol at link time is the location of the symbol in the image, expressed as an offset from the base of the image). Thus, the relative position of the symbol vector within the image does not affect upward compatibility.

8.3.3. Deleting Universal Symbols Without Disturbing Upward Compatibility (Alpha Only)

To delete a universal symbol without disturbing the upward compatibility of an image, use the PRIVATE_PROCEDURE or PRIVATE_DATA keywords. In the following example, the symbol mysub is deleted using the PRIVATE_PROCEDURE keyword:
$ LINK/SHAREABLE MY_MATH, SYS$INPUT/OPT
GSMATCH=lequal,1,1000
SYMBOL_VECTOR=(myadd=PROCEDURE,-
mysub=PRIVATE_PROCEDURE,-
mymul=PROCEDURE,-
mydiv=PROCEDURE,-
my_symbol=DATA,-
my_data=PSECT)
Ctrl/Z

When you specify the PRIVATE_PROCEDURE or PRIVATE_DATA keyword in the SYMBOL_VECTOR= option, the linker creates symbol vector entries for the symbols but does not create an entry for the symbol in the GST of the image. The symbol still exists in the symbol vector and none of the other symbol vector entries have been disturbed. Images that were linked with previous versions of the shareable image that reference the symbol will still work, but the symbol will not be available for new images to link against.

Using the PRIVATE_PROCEDURE keyword, you can replace an entry for an obsolete procedure with a private entry for a procedure that returns a message that explains the status of the procedure.

8.3.4. Creating Run-Time Kits (Alpha Only)

If you use shareable images in your application, you may want to ship a run-time kit with versions of these shareable images that cannot be used in link operations.

To do this, you must first link your application, declaring the universal symbols in the shareable images using the SYMBOL_VECTOR= option so that references to these symbols can be resolved. After the application is linked,you must then relink the shareable images so that they have fully populated symbol vectors but empty global symbol tables (GSTs). The fully populated symbol vectors allow your application to continue to use the shareable image sat run-time. The empty GSTs prevent other images from linking against your application.

To create this type of shareable image for a run-time kit (without having to disturb the SYMBOL_VECTOR= option statements in your application's options files), relink the shareable image after development is completed, specifying the /NOGST qualifier on the LINK command line. When you specify the /NOGST qualifier, the linker builds a complete symbol vector, containing the symbols you declared universal in the SYMBOL_VECTOR= option, but does not create entries for the symbols that you declared universal in the GST of the shareable image. For more information about the /GST qualifier, see Chapter 10.

8.3.5. Specifying an Alias Name for a Universal Symbol (Alpha Only)

For Alpha linking, a universal symbol can have a name, called a universal alias, different from the name contributed by the object module in which it is defined. You specify the universal alias name when you declare the global symbol as a universal symbol using the SYMBOL_VECTOR= option. The universal alias name precedes the internal name of the global symbol, separated by a slash (/). In the following example, the global symbol mysub is declared as a universal symbol under the name sub_alias.
LINK/SHAREABLE MY_SHARE/SYS$INPUT/OPT
SYMBOL_VECTOR=(myadd=procedure,-
               sub_alias/mysub=procedure,-
               mymul=procedure,-
               mydiv=procedure,-
               my_symbol=DATA,-
               my_data=PSECT)
Ctrl/Z

You can specify universal alias names for symbols that represent procedures or data; you cannot declare a universal alias name for a symbol implemented as an overlaid program section. In link operations in which the shareable image is included, the calling modules must refer to the universal symbol by its universal alias name to enable the linker to resolve the symbolic reference.

In a privileged shareable image, calls from within the image that use the alias name result in a fix-up and subsequent vectoring through the privileged library vector (PLV), which results in a mode change. Calls from within the shareable image that use the internal name are done in the caller's mode. (Calls from external images always result in a fix-up). For more information about creating a PLV, see the VSI OpenVMS Programming Concepts Manual, Volume I.

8.3.6. Improving the Performance of Installed Shareable Images (Alpha Only)

For Alpha linking, you can improve the performance of an installed shareable image by installing it as a resident image (by using the /RESIDENT qualifier of the Install utility). INSTALL moves the executable, read-only pages of resident images into system space where they reside on huge pages. Executing your image in huge pages improves performance.

Chapter 9. Interpreting an Image Map File (Alpha and VAX)

This chapter describes how to interpret the information returned in an image map on OpenVMS Alpha and OpenVMS VAX systems and describes the combinations of linker qualifiers used to obtain a map.

For information about interpreting an image map file on OpenVMS x86-64 and OpenVMS I64 systems, see Chapter 5.

9.1. Overview of Alpha/VAX Linker Map

At your request, the linker can generate information that describes the contents of the image and the linking process itself. This information, called an image map, can be helpful when locating link-time errors, studying the layout of the image in virtual memory, and keeping track of global symbols.

You can obtain the following types of information about an image from its image map:
  • The names of all modules included in the link operation, both explicitly in the LINK command and implicitly from libraries

  • The names, sizes, and other information about the image sections that comprise the image

  • The names, sizes, and locations of program sections within an image

  • The names and values of all the global symbols referenced in the image,including the name of the module in which the symbol is defined and the names of the modules in which the symbol is referenced

  • Statistical summary information about the image and the link operation itself

You determine which information the linker includes in a map file by specifying qualifiers in the LINK command line. If you specify the /MAP qualifier, the map file includes certain information by default (called the default map). You can also request a map file that contains less information about the image (called a brief map) or a map file that contains more information about the image (called a full map). Table 9.1 lists the LINK command qualifiers that affect map file production.
Table 9.1. LINK Command Map File Qualifiers

/MAP

Directs the linker to create a map file. This is the default for batch jobs. /NOMAP is the default for interactive link operations.

/BRIEF

When used in combination with the /MAP qualifier, directs the linker to create a map file that contains only a subset of all the possible information.

/FULL

When used in combination with the /MAP qualifier, directs the linker to create a map file that contains all the possible information.

/CROSS_REFERENCE

When used in combination with the /MAP qualifier, directs the linker to replace the Symbols By Name section with a Symbol Cross-Reference section, in which all the symbols in each module are listed with the modules in which they are called. You cannot request this type of listing in a brief map file.

9.2. Components of an Image Map File (Alpha/VAX)

The linker formats the information it includes in a map file into sections. Table 9.2 lists the sections of a map file in the order in which they appear in the file. The table also indicates whether the section appears in a brief map, full map, or default map file.
Table 9.2. Image Map Sections

Section Name

Description

Default Map

Full Map

Brief Map

Object Module Synopsis?

Lists all the object modules in the image.

Yes

Yes

Yes

Module Relocatable Reference Synopsis?

Specifies the number of .ADDRESS directives in each module.

Yes

Image Section Synopsis

Lists all the image sections and clusters created by the linker.

Yes

Program Section Synopsis?

Lists the program sections and their attributes.

Yes

Yes

Symbols By Name?

Lists global symbol names and values.

Yes

Yes

Symbol Cross-Reference?

Lists each symbol name, its value, the name of the module that defined it, and the names of the modules that refer to it. Replaces the Symbols By Name section when the /CROSS_REFERENCE qualifier is specified.

Yes

Yes

Symbols By Value

Lists all the symbols with their values (in hexadecimal representation).

Yes

Image Synopsis

Presents statistics and other information about the output image.

Yes

Yes

Yes

Link Run Statistics

Presents statistics about the link run that created the image.

Yes

Yes

Yes

The following sections describe each of the image map sections in detail. The examples of the map sections are taken from the map file created in a link operation of the executable image in Chapter 8.

9.2.1. Object Module Synopsis (Alpha/VAX)

The first section that appears in a map file is the Object Module Synopsis. This section lists the name of each module included in the link operation in the order in which it was processed. Note that shareable images included in the link operation are listed here as well. This section of the map file also includes other information about each module, arranged in columns, as in the following example:
                                        +------------------------+
                                        ! Object Module Synopsis !
                                        +------------------------+

Module Name 1  Ident 2   Bytes 3 File 4                           Creation Date 5   Creator 6
-----------     -----     -----    -----                             -------------     -------
MY_MATH         V1.0      0        WORK:[PROGS]MY_MATH.EXE;11        3-NOV-2000 12:27  Linker T10-37
MY_MAIN         V1.0      553      WORK:[PROGS]MY_MAIN.OBJ;15        3-NOV-2000 12:27  C X1.1-048E
DECC$SHR        V1.0      0        [SYSLIB]DECC$SHR.EXE;2            9-JUL-2000 07:49  Linker T10-03
SYS$PUBLIC_VECTORS
                X-26      0        [SYSLIB]SYS$PUBLIC_VECTORS.EXE;2  9-JUL-2000 07:34  Linker T10-03

1

Module Name. The name of each object module included in the link operation. The modules are listed in the order in which the linker processed them. If the linker encounters an error during its processing of an object module, an error message appears on the line directly following the line containing the name of that object module.

2

Ident. The text string in the IDENT field in an object module or in the image header of a shareable image.

3

Bytes. The number of bytes the object module contributes to the image. Because shareable images are activated at run-time, the linker cannot calculate the size of their contributions to the image. Thus, the value 0 (zero) is associated with shareable images.

4

File. Full file specification of the input file, including device and directory. If the specification is longer than 35 characters, it is shortened by dropping the device portion of the file specification or both the device and directory portions of the file specification.

5

Creation Date. The date and time the file was created.

6

Creator. Identification of the language processor or other utility that created the file.

The order in which the modules are listed in this section reflects the order in which the linker processes the input files specified in the link operation. Note that the order of processing can be different from the order in which the files were specified in the command line. For more information about how the linker processes input files, see Chapter 6.

9.2.2. Module Relocatable Reference Synopsis (VAX Only)

For VAX linking, the information contained in the Module Relocatable Reference Synopsis section varies with the type of image being created. For shareable images, this section lists all of the modules that contain at least one .ADDRESS directive. For executable or system images, this section lists the names of all object modules containing at least one .ADDRESS reference to a shareable image. The section lists the modules in the order in which the linker processes them, including the number of .ADDRESS references found. The linker formats the information as in the following example:
                     +---------------------------------------+
                     ! Module Relocatable Reference Synopsis !
                     +---------------------------------------+

Module Name 1     Number 2 Module Name       Number   Module Name           Number
-----------        ------   -----------       ------   -----------           ------

MAIN1                       1                                                                                           

1

Module Name. The name of each object module included in the link operation. The modules are listed in the order in which the linker processed them.

2

Number. The number of .ADDRESS references found.

Note that you can reduce linker and image activator processing time by removing .ADDRESS directives from input files.

9.2.3. Image Section Synopsis Section (Alpha/VAX)

The Image Section Synopsis section of the linker map file lists the image sections created by the linker. The image sections appear in the order in which the linker created them, which is the same order as the clusters in the linker's cluster list. (For more information about clusters, see Chapter 6). The section includes other information about these image sections, formatted in columns, as in the following example:

                                                      ++++++++++++++++++++++++++
                                                      ! Image Section Synopsis !
                                                      ++++++++++++++++++++++++++
     1         2      3        4         5       6              7                    8              9         10        11
  Cluster      Type    Pglts   Base Addr   Disk VBN   PFC    Protection and Paging    Global Sec. Name      Match     Majorid   Minorid
  -------      ----    -----   ---------   --------   ---    ---------------------    ----------------      -----     -------   -------

MY_MATH            2     1      00000000R      0         0   READ WRITE   COPY ON REF    MY_MATH_001        EQUAL      113      5598831
                   2     1      00010000R      0         0   READ WRITE   COPY ON REF    MY_MATH_002        EQUAL      113      5598831
                   3     1      00020000R      0         0   READ ONLY                   MY_MATH_003        EQUAL      113      5598831
                   4     1      00030000R      0         0   READ WRITE   COPY ON REF    MY_MATH_004        EQUAL      113      5598831
                   2     1      00040000R      0         0   READ WRITE   FIXUP VECTORS  MY_MATH_005        EQUAL      113      5598831

DEFAULT_CLUSTER    0     1      00010000       3         0   READ WRITE   NONSHAREABLE   ADDRESS DATA
                   0     1      00020000       4         0   READ ONLY 
                   0     1      00030000       5         0   READ WRITE   FIXUP VECTORS
                 253    20      7FFF0000       0         0   READ WRITE   DEMAND ZERO

DECC$SHR           2   132     00000000-R      0         0   READ WRITE   COPY ON REF    DECC$SHR_001       LESS/EQUAL   1      0
                   2     3     00020000-R      0         0   READ WRITE   COPY ON REF    DECC$SHR_002       LESS/EQUAL   1      0
                   3    11     00030000-R      0         0   READ ONLY                   DECC$SHR_003       LESS/EQUAL   1      0
                   3   965     00040000-R      0         0   READ ONLY                   DECC$SHR_004       LESS/EQUAL   1      0
                   4     7     000C0000-R      0         0   READ WRITE   COPY ON REF    DECC$SHR_005       LESS/EQUAL   1      0
                   4    71     000D0000-R      0         0   READ WRITE   COPY ON REF    DECC$SHR_006       LESS/EQUAL   1      0
                   4     1   P-000E0000-R      0         0   READ WRITE   COPY ON REF    DECC$SHR_007       LESS/EQUAL   1      0
                   2     9     000F0000-R      0         0   READ WRITE   FIXUP VECTORS  DECC$SHR_008       LESS/EQUAL   1      0

SYS$PUBLIC_VECTORS
                   2    15     00000000-R      0         0   READ ONLY                   SYS$PUBLIC_VECTO   EQUAL      113     14651409
                   1    24     00004000-R      0         0   READ WRITE   COPY ON REF    SYS$PUBLIC_VECTO   EQUAL      113     14651409
                   2     1     00008000-R      0         0   READ WRITE   FIXUP VECTORS  SYS$PUBLIC_VECTO   EQUAL      113     14651409

          Key for special characters above:
                      +++++++++++++++++++++
                      ! R   Relocatable   !
                      ! P   Protected     !
                      +++++++++++++++++++++

1

The name of each cluster the linker created, listed in the order in which the linker created them.

2

The type of image section, expressed as one of the following codes:

Code

Image Section Type

1

Shareable fixed image section

2

Private fixed image section

3

Shareable position-independent image section

4

Private position-independent image section

253

Stack image section

For more information about the types of image sections the linker creates, see Section 7.3.5.

3

The length of each image section, expressed in pages or pagelets.

4

The base address assigned to the image section. Note that if the cluster is relocatable, the image activator relocates the base address. In this case, the base address entry for each image section in the cluster MY_MATH has the letter R appended to it, indicating that the base address entry is an offset to be added to the cluster base address assigned by the image activator.

For Alpha linking, when images are installed as resident images, the Install utility moves image sections containing code into system space. This invalidates the base addresses listed for these image sections in this section of the map file. Note, however, that the relative positions of the program sections within the image section, listed in the Program Section Synopsis section of the map file, remain valid when the image section is moved into system space.

5

The virtual block number of the image file on disk where the image section begins. The number 0 indicates that the image section is not in the image file.

6

Page fault cluster, the number of pagelets read into memory by the operating system when the initial page fault occurs for that image section. The number 0 indicates that the system parameter PFCDEFAULT determines this value, rather than the linker.

7

A keyword phrase that characterizes the settings of certain attributes of the image section, such as the attributes that affect protection and paging. The following table lists the keywords used by the linker to indicate these characteristics of an image section:

Keyword

Meaning

COPY ON REF

Indicates that the image section is a copy-on-reference image section. Because a copy-on-reference image section is readable and writable, but not shareable, each process receives a copy of it.

DEMAND ZERO

Indicates that the image section is a demand-zero image section. For more information, see Section 7.4.3.

EXECUTABLE

Indicates that the image section contains code.

FIXUP VECTORS

Indicates that the image section contains the fix-up section. There is always a change-protection fix-up for the fix-up section, so that when the image activator is done, the image activator changes the protection of the image section to READ ONLY.

NON-SHAREABLE ADDRESS DATA

Indicates that the linker set a READONLY page in the image section to WRITE so that the image activator can fix up address references (.ADDRESS) in the image section. The linker creates a change-protection fix-up for these image sections that causes the image activator to set the attributes of the image section back to READ ONLY when it finishes processing the address references.

READ ONLY

Indicates that the image section is protected against write access.

READ WRITE

Indicates that the image section allows both read and write access.

The linker may use more than one keyword to describe an image section. For example, to describe an image section that contains code, the linker uses the READ ONLY and EXECUTABLE keywords.

Note that a program section that you may have protected from write access (by setting the NOWRT program section attribute) may appear in the map file as writable (with the READ WRITE keyword). If this program section also has the NON-SHAREABLE ADDRESS DATA keyword (as the first image section in DEFAULT_CLUSTER illustrates), the linker has enabled write access to the program section to allow the image activator to fix up address references in the image section at run-time. The image activator resets the program section attributes to READ ONLY after it is finished.

8

Global Section Name, the name assigned by the linker to each image section comprising a shareable image. The linker creates the names by appending the characters _00x after the file name, where x is an integer, starting with 1, and incremented for each image section in a shareable image.

9

The algorithm the image activator uses when comparing identification numbers in a shareable image, expressed by the keyword LESS/EQUAL, EQUAL, or ALWAYS. For more information about this topic, see the description of the GSMATCH= option in Chapter 10.

10

An identification number assigned to the image. The linker assigns the number to the image if it is not specified as part of the link operation in the GSMATCH= option.

11

An identification number assigned to the image. The linker assigns the number to the image if it is not specified as part of the link operation in the GSMATCH= option.

9.2.4. Program Section Synopsis Section (Alpha/VAX)

The Program Section Synopsis section lists the program sections that comprise the image, with information about the size of the program section, its starting- and ending-addresses, and its attributes. The Module Name column in this section lists the modules that contribute to each program section. The following example illustrates this format:

Psect Name1    Module Name2     Base3   End4         Length5          Align6                 Attributes7
----------      -----------       ----     ---           ------            -----                   ----------

$LINK$                          00010000 000100BF 000000C0 (        192.) OCTA  4 NOPIC,CON,REL,LCL,NOSHR,NOEXE,NOWRT,NOVEC,  MOD
                MY_MAIN         00010000 000100BF 000000C0 (        192.) OCTA  4
MY_DATA                         00010010 00010013 00000004 (          4.) OCTA  4 NOPIC,OVR,REL,GBL,NOSHR,NOEXE,  WRT,NOVEC,  MOD
                MY_MATH         00010010 00010010 00000000 (          0.) OCTA  4
                MY_MAIN         00010010 00010013 00000004 (          4.) OCTA  4

$LITERAL$                       000100C0 00010108 00000049 (         73.) OCTA  4   PIC,CON,REL,LCL,  SHR,NOEXE,NOWRT,NOVEC,  MOD
                MY_MAIN         000100C0 00010108 00000049 (         73.) OCTA  4
$READONLY$                      00010110 00010110 00000000 (          0.) OCTA  4 NOPIC,CON,REL,LCL,NOSHR,NOEXE,NOWRT,NOVEC,  MOD
                MY_MAIN         00010110 00010110 00000000 (          0.) OCTA  4
$RSS$                           00020000 00020000 00000000 (          0.) OCTA  4 NOPIC,CON,REL,LCL,NOSHR,NOEXE,  WRT,NOVEC,  MOD
                MY_MAIN         00020000 00020000 00000000 (          0.) OCTA  4
$DATA$                          00020000 00020000 00000000 (          0.) OCTA  4 NOPIC,CON,REL,LCL,NOSHR,NOEXE,  WRT,NOVEC,  MOD
                MY_MAIN         00020000 00020000 00000000 (          0.) OCTA  4
$CODE$                          00020000 0002011B 0000011C (        284.) OCTA  4   PIC,CON,REL,LCL,  SHR,  EXE,  WRT,NOVEC,  MOD
                MY_MAIN         00020000 0002011B 0000011C (        284.) OCTA  4

1

The name of each program section in the image in ascending order of its base virtual address.

2

The names of the modules that contribute to the program section whose name appears on the line directly above in the Psect Name column. If a shareable image appears in this column, the linker processed the program section as a shareable image reference.

3

The starting virtual address of the program section or of a module that contributes to a program section.

4

The ending virtual address of the program section or of a module that contributes to a program section.

5

The total length of the program section or of a module that contributes to a program section.

6

The type of alignment used for the entire program section or for an individual program section contribution. The alignment is expressed in two ways. In the first column, the alignment is expressed using a predefined keyword, such as OCTA. In the second column, the alignment is expressed as an integer that is the power of 2 that creates the alignment. For example, octaword alignment would be expressed as the keyword OCTA and as the integer 4 (because 24 = 16).

If the linker does not support a keyword to express an alignment, it puts the text "2 **" in the column in which the keyword usually appears. When read with the integer in the second column, it expresses these alignments, such as 2 ** 5.

7

The attributes associated with the program section. For a list of all the possible attributes, see Chapter 7.

For Alpha linking, the linker includes the MOD attribute in the list of program section attributes (as illustrated in the example). To make room in the display for this attribute, the linker leaves out the Readability (RD/NORD) and User Library (USR/LIB) attributes, which are reserved for future use.

For VAX linking, the list of attributes includes the Readability (RD/NORD) and User Library (USR/LIB) attributes. The Modified (MOD/NOMOD) attribute, which is not supported for VAX images, is not included.

Note that, if a routine is extracted from the default system library to resolve a symbolic reference, the Program Section Synopsis section in a full map contains information about the program sections comprising that routine. The Program Section Synopsis section in a default map does not.

9.2.5. Symbols By Name Section (Alpha/VAX)

The Symbols By Name section lists the global symbols contained in all the modules included in the link operation. The section includes the value of the symbol, in the following format:
                                             +-----------------+
                                             ! Symbols By Name !
                                             +-----------------+

Symbol 1      Value 2  Symbol      Value         Symbol       Value       Symbol   Value
------         -----    ------      -----         ------       -----       ------   -----
DECC$EXIT       00001FD0-RX
DECC$GPRINTF    00001710-RX
DECC$MAIN       000007D0-RX
MAIN            00010000-R
MYSUB           00000010-RX
MY_SYMBOL       00000050-RX
SYS$IMGSTA      00000340-RX
__MAIN          00010078-R

1

Symbol. The names of the image's global symbols in alphabetical order.

2

Value. The value of the symbol, expressed in hexadecimal. The linker appends characters to the end of the symbol value to describe other characteristics of the symbol. For an explanation of these symbols, see Section 9.2.7.

Note that this section is replaced by the Symbol Cross-Reference section when you specify the /CROSS_REFERENCE qualifier in the LINK command. The Symbols by Value section, described in Section 9.2.7, lists the same symbols by value.

9.2.6. Symbol Cross-Reference Section (Alpha/VAX)

The Symbol Cross-Reference Section, which is produced in place of the Symbols By Name section when you specify the /CROSS_REFERENCE qualifier, lists all of the symbols referenced in the image, along with the module in which they are defined and with all the modules that reference them. The section formats this information as in the following example:
                                        +------------------------+
                                        ! Symbol Cross Reference !
                                        +------------------------+

Symbol 1       Value 2        Defined By 3     Referenced By ... 4
------          -----           ----------        -----------------
DECC$EXIT    00001FD0-RX       DECC$SHR                 MY_MAIN
DECC$GPRINTF 00001710-RX       DECC$SHR                 MY_MAIN
DECC$MAIN    000007D0-RX       DECC$SHR                 MY_MAIN
MAIN         00010000-R        MY_MAIN
MYSUB        00000010-RX       MY_MATH                  MY_MAIN
MY_SYMBOL    00000050-RX       MY_MATH                  MY_MAIN
SYS$IMGSTA   00000340-RX       SYS$PUBLIC_VECTORS
__MAIN       00010078-R        MY_MAIN

1

Symbol. The name of the global symbol.

2

Value. The value of the global symbol, expressed in hexadecimal. The linker appends characters to the end of the symbol value to describe other characteristics of the symbol. For an explanation of these symbols, see Section 9.2.7.

3

Defined By. The name of the module in which the symbol is defined. For example, the symbol mysub is defined in the module named MY_MATH.

4

Referenced By.... The name or names of all the modules that contain at least one reference to the symbol.

9.2.7. Symbols By Value Section (Alpha/VAX)

The Symbols By Value section lists all the global symbols in the image

The Symbols By Value section lists all the global symbols in the image in order by value, in ascending numeric order. The linker formats the information into columns, as in the following example:
                                           +------------------+
                                           ! Symbols By Value !
                                           +------------------+

Value  1                Symbols...2
-----                   ----------
00000010     RX-MYSUB
00000050     RX-MY_SYMBOL
00000340     RX-SYS$IMGSTA
000007D0     RX-DECC$MAIN
00001710     RX-DECC$GPRINTF
00001FD0     RX-DECC$EXIT
00010000      R-MAIN
00010078      R-__MAIN

1

Value. The value of each global symbol, expressed in hexadecimal, in ascending numerical order.

2

Symbols... The names of the global symbols. If more than one symbol has the same value, the linker lists them on more than one line. The characters prefixed to the symbol names indicate other characteristics of the symbol, such as its scope. Table 9.3 lists these codes.
Table 9.3. Symbol Characterization Codes (Alpha/VAX)

Code

Meaning

asterisk(*)

Symbol is undefined.

A?

Symbol is the alias name for a universal symbol.

I?

Symbol is the internal name of a symbol that has a universal alias name.

U

Symbol is a universal symbol.

R

Symbol is a relocatable symbol.

X

Symbol is an external symbol.

WK

Symbol is a weak symbol. (For more information, see Chapter 6).

9.2.8. Image Synopsis Section (Alpha/VAX)

The Image Synopsis section contains miscellaneous information about the image, such as its name and identification numbers, and a summary of various attributes of the image, such as the number of files used to build the image. The following example illustrates the format of this section of a map file. The list following the example provides more information about items in this section that are not self-explanatory.
                                              +----------------+
                                              ! Image Synopsis !
                                              +----------------+

Virtual memory allocated:1          00010000 0003FFFF 00030000 (196608. bytes, 384. pages)
Stack size:                                       20. pages
Image header virtual block limits:                 1.        2. (    2. blocks)
Image binary virtual block limits:                 3.        5. (    3. blocks)
Image name and identification:              MY_MAIN V1.0
Number of files:                                   7.
Number of modules:                                 4.
Number of program sections:                       11.
Number of global symbols:                        944.
Number of cross references:                       13.
Number of image sections:                         20.
User transfer address:                      00010078
Debugger transfer address:                  00000340
Number of code references to shareable images:     6.
Image type:                                 EXECUTABLE.
Map format:                                 FULL WITH CROSS REFERENCE in file WORK:[PROGS]MY_MAIN.MAP;15
Estimated map length:                       148. blocks

1

Virtual memory allocated. This line contains the following information:
  • The starting-address of the image (base-address)

  • The ending-address of the image

  • The total size of the image, expressed in bytes, in hexadecimal radix

The numbers in parentheses at the end of the line indicate the total size of the image, expressed in bytes and in pagelets. Both these values are expressed in decimal.

9.2.9. Link Run Statistics Section (Alpha/VAX)

The Link Run Statistics section contains miscellaneous statistical information about the link operation, such as performance indicators, formatted as in the following example:
                                          +---------------------+
                                          ! Link Run Statistics !
                                          +---------------------+

Performance Indicators                        Page Faults   CPU Time        Elapsed Time
----------------------                        -----------   --------        ------------
    Command processing:                                93   00:00:00.18     00:00:00.81
    Pass 1:                                           345   00:00:00.55     00:00:12.04
    Allocation/Relocation:                              9   00:00:00.04     00:00:00.30
    Pass 2:                                            29   00:00:00.14     00:00:00.62
    Map data after object module synopsis:              3   00:00:00.05     00:00:00.31
    Symbol table output:                                0   00:00:00.00     00:00:00.10
Total run values:                                     479   00:00:00.96     00:00:14.18

Using a working set limited to 2048 pages and 946 pages of data storage (excluding image)

Total number object records read (both passes):   167
    of which 0 were in libraries and 0 were DEBUG data records containing 0 bytes

Number of modules extracted explicitly             = 0
    with 0 extracted to resolve undefined symbols

5 library searches were for symbols not in the library searched

A total of 0 global symbol table records was written

LINK/MAP/FULL/CROSS MY_MAIN,SYS$INPUT/OPT
my_math/share

Glossary

This glossary defines key terms for the OpenVMS Linker. The OpenVMS Linker is part of the OpenVMS operating system which is available on x86-64, Integrity, Alpha, and VAX hardware platforms. Certain terminology commonly used by the linker on OpenVMS Alpha and OpenVMS VAX systems might be different on OpenVMS x86-64 and OpenVMS I64 systems.

based cluster

An Alpha and VAX term. A cluster located at a base address using the CLUSTER= option.

brief map

Information produced by the linker when the /BRIEF qualifier is specified with the /MAP qualifier. A brief map contains only a subset of the default map.

See Also image map.

default map

Information produced by the linker when the /MAP qualifier is specified without the /BRIEF and /FULL qualifiers.

See Also image map.

demangler

A compiler tool that translates mangled names back to their source-name equivalents. Recent compilers are able to include demangling information when they generate their object modules.

See Also mangled names.

ELF

See Executable and Linkable Format (ELF).

Executable and Linkable Format (ELF)

The object and image format as described in System V Application Binary Interface. The ELF format is extensible; that is, it can contain hardware and software extensions.

For I64 systems, a hardware extension is used as described in the Intel Itanium Processor-specific Application Binary Interface.

For x86-64 systems, a hardware extension is used as described in the System V Application Binary Interface, AMD64 Architecture Processor Supplement.

In the OpenVMS x86-64 and I64 extensions, ELF is the object and image file format for object and image binaries. Compilers, assemblers, and other language processors whose output is used by the OpenVMS Linker utility must produce object files that conform to the OpenVMS extensions of the ELF specification.

executable image

The primary type of image created from a link operation. This image can be executed from the DCL command line.

See Also shareable image.

fix-up

Executable and shareable images can have references to shareable images. At link time, when symbols are resolved, the address values are not known. They become visible when the image activator maps the shareable image. At that time, the image activator "fixes up" the references with the address values.

full map

Information produced by the linker when the /FULL qualifier is specified with the /MAP qualifier. To tailor the full information, you can use keywords to add or suppress specific information.

See Also image map.

function descriptor

An I64 term. As defined in the VSI OpenVMS Calling Standard, a function descriptor is the pairing of a code address and a global pointer. With this information, a call to the function (or procedure) can be made, and the called function can access its data by way of the global pointer.

hard definition

A symbol with compiler-supplied storage that is not in an overlaid section.

header table

An ELF term. The ELF format describes portions of the object and image modules, as well as their attributes, using section and segment headers. These headers are contained in two arrays of headers called the Section Header Table (for section headers) and the Program Header Table (for program segment headers). Only one header, the main ELF header, is not listed in either of these tables. It is located at the beginning of the module.

See Also Executable and Linkable Format (ELF).

image file

A file containing binary code and data of a program for an OpenVMS system; essentially, an image of what is in memory when the program is started. Also called an image.

image header

An Alpha and VAX term. The part of an executable or shareable image that describes the contents of the image file (the image sections). It is located at the beginning of the file.

image initialization

The part of the link operation where the linker, after it resolves references and obtains memory requirements, initializes the image by filling it with the compiled binary code and data.

image map

Information generated by the linker that describes the contents of the image and the linking process. The image map helps you determine programming and link-time errors, study the layout of the image in virtual memory, and keep track of global symbols. You control the information generated by the map by accepting the default map, or by specifying either a brief or full map.

See Also default map, brief map, full map.

image optimization

An I64 and Alpha term. Actions the linker takes to improve run-time performance of an image it creates. For example, for OpenVMS I64 images, the linker can optimize data references to the short data segment.

image relocations

Address suggested by the linker that image activator uses to relocate the image.

See Also relocations.

linkage pair

An Alpha term. A compiler-generated small data structure to implement a call. A linkage pair consists of the required information to make a call: the code address and the procedure descriptor address of a procedure. The linkage pair is defined in the VSI OpenVMS Calling Standard.

local function descriptor

An I64 term. As defined in the VSI OpenVMS Calling Standard, a function descriptor is the pairing of a code address and a global pointer. With this information, a call to the function (or procedure) can be made and the called function can access its data by way of the global pointer. The calling standard requires a local function descriptor for each call to another image. Local function descriptors are set up by the linker. Although for each call a different local function descriptor can be used, the linker sets up and re-uses one local function descriptor per target function. The linker creates a fix-up for each local function descriptor.

See Also fix-up, official function descriptor.

mangled names

The process where some compilers create abbreviated symbol names to implement language features or to use shortened, unique names. For example, C++ compilers mangle symbol names to guarantee unique names for overloaded functions.

See Also demangler.

object file

A file produced from a source language by a language processor (compiler, assembler, etc.) that contains one or more object modules that serves as input to the linker.

See Also image file.

official function descriptor

An I64 term. As defined in the VSI OpenVMS Calling Standard, a function descriptor is the pairing of a code address and a global pointer. With this information, a call to the function (or procedure)can be made and the called function can access its data via the global pointer. The linker sets up an official function descriptor to implement calls to the function (or procedure). As such,an official function descriptor is an entry point. An entry is unique: there can be only one official function descriptor per function (or procedure).

See Also local function descriptor.

OpenVMS system

A system running the VSI OpenVMS operating system. These include OpenVMS x86-64, I64, Alpha, and VAX operating systems.

See Also system.

OpenVMS Alpha system

An HPE Alpha system running the OpenVMS Alpha operating system. Also referred to as Alpha system or Alpha.

OpenVMS I64 system

An HPE Integrity server running the OpenVMS I64 operating system. Also referred to as I64 system or I64.

OpenVMS VAX system

An HPE VAX system running the OpenVMS VAX operating system. Also referred to as VAX system or VAX.

OpenVMS x86-64 system

A server running the OpenVMS x86-64 operating environment. Also referred to as x86-64 system or x86-64.

OpenVMS 64-bit system

An OpenVMS Alpha, OpenVMS I64, or OpenVMS x86-64.

platform

A generic term referring to all systems of a specific processor architecture. For example, Intel Itanium.

See Also system.

privileged shareable image

A shareable image containing privileged code. For example, user-written system services allow user-mode programs to call routines that can perform functions that require privileges. These services are implemented in shareable images. Because of the presence of privileged code, they are referred to as privileged shareable images.

See Also protected shareable image.

program section

An area of memory that has a name, a length, and other attributes describing the intended or permitted usage of that portion of memory. Program sections are part of an object module. At link time, the user can set or change some of the attributes so the linker combines them in a manner that the user controls.

program segment

An x86-64 and I64 term. A chunk of the image binary, usually data or code. In general, everything that needs to be available to activate and run the image.

See Also image header.

protected shareable image

A shareable image created with the /PROTECT qualifier. Privileged shareable images must be protected from user-mode and supervisor-mode write access.

See Also privileged shareable image.

psect

See program section.

relaxed definition

See tentative definition.

relocations

The linker combines object binaries (code and data) from different object modules. The language processors do not know where their modules will be located in virtual address space. Therefore, the language processors generate information packets for the linker, called relocations, so that code execution and data references will work from any linker-chosen memory location. The linker applies these relocations to data. Because the image activator can place an image at any memory location, the linker produces relocations, called "image relocations", to assist the image activator. Code is always position independent, that is, it requires no relocations.

shareable image

A collection of data and program services that is a product of a link operation and is not directly executed from the DCL command line. To make use of a shareable image, it must first be included as input in a link operation that produces an executable image.

See Also executable image.

symbol resolution

The process of resolving references to symbols whose definitions are external to the module.

system

The computer hardware; the server. Distinguish from the operating system (for example, OpenVMS Alpha).

See Also platform.

system image

An Alpha and VAX term. A product of a link operation producing an image that can be run as a standalone program, without operating system support. Therefore, these images typically do not contain image activation information. On OpenVMS x86-64 and I64 systems, images always contain image activation information. As a result, the x86-64 and I64 linkers do not create system images.

See Also executable image.

tentative definition

A symbol definition without compiler supplied storage or storage in overlaid sections. There can be tentative definitions for a symbol in several modules. If no hard definition for the symbol is encountered, one of the tentative definitions for that symbol is selected by the linker to be the defining instance.

See Also hard definition.

1

Alpha and VAX specific

2

64-bit specific

1

All ELF sections are relative (REL). There is only a conceptual absolute section: the reserved section number SHDR$K_SHN_ABS. Absolute symbols are defined by that mechanism.

2

x86-64 specific

3

I64 specific

4

This is an ELF section type (prefixed with SHDR$K_), mapped to an OpenVMS section attribute.

5

SHT_NOBITS/NOMOD is only set by compilers; it reflects uninitialized data.

1

I64 specific

1

Not an attribute, implemented in the dynamic segment

2

Zero PHDR$Q_P_FILESZ and nonzero PHDR$Q_P_MEMSZ

3

Not used on x86-64 and I64

4

Reserved to OpenVMS

1

Demand zero is no attribute, it is expressed as a file size of zero for a segment with nonzero memory size. If the /NODEMAND_ZERO qualifier is specified, the file size is equal to the memory size of the segment.

2

An asterisk (*) means any section attribute.

1

Demand zero is no attribute, it is expressed as a file size of zero for a segment with nonzero memory size. If the /NODEMAND_ZERO qualifier is specified, the file size is equal to the memory size of the segment.

2

An asterisk (*) means any section attribute.

1

I64 specific

1

These dynamic segment flags are prefixed with DYNSEG$SC_VMS_LF_ as a main entry point by the corresponding language processor.

1

These dynamic segment flags are prefixed with DYNSEG$SC_VMS_LF_.

1

It is recommended to protect the whole image with the /PROTECT qualifier, see Section 4.4.

2

The only purpose of a symbol table file is to make symbols and their values known to the System Dump Analyzer (SDA). The option is intended for system developers who use SDA to look at a running system, a process, or crash dump.

1

In a full map file, these sections include information about modules that were included in the link operation from libraries but were not explicitly specified on the LINK command line.

1

x86-64 specific

2

I64 specific

1

VAX specific

1

VAX specific

1

Alpha specific

1

For Alpha images, these attributes are prefixed with EGPS$V_. For VAX images, these attributes are prefixed with GPS$V_.

2

For Alpha images, these attributes are prefixed with EISD$V_. For VAX images, these attributes are prefixed with ISD$V_.

3

Alpha specific

4

For Alpha images, these attributes are prefixed with EGPS$V_. For VAX images, these attributes are prefixed with GPS$V_.

5

If the /NODEMAND_ZERO qualifier is specified, the copy-on-reference (CRF) attribute is set instead of the DZRO attribute.

2

For Alpha images, these attributes are prefixed with EISD$V_. For VAX images, these attributes are prefixed with ISD$V_.

3

Alpha specific

4

If the /NODEMAND_ZERO qualifier is specified, the copy-on-reference (CRF) attribute is set instead of the DZRO attribute.

1

Alpha specific

2

VAX specific

1

In a full map file, these sections include information about modules that were included in the link operation from libraries but were not explicitly specified on the LINK command line.

2

VAX specific

1

Alpha specific

1

On x86-64 and I64 systems, the qualifier is accepted by the linker but has no effect.

2

Keywords are only supported on x86-64 systems.

1

x86-64 and I64 specific. On Alpha systems, the traceback info is in the DSF file; for a RUN, the traceback handler is enabled but it cannot print the line information, because it is not in the image.

1

x86-64 and I64 specific

1

You can specify an alias name for this type of symbol vector entry.

2

Although not a symbol, the name of an exported program section is part of the GST, which implements the public interface of the shareable image.