Introduction
Compilers and assemblers for 16-bit DOS and Windows kept their runtime libraries in
.lib files of this format: a collection of
OMF object modules, with a dictionary that lets a
linker find the module defining a name without reading them all.
Structure
0library header, a record of type 0xF0, padded to the page size1 page…modules, each an OMF object module starting on a page boundaryvaries…end record of type 0xF1, padded to a 512-byte boundaryvaries…dictionary blocks512 bytes each
The library header
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 1 | Type | 0xF0 |
| 1 | 2 | Record length | The bytes after this field; the page size minus 3. The page size is a power of two, usually 16 or 512. |
| 3 | 4 | Dictionary offset | The file offset of the dictionary |
| 7 | 2 | Dictionary size | The number of 512-byte blocks |
| 9 | 1 | Flags | Bit 0 set: the names are case-sensitive |
| 10 | to the page | Padding | Up to the page size |
Modules
Each module is an OMF object module, from THEADR or LHEADR to MODEND, and starts at a multiple of the page size. A module is named by its offset divided by the page size: its page number. Padding fills up to the next multiple of the page size. The dictionary uses these page numbers to find a symbol’s module.
The end record
After the last module comes a record of type 0xF1, with a length and a run of padding that brings the file to the next 512-byte boundary, where the dictionary starts.
Not described
For OMF libraries, the extended dictionary is not read, and 11 of 340 real libraries do not place names where the dictionary hash says they should.
Other formats that use .lib
An OMF library is not an archive: it is a different format from the Windows .lib files, which share only the extension.
- Library (ar archive) – static and import libraries in the ar archive format, with the Windows COFF library and the short import object
Links
Software
- Open Watcom – compiler suite with the
wliblibrarian (Windows, Linux, DOS, OS/2)
Reference
- Object Module Format (Intel) – Wikipedia’s overview, with links to the Tool Interface Standards specification