Description: The purpose of the COMDAT record is to combine logical blocks of code and data which may be duplicated across a number of compiled modules.
   1 byte  2 bytes
  ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂ---
  ³  C3   ³ Record         ³
  ³       ³  Length        ³
  ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁ---

    1 byte 1 byte 1 byte   4 bytes    1 or 2  <cond>  <string> 1 byte  1 byte
 --ÂÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄ¿
   ³Flags ³ Attr.³Align ³ Enum Data  ³ Type  ³Public ³ Public ³ DAT   ³Chk.  ³
   ³      ³      ³      ³ Offset     ³  Index³ Base  ³  Name  ³       ³ Sum  ³
 --ÁÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÙ
                                                               <repeat>

COMDAT initialized communal data record
Flags

This field contains three defined bits:

01H - Continuation bit. If clear, then this COMDAT record establishes a new instance of the COMDAT variable, otherwise the data is a continuation of the previous COMDAT of the symbol.

02H - Iterated data bit. If clear, the Dat field contains enumerated data, otherwise the Dat field contains iterated data, as in an LIDATA record.

04H - Local COMDAT. The public name is local.
Attr

This field contains two 4-bit fields: the selection criteria to be used, the allocation type and the ordinal specifying the type of allocation to be performed. Values are:

Selection criteria (high-order 4 bits):

00H - No match - only one instance of this comdat allowed.

10H - Pick any - pick any instance of this COMDAT record.

20H - Same size - pick any, but instances must have the same length or linker will generate an error.

30H - Exact Match - pick any, but checksums of instances must match of linker will generate an error. Fixups are ignored.

40H - F0H - reserved.
Allocation Type (low-order 4 bits):

00H - Explicit - allocate in the segment specified in the ensuing public base field.

01H - Far Code - allocate as CODE16. The linker will create segments to contain all COMDAT's of this type.

02H - Far DATA - allocate as DATA16. The linker will create segments to contain all COMDAT's of this type.

03H - CODE32 - allocate as CODE32. The linker will create segments to contain all COMDAT's of this type.

04H - DATA32 - allocate as DATA32. The linker will create segments to contain all COMDAT's of this type.

05H - 0FH - Reserved.
Align

These codes are based on the ones used by the SEGDEF record:

0 - use value from SEGDEF.

1 - byte aligned.

2 - word (2 byte) aligned.

3 - paragraph (16 byte) aligned.

4 - 4K page aligned.

5 - dword (4 byte) aligned.

6 - not defined.

7 - not defined.
Enum Data Offset

This field specifies an offset relative to the beginning location of the symbol specified in the public name field and defines the relative location of the first byte of the DAT field. Successive data bytes in the DAT field occupy higher locations of memory. This works very much like the offset field in an LEDATA record, but instead of an offset relative to a segment, this is relative to the beginning of the COMDAT symbol.
Type Index

The type index field is encoded in index format; it contains either debug type information or an old-style TYPDEF index. If this index is zero, there is no associated type data. Old-style TYPDEF indices are ignored by the linker. Present linkers do no type checking.
Public Base

This field is conditional and is identical to the public base stored in the public base field in the PUBDEF record. This field is only present if the allocation type field specifies explicit allocation.
Public Name

This field is a regular length prefixed name.
Dat

The Dat field provides up to 1024 consecutive bytes of data. If there are fixups, they must be emitted in a FIXUPP record that follows the COMDAT record. The data can be either enumerated or iterated, depending on the flags field.
Notes:

While creating addressing frames, the linker will add the COMDAT data to the appropriate logical segments, adjusting their sizes. At that time the offset at which the data will go inside the logical segment will be calculated. Next, the linker will create physical segments from adjusted logical segments reporting any 64K boundary overflows.

If the allocation type is not explicit, COMDAT code and data is accumulated by the linker and broken up into segments, so that the total may exceed 64K.

In pass two, only the selected occurrence of COMDAT data will be stored in the VM, fixed up and later written into the .EXE file.


[Back: B0H COMDEF Communal Names Definition Record]
[Next: LX - Linear eXecutable Module Format Description]