-
Notifications
You must be signed in to change notification settings - Fork 0
Library Files
Library files (file type $B2
) contain object segments that the linker can search for external references. Usually, these files contain general routines that can be used by more than one application. The linker extracts from the library file any object segment that contains an unresolved global definition that was referenced during the link, This segment is then added to the load segment that the linker is currently creating.
Library files differ from object files in that each library file includes a segment called the library dictionary segment (segment kind = $08
). The library dictionary segment contains the names and locations of all segments in the library file. This information allows the linker to scan the file quickly for needed segments. Library files are created from object files by a MakeLib tool (provided with a development environment). The format of the library dictionary segment is illustrated in Figure F-3.
The library dictionary segment begins with a segment header, which is identical in form to other segment headers. The BYTECNT
field indicates the number of bytes in the library dictionary segment, including the header. The body of the library dictionary segment consists of three LCONST records, in this order:
- Filenames
- Symbol table
- Symbol names
The filenames record consists of one or more subrecords, each consisting of a 2-byte file number followed by a filename. The filename is in Pascal string format, that is, a length byte indicating the number of characters, followed by an ASCII string. The filenames are the full pathnames of the object files from which the segments in this library file were extracted. The file numbers are assigned by the MakeLib program and used only within the library file. These file numbers are not related to the load-file numbers in the pathname table.
The symbol table record consists of a cross-reference between the symbol names in the symbol-names record and the object segments in which the symbol names occur. For each global symbol in the library file, the symbol table record contains the following components:
- A 4-byte displacement into the symbol names record, indicating the start of the symbol name.
- The 2-byte file number of the file in which the name occurred. This is the file number assigned by the MakeLib utility and used in the filenames record of this library dictionary segment.
- A 2-byte flag, the private flag. If this flag equals 1, the symbol name is valid only in the object file in which it occurred (that is, the symbol name was in a private segment). If this flag equals 0, the symbol name is not private.
- A 4-byte displacement into the library file indicating the beginning of the object segment in which the symbol occurs. The displacement is to the beginning of the segment even if the symbol occurs inside the segment, the location within the segment is resolved by the linker.
The symbol names record consists of a series of symbol names; each symbol name consists of a length byte followed by up to 255 ASCII characters. All global symbols that appear in an object segment, including entry points and global equates, are placed in the library dictionary segment. Duplicate symbols are not allowed.