Introduction
.obj is the extension for object files on DOS and Windows: the compiled
code of one source file, waiting for the linker to join it with others into a program or
library. Two formats have used it. Compilers and assemblers for 16-bit DOS and Windows
wrote Intel’s OMF format; 32-bit and 64-bit Windows compilers write COFF, the object
format that the Windows PE program format is
built on.
Unix-like systems use .o for the same job, in the
ELF or Mach-O
format. A .obj file can also be something else entirely: a 3D model in the
Wavefront OBJ format, which is plain text.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.OBJ | COFF object file | Compiled code from Windows compilers, waiting for the linker. | Open |
.OBJ | OMF object file | Intel’s object format for 16-bit DOS and Windows compilers, in typed records. | Open |
OMF object file
The Object Module Format, defined by Intel for the 8086 and used by most 16-bit DOS and Windows compilers and assemblers, such as Borland’s and early Microsoft tools. Some 32-bit compilers, such as Watcom’s, also used it. The file is a series of records, each with a type byte, a length and a checksum.
The file starts with a record type byte, almost always 0x80
(THEADR, the module name), followed by a 16-bit length and a short name string.
COFF object file
The Common Object File Format, written by Microsoft’s compiler in Visual Studio and by Clang and other compilers that target 32-bit and 64-bit Windows. It holds code and data in sections, with relocations and a symbol table.
The file has no signature. It starts with a 16-bit machine type, such as
4C 01 (0x14C, 32-bit x86) or 64 86
(0x8664, x64).
Also used for
- Wavefront OBJ .obj