An OMF object module is a run of records, read in order from the start. Each record has the same outer shape, which lets a reader skip what it doesn’t understand. A module begins with THEADR or LHEADR and ends with MODEND.
The record
+0Type1 byte+1Length, little-endian: the bytes after this field, including the checksum2 bytes+3Contents, laid out by typeLength − 1 bytes…Checksum: makes the record’s bytes add up to 0 modulo 256, or 0 if not computed1 byte
A type with an odd number is the 32-bit form of the type one below it: fields that hold offsets and lengths are 4 bytes instead of 2. Records are limited to 1,024 bytes unless a record type says otherwise.
Field encodings
| Field | Encoding |
|---|---|
| Name | A count byte, then that many characters. A count of 0 is an empty name. |
| Index | One byte for values 0 to 127. Otherwise two bytes, high byte first, the top bit of the first set: (first & 0x7F) << 8 | second. Indexes count from 1; 0 means none. |
| Offset or length | 2 bytes in a record with an even type, 4 bytes in the odd form, little-endian. |
Record types
| Type | Name | Meaning |
|---|---|---|
0x6E–0x7E | RHEADR, REGINT, REDATA, RIDATA, OVLDEF, ENDREC, BLKDEF, BLKEND, DEBSYM | Old Intel records, not written by later tools |
0x80 | THEADR | The module name |
0x82 | LHEADR | The name of a library module |
0x84, 0x86 | PEDATA, PIDATA | Old forms of data, not used |
0x88 | COMENT | A comment |
0x8A, 0x8B | MODEND | The end of a module; see below |
0x8C | EXTDEF | External names needed |
0x8E | TYPDEF | Type definitions, obsolete |
0x90, 0x91 | PUBDEF | Public names defined |
0x92 | LOCSYM | Local symbols, obsolete |
0x94, 0x95 | LINNUM | Line numbers |
0x96 | LNAMES | Names for segments, groups and classes |
0x98, 0x99 | SEGDEF | A segment |
0x9A | GRPDEF | A group of segments |
0x9C, 0x9D | FIXUPP | Fixups and threads |
0xA0, 0xA1 | LEDATA | Bytes for a segment |
0xA2, 0xA3 | LIDATA | Bytes for a segment, as repeating blocks |
0xA4–0xAA | LIBHED, LIBNAM, LIBLOC, LIBDIC | Intel library records, not used by Microsoft’s tools |
0xB0 | COMDEF | Communal names |
0xB2, 0xB3 | BAKPAT | Back-patches |
0xB4, 0xB6, 0xB7, 0xB8 | LEXTDEF, LPUBDEF, LCOMDEF | Names local to the module |
0xBA, 0xBB | COMFIX | Obsolete; Microsoft’s linker reports an error |
0xBC | CEXTDEF | COMDAT external names |
0xC0 | SELDEF | Obsolete; Microsoft’s linker reports an error |
0xC2, 0xC3 | COMDAT | A block the linker may keep one copy of |
0xC4, 0xC5 | LINSYM | Line numbers for a COMDAT |
0xC6 | ALIAS | Aliases |
0xC8, 0xC9 | NBKPAT | Back-patches to a named COMDAT |
0xCA | LLNAMES | Local names |
0xCC | VERNUM | The OMF version, as text |
0xCE | VENDEXT | A vendor number and private data |
0xF0, 0xF1 | Library header and end | Only in an OMF library |
MODEND
| Field | Meaning |
|---|---|
| Module type (1 byte) | Bit 7: this is the main module of a program. Bit 6: a start address follows. Bit 0: the start address needs relocating. |
| End data (if bit 6 is set) | The same bytes as in a fixup: a Fixdat byte, a frame datum and target datum when the method needs them, and a target displacement. |