microsoft library (.lib) format

来源:互联网 发布:寓言十九知乎 编辑:程序博客网 时间:2024/06/06 00:46

product: microsoft basic compiler
title: microsoft library (.lib) format, created by lib.exe

updated: 27-dec-1991
operating system versions: 6.00 6.00b 7.00 7.10
operating systems: ms-dos

summary:

this article describes the components of the microsoft library format
(for .lib files created by the lib.exe library manager). the microsoft
library format is consistent between compatible microsoft languages.
while future library utilities will remain backward- compatible with
the older library formats, the actual library format itself is subject
to change. this information is taken from chapter 5 of the "microsoft
c developer's toolkit reference," which contains more in-depth
information on the microsoft library format.

this information applies to microsoft quickbasic versions 4.0, 4.0b,
and 4.5 for ms-dos, to microsoft basic compiler versions 6.0 and 6.0b
for ms-dos, and to microsoft basic professional development system
(pds) versions 7.0 and 7.1 for ms-dos.

more information:

library header record
---------------------

object code library .lib files under ms-dos always contain blocks of
data in multiples of 512 bytes. the first record in the library is a
library header. this record is structured the same as a microsoft
object-module-format (ms omf) record. that is, the first byte of the
record identifies the record's type, and the next two bytes specify
the number of bytes remaining in the record. note that the length
field is byte-swapped (in other words, the low-order byte precedes the
high-order byte). the record type for this library header is f0 hex
(240 decimal).

modules in a library always start at the beginning of a page. page
size is determined by adding three (one for the record type byte and
two for the record length field itself) to the value in the record
length field; thus the library header record always occupies exactly
one page. legal values for page size are given by the range of 2
through the n, where n is a value from 4 through 15.

the four bytes immediately following the length field are a byte-
swapped long integer specifying the byte offset within the library of
the first block of the dictionary. the next two bytes are a byte-
swapped word field that specifies the number of blocks in the
dictionary. (note: the library manager, lib.exe for ms-dos, cannot
create a library whose dictionary requires more than 251 512-byte
pages.)

the next byte contains flags describing the library. one current flag
definition is "0x01 = case sensitive". this applies to both regular
and extended dictionaries. all other values are reserved for future
use and should be 0. the remaining bytes in the library header record
are not significant. this record deviates from the typical microsoft
omf record in that the last byte is not used as a checksum on the rest
of the record.

object modules
--------------

the first object module in the library immediately follows the header.
the first object module is followed in turn by all other object
modules in the library. each module is in microsoft omf. individual
modules are aligned so that they start at the beginning of a new page.
if, as is commonly the case, a module does not occupy a number of
bytes that is exactly a multiple of the page size, then its last block
is padded with as many null bytes as are required to fill it. this
special format is covered in detail in the "c developer's toolkit
reference."

dictionary blocks
-----------------

the remaining blocks in the library compose the dictionary. the number
of blocks in the dictionary is given in the library header. dictionary
length is in 512-byte blocks. detailed information on the exact
content and format of the dictionary are contained in the "c
developer's toolkit reference."

extended dictionary
-------------------

the extended dictionary is optional and indicates dependencies between
modules in the library. versions of lib.exe earlier than version 3.09
do not create an extended dictionary. the extended dictionary is
placed at the end of the library. again, see the "c developer's
toolkit reference" for details on the structure of the extended
dictionary.

additional reference words: 6.00 6.00b 7.00 7.10 4.00 4.00b 4.50