A COMENT record (0x88) carries notes and extensions. Tools ignore classes they don’t know, which made it the natural place to extend the format.
The record
+0Comment type: bit 7 NP (no purge), bit 6 NL (no list)1 byte+1Comment class1 byte+2Comment bytes, by classvaries
Comment type bits: NP (bit 7, no purge) is set if the comment is to be preserved by utility programs that manipulate object modules (it protects, for example, a copyright message from deletion); NL (bit 6, no list) is set if the comment is not to be displayed by utilities that list the contents (it can hide a comment). The remaining bits are unused and should be 0. The comment bytes are not prefixed with a count: their length comes from the record length. Any number of COMENT records may appear, almost anywhere: only a COMENT cannot lie between a FIXUPP record and the LEDATA or LIDATA record it refers to, and cannot be the first or last record of a module (the first is THEADR or LHEADR and the last MODEND). Microsoft LIB ignores the comment type. COMENT was the main way to extend OMF before VENDEXT was added for TIS; classes 9D, A0, A1, A2, A4, AA, B0 and B1 were added or changed for 32-bit linkers (the specification does not describe AA, B0 or B1). Classes 0xC0 to 0xFF not otherwise used are reserved for user-defined comment classes (VENDEXT replaces the need for new ones). The specification’s three examples: a translator comment (comment type 0, class 0, the text “Microsoft C”), a default library (class 9F, the name SLIBFP without extension) and a class A1 comment whose string (“CV7”) is ignored by Microsoft LINK and which asks it to write the most recent CodeView format.
Classes
| Class | Name | Holds |
|---|---|---|
0x00 | Translator | The name of the compiler or assembler, as text; recommended: the translator name and version and the optimisation level (other options are by practice in class 9D) |
0x01 | Intel copyright | Text. Microsoft uses class 1 for padding (Microsoft LINK ignores it; QuickC uses it for padding) |
0x02–0x9B | Intel reserved | Reserved for Intel products; values from 0x9C to 0xFF are ignored by Intel products. (0x9B is used by Open Watcom for processor and model information, from its pcobj.h.) |
0x81 | Library specifier | Obsolete; replaced by class 0x9F with identical contents |
0x9C | MS-DOS version | A 2-byte string giving the MS-DOS version number; obsolete, not supported by Microsoft LINK |
0x9D | Memory model | Generated by Microsoft C for the XENIX linker; ignored by the MS-DOS and OS/2 versions of Microsoft LINK. One to three ASCII characters: 0, 1, 2 or 3 for 8086, 80186, 80286 or 80386 instructions; O for optimisation performed; s, m, c, l or h for small, medium, compact, large or huge model; the digits 68000, 68010, 68020 or 68030 for 680x0 instructions |
0x9E | DOSSEG | The byte string is null. Sets Microsoft LINK’s DOSSEG switch (standard segment ordering by the MS-DOS and OS/2 naming conventions); included in the startup module of each language library |
0x9F | Default library | A library file name, with no count byte and no extension, that is searched to resolve external references of the module; the default library search can be overridden by LINK’s /NODEFAULTLIBRARYSEARCH switch |
0xA0 | OMF extensions | See below |
0xA1 | New OMF extension | Now used solely to indicate the version of the symbolic debug information (if absent, the linker defines it; Microsoft LINK defaults to the oldest format of the Microsoft symbol and type information). It was previously used to say that COMDEF records, not TYPDEF and EXTDEF pairs, represent communals; COMDEF records are now always enabled. The byte string is currently empty; planned contents are a version number (8-bit) followed by a style: CV (Microsoft symbol and type style), DX (AIX style), HL (IBM PM Debugger style). Open Watcom calls it “Microsoft’s brand of OMF flag”. |
0xA2 | Link pass separator | Conveys the organisation of the file. The first byte of the string is a subtype; one is defined: 01, the start of the records generated from pass 2 of the linker. More bytes may follow, by the record length, and are ignored. Assumed not to be present in a module whose MODEND carries a start address (with overlays the linker needs the start address in pass 1 to define $$MAIN). The specification notes it may become obsolete with COMDAT. |
0xA3 | LIBMOD | A library module’s name; see below |
0xA4 | EXESTR | Arbitrary text, see below |
0xA6 | INCERR | An incremental compile error; no fields, see below |
0xA7 | NOPAD | SEGDEF indexes of segments not to pad, see below |
0xA8 | WKEXT | Pairs of external indexes: a weak name and its default; see below |
0xA9 | LZEXT | Pairs of external indexes: a lazy name and its default; see below |
0xAA | Easy OMF-386 | Open Watcom’s pcobj.h: “Easy OMF signature record”, with the signature 80386; not described in the TIS specification (which lists AA among the classes changed for 32-bit linkers without describing it). The meaning of the signature, that this module has 32-bit fields even in records with even types, comes from the Phar Lap Easy OMF format and is not confirmed in a source read here |
0xDA | Comment | A random comment |
0xDB | Compiler | From #pragma comment(compiler): the version number |
0xDC | Date | From #pragma comment(date stamp) |
0xDD | Timestamp | From #pragma comment(timestamp) |
0xDF | User | From #pragma comment(user), sometimes used for copyright notices |
0xE9 | Dependency file | Borland: the include files used to build the object file (a source file’s date, time and name) |
0xFD | Disassembler directive | Open Watcom’s pcobj.h: a directive to disassemblers; no layout read |
0xFE | Linker directive | Open Watcom’s pcobj.h: a linker directive; the layout (a letter and its data) is from an earlier note, not re-verified |
0xFF | Command line | Microsoft QuickC: shows the compiler options chosen; may be obsolete; also used by Phoenix Technology Ltd. for library comments. (pcobj.h also names 0xFF “name of the source file”.) |
Other classes in real files, such as Borland’s debug classes, are not described here.
Class 0xA0: OMF extensions
The first byte after the class is a subtype:
| Subtype | Name | Holds |
|---|---|---|
| 1 | IMPDEF | An import: an ordinal flag byte, the internal name, the DLL’s name, and an ordinal word or an entry name |
| 2 | EXPDEF | An export: a flag byte, the exported name, the internal name, and an ordinal word if bit 7 of the flag byte is set |
| 3 | INCDEF | Incremental compile information |
| 4 | Protected memory library | 32-bit linkers only, relevant only to 32-bit DLLs: inserted by the compiler when it meets the _loadds construct in the source of a DLL. The linker sets a flag in the executable’s header so that the loader, while doing run-time fixups, loads the selector of a protected memory area into DS (other DLLs and applications get the regular DGROUP selector) |
| 5 | LNKDIR | Microsoft C++ linker directives, see below |
| 6 | Big-endian | The target of this OMF is a big-endian machine (the most significant byte of a multibyte value has the smallest address) |
| 7 | PRECOMP | When the Microsoft symbol and type information of the object file is emitted, the directory entry for $$TYPES is to be emitted as sstPreComp instead of sstTypes |
| 8–0xFF | Reserved | Any unrecognised subtype (currently anything above 7) makes Microsoft LINK give a fatal error |
IMPDEF (subtype 1)
A Microsoft extension added for OS/2 and Windows; describes one imported name. Fields after the subtype byte: an ordinal flag byte (0: the import is identified by name; non-zero: by ordinal; it fixes the form of the last field); the internal name (count and characters; the name used inside this module, which occurs again in an EXTDEF record); the module name (count and characters; the DLL that supplies the matching export); the entry ident: when the flag is non-zero a 16-bit ordinal; when 0 a name, where a first byte of 0 means the exported name is the same as the internal name, and otherwise it is the imported name as exported by the module. IMPDEF records are created by an import library utility (such as IMPLIB) from a module definition file or DLL.
EXPDEF (subtype 2)
A Microsoft extension added for Microsoft C 5.1; describes one exported entry point. After the subtype: an export flag byte, the exported name (count and characters; the name to use when the entry point is imported by name), the internal name (count and characters; a length of 0 means it is the same as the exported name; otherwise the name by which the entry point is known inside the module, which appears as a PUBDEF or LPUBDEF name), and, only when the ordinal bit is set, a 16-bit export ordinal (non-zero). The flag byte: bit 7 ordinal bit (exported by ordinal; the ordinal field is present); bit 6 resident name (the system loader keeps the exported name resident, an optimisation for names imported by name often); bit 5 no data (the entry point uses no initialised data, instanced or global); bits 4 to 0 the parameter count, the number of parameter words, 0 for all but callgates to 16-bit segments. Compilers produce EXPDEF when _export is used.
INCDEF (subtype 3)
A Microsoft extension added for QuickC 2.0, for incremental compilation. After the subtype: an EXTDEF delta (signed 16 bits), a LINNUM delta (signed 16 bits) and padding (zeros, added by QuickC to allow the module to grow). Every FIXUPP and LINNUM record after an INCDEF adjusts all external index values and line number values by the delta; the deltas are cumulative when there is more than one INCDEF in a module, and negative deltas are allowed.
LNKDIR (subtype 5)
A Microsoft extension added for Microsoft C 7.0: directives and flags the compiler passes to the linker. After the subtype: a bit flags byte, a pseudocode version byte (the p-code interpreter version) and a CodeView version byte. Bit 0: output the new .EXE format (ignored except for linking p-code applications, which need a segmented executable); bit 1: do not output the $PUBLICS subsection of the CodeView information; bit 2: run the Microsoft Make Pseudocode Utility (MPC) over the object file to enable creating an executable; the other bits are 0. The presence of this record says the module has global symbols in a $SYMBOLS section, and the linker emits no $PUBLICS section for such modules.
Classes A3, A4, A6, A7, A8, A9
- LIBMOD (A3), added for LIB 3.07 in MASM 5.0: used only by the librarian, ignored by the linker (and by IBM LINK386). The record holds the module name (count and characters): the base name of the
.OBJthat was built into the library, with no path and no extension, so the librarian can keep the source file name in THEADR. Microsoft LIB adds one when an object is added to a library and strips it when removed, so it normally exists only in.LIBfiles, one for each module. - EXESTR (A4), added for Microsoft C 5.1, for
#pragma comment(exestr, …)and#ident: arbitrary text that the linker copies byte for byte to the end of the executable, not into the load image; with CodeView information present the text lies somewhere before the end so as not to disturb the CodeView signature. There is no limit on the number of EXESTR records. - INCERR (A6), added for QuickC 2.0: no fields. Makes the linker end with a fatal “invalid object” error, so a failed incremental compile is not linked by hand; the object module cannot be deleted because it is the base of the next incremental compilation.
- NOPAD (A7), added for COBOL (MicroFocus COBOL 1.2; permanent in LINK 5.11 for Microsoft COBOL 3.0): repeated SEGDEF indexes (1 or 2 bytes) of segments excluded from the padding of the
/PADDATAand/PADCODEoptions; ignored by IBM LINK386. - WKEXT (A8), added for Microsoft Basic 7.0 and first produced by a construct in MASM 6.0 (
EXTERN var(con): bytemakesconthe default resolution of the weak externvar): repeated pairs of 1- or 2-byte EXTDEF indexes, the weak extern and its default resolution. A weak extern becomes strong, like an EXTDEF, if a PUBDEF for it is linked in or an EXTDEF for it is found in another module (a library included), and must then be resolved by a matching PUBDEF; one that is still weak at the end of linking uses the default resolution. Two weak externs of the same symbol with different defaults draw a warning from many linkers. Weak externs do not query libraries: a library module that would be linked in only to satisfy a weak extern is not linked, but if it is linked for other reasons its PUBDEF resolves the symbol. - LZEXT (A9), added for Microsoft C 7.0 but not implemented in its linker: the same layout and rules as WKEXT, except that a lazy extern does query libraries; ignored by IBM LINK386.
Source: the TIS Portable Formats Specification 1.10, which says this OMF text is a Microsoft-LINK-oriented description; other linkers (IBM LINK386, Open Watcom) differ where noted.