Introduction
When Microsoft’s compiler in
Visual Studio builds with link-time
code generation (/GL), it doesn’t write machine code. The
.obj file holds the compiler’s own intermediate language, and the linker
generates the code later. A short anonymous header identifies what the data is, and the
data after it is private to Microsoft’s tools.
Structure
The header is called ANON_OBJECT_HEADER in winnt.h. Version 1 is 32 bytes; version 2 and later add three fields, 44 bytes in all.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 2 | Sig1 | 0: IMAGE_FILE_MACHINE_UNKNOWN |
| 2 | 2 | Sig2 | 0xFFFF |
| 4 | 2 | Version | The version, 1 or more |
| 6 | 2 | Machine | The processor, as in the COFF machine values |
| 8 | 4 | TimeDateStamp | When the file was made |
| 12 | 16 | ClassID | A class identifier for the data that follows |
| 28 | 4 | SizeOfData | The size of the data after the header |
| 32 | 4 | Flags | Version 2 and later: bit 0 set means metadata is present |
| 36 | 4 | MetaDataSize | Version 2 and later: the size of the metadata |
| 40 | 4 | MetaDataOffset | Version 2 and later: where the metadata starts |
A file with the same first four bytes, version 2 or more and the class identifier
D1BAA1C7-BAEE-4BA9-AF20-FAF66AA4DCB8 is a
bigobj, and one with version 0 is a
short import object.
Also used for
- Wavefront OBJ – A plain text mesh of vertices, normals and faces, read by almost every 3D program.
Variants
- OMF object file – Intel’s object format for 16-bit DOS and Windows compilers, in typed records
- COFF object file – compiled code from Windows compilers, waiting for the linker
- COFF object file (bigobj) – the extended form of COFF, for objects with very many sections
- Anonymous object header – the wrapper Microsoft’s compiler writes for link-time code generation
Links
Software
- Visual Studio – Microsoft’s development environment, whose compiler writes these with
/GLand whose linker reads them (Windows)
Reference
- /GL – Microsoft’s documentation of whole program optimisation