Introduction
OMF, the Object Module Format, is the object file format Intel defined for the 8086. Most compilers and assemblers for 16-bit DOS and Windows wrote it, including Borland’s Turbo C, Turbo Assembler and Borland C++, and Microsoft’s early C compilers and MASM. A DOS linker such as Microsoft LINK or Borland TLINK joined OMF files into an MZ or NE program. Some 32-bit compilers, such as Watcom C and Borland’s 32-bit tools, kept using it with 32-bit extensions.
Libraries of OMF object files also use the .lib extension, in a format
of their own that starts with a library header record. Modern Windows compilers write
COFF object files instead. See
all the .OBJ variations.
Structure
An OMF file is a sequence of records. Each starts with a one-byte record type and a 16-bit little-endian length, which counts the rest of the record including a final checksum byte. The checksum makes the sum of all the record’s bytes zero. Many record types come in pairs: the even number is the 16-bit form and the odd number the 32-bit form.
A module begins with a THEADR record (0x80) holding its name, usually
the source file name, and ends with a MODEND record (0x8A or
0x8B). Between them, LNAMES (0x96) lists names, SEGDEF
(0x98) and GRPDEF (0x9A) define segments and groups,
EXTDEF (0x8C) and PUBDEF (0x90) list the symbols the module
needs and provides, LEDATA (0xA0) and LIDATA (0xA2) carry
the code and data, and FIXUPP (0x9C) records say which addresses the
linker must fill in. COMENT records (0x88) carry compiler notes and
extensions.
+0record type, such as0x80THEADR1 byte+1record length, counting the contents and the checksum2 bytes+3contents, laid out by record typelength − 1 bytes…checksum1 byte
Also used for
- Wavefront OBJ .obj
Links
Software
- Open Watcom, whose compilers write OMF and whose
wlinkandwdislink and disassemble it (Windows, Linux, DOS, OS/2) - NASM, which writes OMF with
-f obj(Windows, macOS, Linux) - objconv, which converts OMF to and from COFF, ELF and Mach-O (Windows, macOS, Linux)
- IDA Pro (Windows, macOS, Linux)