Records of external names (EXTDEF, LEXTDEF, CEXTDEF, COMDEF and LCOMDEF) all add to one list, numbered from 1 in file order. Fixups name their targets by an index into this list.
EXTDEF and LEXTDEF (0x8C, 0xB4)
Repeated to the end of the record:
| Field | Meaning |
|---|---|
| Name | A name |
| Type index | An index of a TYPDEF, usually 0 |
LEXTDEF (B4, B5) has the same layout, for names visible only inside this module; there is no semantic difference between B4 and B5, and the record was added for Microsoft C 5.0. LEXTDEF and EXTDEF (and COMDEF and LCOMDEF) are ordered together by occurrence for the external name index used in FIXUPP subrecords.
Rules from the TIS OMF specification: the name may not be null, and many linkers (Microsoft LINK among them) restrict the name length to 1 to 0x7F; many linkers also limit a module to 1,023 external names. The Type Index is an index field that in old versions pointed at a TYPDEF record (obsolete; many linkers ignore TYPDEF) and now carries Microsoft symbol and type (CodeView) information: values 0 to 511 (0x1FF) are predefined primitive types, and values 512 to 32767 (0x200 to 0x7FFF) index the type definitions of the module’s $$TYPES segment, offset by 512. An EXTDEF must come before the FIXUPP records that reference it. A reference is resolved by a case-sensitive name match (and symbol type): the linker searches PUBDEF and COMDEF records; if it is linking a segmented executable, the imported names (IMPDEF); if it is linking a segmented executable that is not a DLL, an exported name (EXPDEF) of the same name (a self-imported alias); then the undefined symbols, where a weak external takes its default resolution and a strong one is an error. All external references must be resolved at link time. The Microsoft C compiler writes an EXTDEF for every referenced global function and every variable declared extern. Example: 8C 25 00 0A 5F 5F 61 63 72 74 75 73 65 64 00 … lists __acrtused, _main, _puts and __chkstk, each with type index 0.
CEXTDEF (0xBC)
External names for COMDAT blocks. Repeated to the end of the record: a logical name index into the LNAMES, and a type index.
PUBDEF and LPUBDEF (0x90, 0x91, 0xB6, 0xB7)
| Field | Meaning |
|---|---|
| Base group index | An index into the GRPDEFs, or 0 |
| Base segment index | An index into the SEGDEFs, or 0 |
| Base frame | Only when both indexes are 0: an absolute paragraph number, 2 bytes |
| Then repeated to the end of the record: | |
| Name | The symbol’s name |
| Offset | Where it is in the segment; 2 or 4 bytes |
| Type index | Usually 0 |
The base group and base segment are indexes of previously defined GRPDEF and SEGDEF records; the group index may be 0 (no group). The base frame field is present only when the base segment index is 0, and its contents are ignored; the segment index is normally non-zero and then no frame follows. According to the Intel 8086 specification, with both indexes 0 the frame field is a 16-bit paragraph, which can define absolute public symbols; absolute addressing is not fully supported by some linkers (Microsoft LINK can use it for read-only access to absolute locations, and writing may not work). The public name cannot be null and is at most 255 bytes. The offset is relative to the group, segment or frame, and 2 or 4 bytes; with a 90 record it is 16-bit encoded and zero-extended to 32 bits for a Use32 segment. The Type Index is as for EXTDEF; if it is 0 there is no type data. PUBDEF records must come after the GRPDEF and SEGDEF records they refer to, and since nothing refers to them they are usually near the end of the module. All defined functions and initialised globals generate them in most compilers (not instantiated inline functions in C++). The symbols are also available for export if an EXPDEF comment says so. LPUBDEF (B6, B7) is identical in form, for symbols not visible outside the module (local offset 32 bits in B7); Microsoft C writes it for static functions and initialised variables. Examples: 90 0C 00 00 01 05 47 41 4D 4D 41 02 00 00 F9 is GAMMA at offset 2 of the first segment, no group; 90 0E 00 00 00 00 00 05 41 4C 50 48 41 34 12 00 B1 is the absolute symbol ALPHA = 0x1234 in frame 0.
COMDEF and LCOMDEF (0xB0, 0xB8)
Communal symbols: uninitialised variables (or data that may match initialised static data in another module) that the linker merges, with the largest size winning (COMDEF was introduced by Microsoft LINK 3.5; the name may be null; NEAR and FAR communals of different modules are matched by name). The Type Index is parsed as an index and not inspected by current linkers. Communal variables cannot be resolved to dynamic links (imported symbols), and a public or exported symbol of the same name in another module gives “symbol defined more than once” in some linkers. Older linkers required a COMENT of class 0xA1 in a module with COMDEF; that is no longer required. LCOMDEF (B8) is identical in form, for names local to the module (Microsoft C writes it for uninitialised static variables). Repeated to the end of the record:
| Field | Meaning |
|---|---|
| Name | The symbol’s name |
| Type index | Usually 0 |
| Data type | 0x61 far (the length is a number of elements, then the element size in bytes), 0x62 near (the length is a number of bytes). The TIS specification defines only these two values. |
| Far: number of elements, then element size. Near: length | See Communal length |
Communal length
| First byte | Value |
|---|---|
0x00–0x80 | The value itself |
0x81 | The next 2 bytes, little-endian |
0x84 | The next 3 bytes, little-endian |
0x88 | The next 4 bytes, little-endian |
ALIAS (0xC6)
Repeated to the end of the record: an alias name and the name it stands for, both as names. Added for FORTRAN 5.1 (Microsoft LINK 5.13) for link-time aliasing: the linker substitutes all references to the alias symbol by the substitute symbol. The alias behaves like a PUBDEF in that it must be unique; a PUBDEF of the alias seen later overrides it; a second ALIAS with a different substitute draws a warning from most linkers and the second substitute is used. When satisfying an external reference, a matching alias stops the search for definitions of the alias symbol and the reference is satisfied with the substitute. All ALIAS records must appear before the Link Pass 2 record.
Weak externals
A weak external is declared in a COMENT record of class 0xA8, WKEXT: pairs of indexes into the external list, the first the weak name and the second the name to use if no other definition is found.