Relocatable Object Module Format
|Developed by||Tool Interface Standards Committee|
|Type of format||Object file|
The Relocatable Object Module Format (OMF) is an object file format used primarily for software intended to run on Intel 80x86 microprocessors. Version 4.0 was released by Intel in 1981 under the name Object Module Format, and is perhaps best known to DOS users as an .OBJ file. It has since been standardized by the Tool Interface Standards Committee.
Many object file formats consist of a set of tables, such as the relocation table, which are either stored on fixed positions in the file, like the a.out format, or are pointed to by the header, like the ELF format. The "sections", code, data area, etc., are stored as contiguous areas of bytes within such files.
The Relocatable Object Module Format, however, was designed to require minimal memory when linking, and consists of a series of records that have the following format:
|1 byte||Record type, for example relocation information|
|2 bytes||Data length (N+1)|
|N bytes||Data (varies depending on the record type)|
|1 byte||Checksum or 0|
There is a wide variety of record types because of consolidation of OMF variants from several vendors, and because of adding such features as 32-bit code and dynamic linking. These are important record types:
- COMENT - (88h) Comment, which may also contain control information.
- EXTDEF - (8Ch) Defines external references
- PUBDEF - (90h/91h) Identifies external symbols in this module
- SEGDEF - (98h/99h) Identifies segments
- GRPDEF - (9Ah) Identifies groups of segments, for example MS-DOS
- FIXUPP - (9Ch/9Dh) Fixup or relocation records
- LEDATA - (A0h/A1h) Contains text of a code or data section
- COMDEF - (B0h) Uninitialized common data
- COMDAT - (C2h/C3h) Initialized common data
- MODEND - (8Ah/8Bh) Indicates end of module
There is no header containing file offsets, such as a pointer to a symbol table, in the file; a linker must completely parse the object file to extract all the information.
In the OMF format the data of one section is not necessarily stored as contiguous bytes in the file, instead it can be represented by multiple records. The file format specification (version 1.1) says that this must be done for sections larger than 1 KiB. Records containing relocation information (fixups) must be stored immediately following the data records of the section they apply to, so the section data and the relocation information is "mixed" in the file.
The file format provides special records (LIDATA) that allow compression of repeating data sequences in an object file. It also provides the possibility to store the symbol name of the entry point of the later executable file in one object file.
The file format can also be used as library file format.
Few toolchains use the 32-bit version of the OMF format. For example, the Watcom C toolchain allows generating code for targets that use 32-bit segmented memory layouts; Iron Spring PL/I can generate code for OS/2 32-bit flat memory layouts.
The Embarcadero Delphi compiler used this format when generating
obj files for C++. It was the only format of object files that could be linked to a program or unit written in Object Pascal prior to version XE2 of Delphi, which introduced support of COFF format, along with 64-bit Windows target.
- "8086 Relocatable Object Module Formats". Version 4.0. Intel. 1981. Product Number 121748-001. ark:/13960/t07w7pz4b. Retrieved 2020-02-08. (124 pages)
- "Tool Interface Standards (TIS) Relocatable Object Module Format (OMF) Specification" (PDF). Version 1.1. TIS Committee / UNIX International, Inc. May 1995 . Archived (PDF) from the original on 2020-02-07. Retrieved 2020-02-07. (87 pages)
- Levine, John R. (2000) [October 1999]. "Chapter 3: Object files". Linkers and Loaders. The Morgan Kaufmann Series in Software Engineering and Programming (1 ed.). San Francisco, USA: Morgan Kaufmann. ISBN 1-55860-496-0. OCLC 42413382. ISBN 978-1-55860-496-4. Archived from the original on 2012-12-05. Retrieved 2020-01-12. Code:  Errata: