HP OpenVMS Linker Utility Manual


Previous Contents Index

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


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:

When creating a shareable image, the linker considers all combinations of the following attributes when combining program sections into image sections:

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

Table 7-2 and Table 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 Settings1 Type of Isect Isect Attributes Set2
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 3


+Alpha specific
++For Alpha images, these attributes are prefixed with EGPS$V_. For VAX images, these attributes are prefixed with GPS$V_.
2For Alpha images, these attributes are prefixed with EISD$V_. For VAX images, these attributes are prefixed with ISD$V_.
3If the /NODEMAND_ZERO qualifier is specified, the copy-on-reference (CRF) attribute is set instead of the DZRO attribute.

Table 7-3 Mapping Program Section Attributes to Image Section Attributes for Shareable Images
Significant Psect Attribute Settings1 Type of Isect Isect Attributes Set2
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 3
               
+NOWRT +NOEXE +NOSHR +PIC +NOVEC +NOMOD PRVPIC DZRO
+WRT +NOEXE +NOSHR +PIC +NOVEC +NOMOD " WRT,DZRO 3, PIC
               
+NOWRT +NOEXE +SHR +PIC +NOVEC +NOMOD SHRPIC PIC
+WRT +NOEXE +SHR +PIC +NOVEC +NOMOD " WRT,PIC


+Alpha specific
1For Alpha images, these attributes are prefixed with EGPS$V_. For VAX images, these attributes are prefixed with GPS$V_.
2For Alpha images, these attributes are prefixed with EISD$V_. For VAX images, these attributes are prefixed with ISD$V_.
3If the /NODEMAND_ZERO qualifier is specified, the copy-on-reference (CRF) attribute is set instead of the DZRO attribute.

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.


Previous Next Contents Index