home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / SS0288_1.TXT < prev    next >
Text File  |  1996-06-02  |  180KB  |  4,553 lines

  1.                              ********************************
  2.                              RELOCATABLE OBJECT MODULE FORMAT
  3.                              ********************************
  4.  
  5.                                                                                                      Revision Date: 5/92
  6.                                                       No Disk Included
  7.  
  8. The following information applies to to the Microsoft products listed
  9. below.
  10.  
  11.  --------------------------------------------------------------------
  12. | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY    |
  13. | ACCOMPANY THIS DOCUMENT (collectively referred to as an            |
  14. | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      |
  15. | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO    |
  16. | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A     |
  17. | PARTICULAR PURPOSE. The user assumes the entire risk as to the     |
  18. | accuracy and the use of this Application Note. This Application    |
  19. | Note may be copied and distributed subject to the following        |
  20. | conditions: 1) All text must be copied without modification and    |
  21. | all pages must be included; 2) If software is included, all files  |
  22. | on the disk(s) must be copied without modification [the MS-DOS(R)  |
  23. | utility DISKCOPY is appropriate for this purpose]; 3) All          |
  24. | components of this Application Note must be distributed together;  |
  25. | and 4) This Application Note may not be distributed for profit.    |
  26. |                                                                    |
  27. |    Copyright 1992 Microsoft Corporation.  All Rights Reserved.     |
  28. |    Microsoft, MS-DOS, QuickC, and QuickPascal are registered       |
  29. |    trademarks and Windows, QuickBasic, and Visual Basic are        |
  30. |    trademarks of Microsoft Corporation.                            |
  31. |                                                                    |
  32.  --------------------------------------------------------------------
  33.  
  34.  
  35. APPLICABLE PRODUCTS
  36. ===================
  37.  
  38. This application note applies to all versions of the following
  39. Microsoft language products:
  40.  
  41.    Microsoft Basic
  42.    Microsoft C
  43.    Microsoft C++
  44.      Microsoft COBOL
  45.    Microsoft FORTRAN
  46.    Microsoft Macro Assembler (MASM)
  47.    Microsoft Pascal
  48.    Microsoft QuickBasic(TM)
  49.    Microsoft QuickC(C)
  50.    Microsoft QuickC for Windows(TM)
  51.    Microsoft QuickPascal(C)
  52.    Microsoft Visual Basic(TM)
  53.    
  54.    
  55.                            TABLE OF CONTENTS
  56.                           ==================
  57.                                    
  58.                                                                Section
  59.                                                                -------
  60. Introduction                                                         1
  61. The Object Record Format                                             1
  62. Frequent Object Record Subfields                                     1
  63. Order of Records                                                     1
  64. Record Specifics                                                     1
  65. 80H THEADR--Translator Header Record                                 1
  66. 82H LHEADR--Library Module Header Record                             2
  67. 88H COMENT--Comment Record                                           2
  68. 88H IMPDEF--Import Definition Record (Comment Class A0, Subtype 01)  2
  69. 88H EXPDEF--Export Definition Record (Comment Class A0, Subtype 02)  2
  70. 88H INCDEF--Incremental Compilation Record (Cmnt Class A0, Sub 03)   2
  71. 88H LNKDIR--C++ Directives Record (Comment Class A0, Subtype 05)     2
  72. 88H LIBMOD--Library Module Name Record (Comment Class A3)            2
  73. 88H EXESTR--Executable String Record (Comment Class A4)              2
  74. 88H INCERR--Incremental Compilation Error (Comment Class A6)         2
  75. 88H NOPAD--No Segment Padding (Comment Class A7)                     2
  76. 88H WKEXT--Weak Extern Record (Comment Class A8)                     2
  77. 88H LZEXT--Lazy Extern Record (Comment Class A9)                     3
  78. 88H PharLap Format Record (Comment Class AA)                         3
  79. 8AH or 8BH MODEND--Module End Record                                 3
  80. 8CH EXTDEF--External Names Definition Record                         3
  81. 8EH TYPDEF--Type Definition Record                                   3
  82. 90H or 91H PUBDEF--Public Names Definition Record                    3
  83. 94H or 95H LINNUM--Line Numbers Record                               3
  84. 96H LNAMES--List of Names Record                                     4
  85. 98H or 99H SEGDEF--Segment Definition Record                         4
  86. 9AH GRPDEF--Group Definition Record                                  4
  87. 9CH or 9DH FIXUPP--Fixup Record                                      4
  88. A0H or A1H LEDATA--Logical Enumerated Data Record                    5
  89. A2H or A3H LIDATA--Logical Iterated Data Record                      5
  90. B0H COMDEF--Communal Names Definition Record                         5
  91. B2H or B3H BAKPAT--Backpatch Record                                  5
  92. B4H or B5H LEXTDEF--Local External Names Definition Record           5
  93. B6H or B7H LPUBDEF--Local Public Names Definition Record             5
  94. B8H LCOMDEF--Local Communal Names Definition Record                  5
  95. BCH CEXTDEF--COMDAT External Names Definition Record                 5
  96. C2H or C3H COMDAT--Initialized Communal Data Record                  5
  97. C4H or C5H LINSYM--Symbol Line Numbers Record                        6
  98. C6H ALIAS--Alias Definition Record                                   6
  99. C8H or C9H NBKPAT--Named Backpatch Record                            6
  100. CAH LLNAMES--Local Logical Names Definition Record                   6
  101. Appendix 1: CodeView Extensions                                      6
  102. Appendix 2: Microsoft MS-DOS Library Format                          6
  103.  
  104.  
  105. INTRODUCTION
  106. ============
  107.  
  108. This document is intended to serve a purpose that up until now has
  109. been performed by the LINK source code: to be the official definition
  110. for the object module format (the information inside .OBJ files)
  111. supported by Microsoft's language products. The goal is to include all
  112. currently used or obsolete OMF record types, all currently used or
  113. obsolete field values, and all extensions made by Microsoft, IBM, and
  114. others.
  115.  
  116. The information provided here has been consolidated from many other
  117. documents: "The MS-DOS Encyclopedia" by Microsoft Press, an OMF386
  118. document from IBM that was made available by the Joint Development
  119. Agreement, the "PharLap 386|Link Reference Manual," the Intel 8086
  120. object module specification (Intel Technical Specification 121748-
  121. 001), and internal Microsoft documents. Where there have been
  122. conflicts, the current LINK source code has decided which information
  123. is correct.
  124.  
  125. The  audience  for  this document is expected to  be  technical,  with
  126. background knowledge of the process by which source code is  converted
  127. into an executable file in the MS-DOS or OS/2 environment. If you need
  128. more  tutorial information, "The MS-DOS Encyclopedia" is a good  place
  129. to start.
  130.  
  131.  
  132. THE OBJECT RECORD FORMAT
  133. ========================
  134.  
  135. Record Format
  136. -------------
  137.  
  138. All object records conform to the following format:
  139.  
  140.                           <------Record Length in Bytes----->
  141.    1         2            <variable>    1
  142.    Record    Record       Record        Checksum or 0
  143.    Type      Length       Contents
  144.  
  145. The Record Type field is a 1-byte field containing the hexadecimal
  146. number that identifies the type of object record.
  147.  
  148. The Record Length field is a 2-byte field that gives the length of the
  149. remainder of the object record in bytes (excluding the bytes in the
  150. Record Type and Record Length fields). The record length is stored
  151. with the low-order byte first. An entire record occupies 3 bytes plus
  152. the number of bytes in the Record Length field.
  153.  
  154. The Record Contents field varies in size and format, depending on the
  155. record type.
  156.  
  157. The Checksum field is a 1-byte field that contains the negative sum
  158. (modulo 256) of all other bytes in the record. In other words, the
  159. checksum byte is calculated so that the low-order byte of the sum of
  160. all the bytes in the record, including the checksum byte, equals 0.
  161. Overflow is ignored. Some compilers write a 0 byte rather than
  162. computing the checksum, so either form should be accepted by programs
  163. that process object modules.
  164.  
  165.   NOTES
  166.   
  167.   The maximum size of the entire record (unless otherwise noted for
  168.   specific record types) is 1024 bytes.
  169.  
  170.   For LINK386, the format is determined by the least-significant bit
  171.   of the Record Type field. An odd Record Type indicates that certain
  172.   numeric fields within the record contain 32-bit values; an even
  173.   Record Type indicates that those fields contain 16-bit values. The
  174.   affected fields are described with each record. Note that this
  175.   principle does not govern the Use32/Use16 segment attribute (which
  176.   is set in the ACBP byte of SEGDEF records); it simply specifies the
  177.   size of certain numeric fields within the record. It is possible to
  178.   use 16-bit OMF records to generate 32-bit segments, or vice versa.
  179.  
  180.   LINK ignores the value of the checksum byte, but some other
  181.   utilities do not. Microsoft's Quick languages write a 0 byte instead
  182.   of computing a checksum.
  183.  
  184.  
  185. FREQUENT OBJECT RECORD SUBFIELDS
  186. ================================
  187.  
  188. The contents of each record are determined by the record type, but
  189. certain subfields appear frequently enough to be explained separately.
  190. The format of such fields is below.
  191.  
  192. Names
  193. -----
  194.  
  195. A name string is encoded as an 8-bit unsigned count followed by a
  196. string of count characters. The character set is usually some ASCII
  197. subset. A null name is specified by a single byte of 0 (indicating a
  198. string of length 0).
  199.  
  200. Indexed References
  201. ------------------
  202.  
  203. Certain items are ordered by occurrence and are referenced by index.
  204. The first occurrence of the item has index number 1. Index fields may
  205. contain 0 (indicating that they are not present) or values from 1
  206. through 7FFF. The index number field in an object record can be either
  207. 1 or 2 bytes long. If the number is in the range 0-7FH, the high-order
  208. bit (bit 7) is 0 and the low-order bits contain the index number, so
  209. the field is only 1 byte long. If the index number is in the range 80-
  210. 7FFFH, the field is 2 bytes long. The high-order bit of the first byte
  211. in the field is set to 1, and the high-order byte of the index number
  212. (which must be in the range 0-7FH) fits in the remaining 7 bits. The
  213. low-order byte of the index number is specified in the second byte of
  214. the field. The code to decode an index is:
  215.    
  216.    if (first_byte & 0x80)
  217.         index_word = (first_byte & 7F) * 0x100 + second_byte;
  218.    else
  219.         index_word = first_byte;
  220.  
  221. Type Indexes
  222. ------------
  223.  
  224. Type Index fields occupy 1 or 2 bytes and occur in PUBDEF, LPUBDEF,
  225. COMDEF, LCOMDEF, EXTDEF, and LEXTDEF records. They are encoded as
  226. described above for indexed references, but the interpretation of the
  227. values stored is governed by whether the module has the "new" or "old"
  228. object module format.
  229.  
  230. "Old" versions of the OMF (indicated by lack of a COMENT record with
  231. comment class A1), have Type Index fields that contain indexes into
  232. previously seen TYPDEF records. This format is no longer produced by
  233. Microsoft products and is ignored by LINK if it is present. See the
  234. section of this document on TYPDEF records for details on how this was
  235. used.
  236.  
  237. "New" versions of the OMF (indicated by the presence of a COMENT
  238. record with comment class A1), have Type Index fields that contain
  239. proprietary CodeView information. For more information on CodeView,
  240. see Appendix 1.
  241.   
  242.   NOTE: Currently, the linker does not perform type checking.
  243.  
  244. Ordered Collections
  245. -------------------
  246.  
  247. Certain records and record groups are ordered so that the records may
  248. be referred to with indexes (the format of indexes is described in the
  249. "Indexed References" section of this document). The same format is
  250. used whether an index refers to names, logical segments, or other
  251. items.
  252.  
  253. The overall ordering is obtained from the order of the records within
  254. the file together with the ordering of repeated fields within these
  255. records. Such ordered collections are referenced by index, counting
  256. from 1 (index 0 indicates unknown or not specified).
  257.  
  258. For example, there may be many LNAMES records within a module, and
  259. each of those records may contain many names. The names are indexed
  260. starting at 1 for the first name in the first LNAMES record
  261. encountered while reading the file, 2 for the second name in the first
  262. record, and so forth, with the highest index for the last name in the
  263. last LNAMES record encountered.
  264.  
  265. The ordered collections are:
  266.  
  267.    Names       Ordered by occurrence of LNAMES records and
  268.                names within each. Referenced as a name
  269.                index.
  270.                
  271.    Logical     Ordered by occurrence of SEGDEF records in
  272.    Segments    file. Referenced as a segment index.
  273.                
  274.    Groups      Ordered by occurrence of GRPDEF records in
  275.                file. Referenced as a group index.
  276.                
  277.    External    Ordered by occurrence of EXTDEF, COMDEF,
  278.    Symbols     LEXTDEF, and LCOMDEF records and symbols
  279.                within each. Referenced as an external name
  280.                index (in FIXUP subrecords).
  281.                
  282.  
  283. Numeric 2- and 4-Byte Fields
  284. ----------------------------
  285.  
  286. Words and double words (16- and 32-bit quantities) are stored in Intel
  287. byte order (lowest address is least significant).
  288.  
  289. Certain records, notably SEGDEF, PUBDEF, LPUBDEF, LINNUM, LEDATA,
  290. LIDATA, FIXUPP, and MODEND, contain size, offset, and displacement
  291. values that may be 32-bit quantities for Use32 segments. The encoding
  292. is as follows:
  293.  
  294.  - When the least-significant bit of the record type byte is set (that
  295.    is, the record type is an odd number), the numeric fields are 4
  296.    bytes.
  297.  
  298.  - When the least-significant bit of the record type byte is clear,
  299.    the fields occupy 2 bytes. The values are zero-extended when
  300.    applied to Use32 segments.
  301.  
  302.   NOTE: See the description of SEGDEF records in this document for an
  303.   explanation of Use16/Use32 segments.
  304.  
  305.  
  306. ORDER OF RECORDS
  307. ================
  308.  
  309. The sequence in which the types of object records appear in an object
  310. module is fairly flexible in some respects. Several record types are
  311. optional, and if the type of information they carry is unnecessary,
  312. they are omitted from the object module. In addition, most object
  313. record types can occur more than once in the same object module. And
  314. because object records are variable in length, it is often possible to
  315. choose between combining information into one large record or breaking
  316. it down into several smaller records of the same type.
  317.  
  318. An important constraint on the order in which object records appear is
  319. the need for some types of object records to refer to information
  320. contained in other records. Because the linker processes the records
  321. sequentially, object records containing such information must precede
  322. the records that refer to the information. For example, two types of
  323. object records, SEGDEF and GRPDEF, refer to the names contained in an
  324. LNAMES record. Thus, an LNAMES record must appear before any SEGDEF or
  325. GRPDEF records that refer to it so that the names in the LNAMES record
  326. are known to the linker by the time it processes the SEGDEF or GRPDEF
  327. records.
  328.  
  329. The record order is chosen so that linker passes through an object
  330. module are minimized. Microsoft LINK makes two passes through the
  331. object modules: the first pass may be cut short by the presence of the
  332. Link Pass Separator COMENT record; the second pass processes all
  333. records.
  334.  
  335. For greatest linking speed, all symbolic information should occur at
  336. the start of the object module. This order is recommended but not
  337. mandatory. The general ordering is:
  338.  
  339. Identifier Record(s)
  340. --------------------
  341.  
  342.     NOTE: This must be the first record.
  343.    
  344.      THEADR or LHEADR record
  345.  
  346. Records Processed by LINK Pass 1
  347. --------------------------------
  348.    
  349. The following records may occur in any order but they must precede the
  350. Link Pass Separator if it is present:
  351.    
  352.    COMENT records identifying object format and extensions
  353.    
  354.    COMENT records other than Link Pass Separator comment
  355.    
  356.    LNAMES or LLNAMES records providing ordered name list
  357.    
  358.    SEGDEF records providing ordered list of program segments
  359.    
  360.    GRPDEF records providing ordered list of logical segments
  361.    
  362.    TYPDEF records (obsolete)
  363.    
  364.      ALIAS records
  365.    
  366.    PUBDEF records locating and naming public symbols
  367.    
  368.    LPUBDEF records locating and naming private symbols
  369.    
  370.    COMDEF, LCOMDEF, EXTDEF, LEXTDEF, and CEXTDEF records
  371.     
  372.     NOTE: This group of records is indexed together, so external name
  373.     index fields in FIXUPP records may refer to any of the record
  374.     types listed.
  375.  
  376. Link Pass Separator (Optional)
  377. ------------------------------
  378.  
  379. COMENT class A2 record indicating that Pass 1 of the linker is
  380. complete. When this record is encountered, LINK stops reading the
  381. object file in Pass 1; no records after this comment are read in Pass
  382. 1. All the records listed above must come before this COMENT record.
  383.  
  384. For greater linking speed, all LIDATA, LEDATA, FIXUPP, BAKPAT, INCDEF,
  385. and LINNUM records should come after the A2 COMENT record, but this is
  386. not required. In LINK, Pass 2 begins again at the start of the object
  387. module, so these records are processed in Pass 2 no matter where they
  388. are placed in the object module.
  389.  
  390. Records Ignored by LINK Pass 1 and Processed by LINK Pass 2
  391. -----------------------------------------------------------
  392.    
  393. The following records may come before or after the Link Pass
  394. Separator:
  395.    
  396.    LIDATA, LEDATA, or COMDAT records followed by applicable FIXUPP
  397.    records
  398.    
  399.    FIXUPP records containing only THREAD subrecords
  400.    
  401.    BAKPAT and NBKPAT FIXUPP records
  402.    
  403.    COMENT class A0, subrecord type 03 (INCDEF) records containing
  404.      incremental compilation information for FIXUPP and LINNUM records
  405.    
  406.    LINNUM and LINSYM records providing line number and program code or
  407.    data association
  408.  
  409. Terminator
  410. ----------
  411.    
  412.    MODEND record indicating end of module with optional start address
  413.    
  414.  
  415. RECORD SPECIFICS
  416. ================
  417.  
  418. Details of each record (form and content), together with historical
  419. notes and comments on usage, are presented in the sections that
  420. follow.
  421.  
  422. Conflicts between various OMFs that overlap in their use of record
  423. types or fields are marked.
  424.  
  425. Below is a combined list of record types defined by the Intel 8086 OMF
  426. specification and record types added after that specification was
  427. finished. Titles in square brackets ([]) indicate record types that
  428. have been implemented and that are described in this document. Titles
  429. not in square brackets indicate record types that have not been
  430. implemented and are followed by a paragraph of description from the
  431. Intel specification.
  432.  
  433. For unimplemented record types, a subtle distinction is made between
  434. records that LINK ignores and those for which LINK generates an
  435. "illegal object format" error condition.
  436.  
  437. Records Currently Defined
  438. -------------------------
  439.    
  440.    6EH     RHEADR   R-Module Header Record
  441.                     This record serves to identify a module that has
  442.                     been processed (output) by LINK-86/LOCATE-86. It
  443.                     also specifies the module attributes and gives
  444.                                         information on memory usage and need. This record
  445.                     type is ignored by Microsoft LINK.
  446.                     
  447.    70H     REGINT   Register Initialization Record
  448.                     This record provides information about the 8086
  449.                     register/register-pairs: CS and IP, SS and SP, DS
  450.                     and ES. The purpose of this information is for a
  451.                     loader to set the necessary registers for
  452.                     initiation of execution. This record type is
  453.                     ignored by Microsoft LINK.
  454.                     
  455.    72H     REDATA   Relocatable Enumerated Data Record
  456.                     This record provides contiguous data from which a
  457.                     portion of an 8086 memory image may eventually be
  458.                     constructed. The data may be loaded directly by
  459.                     an 8086 loader, with perhaps some base fixups.
  460.                     The record may also be called a Load-Time
  461.                     Locatable (LTL) Enumerated Data Record. This
  462.                     record type is ignored by Microsoft LINK.
  463.                     
  464.      74H     RIDATA   Relocatable Iterated Data Record
  465.                     This record provides contiguous data from which a
  466.                     portion of an 8086 memory image may eventually be
  467.                     constructed. The data may be loaded directly by
  468.                     an 8086 loader, but data bytes within the record
  469.                     may require expansion. The record may also be
  470.                     called a Load-Time Locatable (LTL) Iterated Data
  471.                     Record. This record type is ignored by Microsoft
  472.                     LINK.
  473.                     
  474.    76H     OVLDEF   Overlay Definition Record
  475.                     This record provides the overlay's name, its
  476.                     location in the object file, and its attributes.
  477.                     A loader may use this record to locate the data
  478.                     records of the overlay in the object file. This
  479.                     record type is ignored by Microsoft LINK.
  480.                     
  481.    78H     ENDREC   End Record
  482.                     This record is used to denote the end of a set of
  483.                     records, such as a block or an overlay. This
  484.                                         record type is ignored by Microsoft LINK.
  485.                     
  486.    7AH     BLKDEF   Block Definition Record
  487.                     This record provides information about blocks
  488.                     that were defined in the source program input to
  489.                     the translator that produced the module. A BLKDEF
  490.                     record will be generated for every procedure and
  491.                     for every block that contains variables. This
  492.                     information is used to aid debugging programs.
  493.                     This record type is ignored by Microsoft LINK.
  494.  
  495.    7CH     BLKEND   Block End Record
  496.                     This record, together with the BLKDEF record,
  497.                     provides information about the scope of variables
  498.                     in the source program. Each BLKDEF record must be
  499.                     followed by a BLKEND record. The order of the
  500.                     BLKDEF, debug symbol records, and BLKEND records
  501.                     should reflect the order of declaration in the
  502.                     source module. This record type is ignored by
  503.                     Microsoft LINK.
  504.  
  505.    7EH     DEBSYM   Debug Symbols Record
  506.                     This record provides information about all
  507.                     local symbols, including stack and based symbols.
  508.                     The purpose of this information is to aid debug-
  509.                     ging programs. This record type is ignored by 
  510.                     Microsoft LINK.
  511.                           
  512.    [80H]   [THEADR] [Translator Header Record]
  513.                           
  514.    [82H]   [LHEADR] [Library Module Header Record]
  515.                           
  516.    84H     PEDATA   Physical Enumerated Data Record
  517.                     This record provides contiguous data,
  518.                     from which a portion of an 8086 memory
  519.                     image may be constructed. The data
  520.                     belongs to the "unnamed absolute segment"
  521.                     in that it has been assigned absolute
  522.                     8086 memory addresses and has been
  523.                     divorced from all logical segment
  524.                                         information. This record type is ignored
  525.                     by Microsoft LINK.
  526.                           
  527.    86H     PIDATA   Physical Iterated Data Record
  528.                     This record provides contiguous data,
  529.                     from which a portion of an 8086 memory
  530.                     image may be constructed. It allows
  531.                     initialization of data segments and
  532.                     provides a mechanism to reduce the size
  533.                     of object modules when there is repeated
  534.                     data to be used to initialize a memory
  535.                     image. The data belongs to the "unnamed
  536.                     absolute segment." This record type is
  537.                     ignored by Microsoft LINK.
  538.                           
  539.    [88H]   [COMENT] [Comment Record]
  540.                           
  541.    [8AH/8BH] [MODEND] [Module End Record]
  542.                           
  543.    [8CH]   [EXTDEF] [External Names Definition Record]
  544.  
  545.    [8EH]   [TYPDEF] [Type Definition Record]
  546.                           
  547.    [90H/91H] [PUBDEF] [Public Names Definition Record]
  548.                           
  549.    92H     LOCSYM   Local Symbols Record
  550.                     This record provides information about
  551.                     symbols that were used in the source
  552.                     program input to the translator that
  553.                     produced the module. This information is
  554.                     used to aid debugging programs. This
  555.                     record has a format identical to the
  556.                     PUBDEF record. This record type is
  557.                     ignored by Microsoft LINK.
  558.                           
  559.    [94H/95H] [LINNUM] [Line Numbers Record]
  560.                           
  561.    [96H]   [LNAMES] [List of Names Record]
  562.                           
  563.    [98H/99H] [SEGDEF] [Segment Definition Record]
  564.  
  565.    [9AH]   [GRPDEF] [Group Definition Record]
  566.                           
  567.    [9CH/9DH] [FIXUPP] [Fixup Record]
  568.                           
  569.    9EH     (none)   Unnamed record
  570.                     This record number was the only even
  571.                     number not defined by the original Intel
  572.                     specification. Apparently it was never
  573.                     used.  This record type is ignored by
  574.                     Microsoft LINK.
  575.                           
  576.    [A0H/A1H] [LEDATA] [Logical Enumerated Data Record]
  577.                           
  578.    [A2H/A3H] [LIDATA] [Logical Iterated Data Record]
  579.  
  580.    A4H     LIBHED   Library Header Record
  581.                     This record is the first record in a library
  582.                     file. It immediately precedes the modules
  583.                     (if any) in the library. Following the
  584.                                         modules are three more records in the
  585.                     following order: LIBNAM, LIBLOC, and LIBDIC.
  586.                     This record type is ignored by Microsoft
  587.                     LINK.
  588.                         
  589.    A6H     LIBNAM   Library Module Names Record
  590.                     This record lists the names of all the
  591.                     modules in the library. The names are listed
  592.                     in the same sequence as the modules appear
  593.                     in the library. This record type is ignored
  594.                     by Microsoft LINK.
  595.                         
  596.    A8H     LIBLOC   Library Module Locations Record
  597.                     This record provides the relative location,
  598.                     within the library file, of the first byte
  599.                     of the first record (either a THEADR or
  600.                     LHEADR or RHEADR record) of each module in
  601.                     the library. The order of the locations
  602.                     corresponds to the order of the modules in
  603.                     the library. This record type is ignored by
  604.                                         Microsoft LINK.
  605.                         
  606.    AAH     LIBDIC   Library Dictionary Record
  607.                     This record gives all the names of public
  608.                     symbols within the library. The public names
  609.                     are separated into groups; all names in the
  610.                     nth group are defined in the nth module of
  611.                     the library. This record type is ignored by
  612.                     Microsoft LINK.
  613.                         
  614.    [B0H]   [COMDEF] [Communal Names Definition Record]
  615.                         
  616.    [B2H/B3H] [BAKPAT] [Backpatch Record]
  617.                         
  618.    [B4H]   [LEXTDEF] [Local External Names Definition Record]
  619.                         
  620.    [B6H/B7H] [LPUBDEF] [Local Public Names Definition Record]
  621.                         
  622.    [B8H]   [LCOMDEF] [Local Communal Names Definition Record]
  623.                         
  624.      BAH/BBH COMFIX   Communal Fixup Record
  625.                     Microsoft doesn't support this never-
  626.                     implemented IBM extension. This record type
  627.                     generates an error when it is encountered by
  628.                     Microsoft LINK.
  629.                         
  630.    BCH     CEXTDEF  COMDAT External Names Definition Record
  631.                         
  632.    C0H     SELDEF   Selector Definition Record
  633.                     Microsoft doesn't support this never-
  634.                     implemented IBM extension. This record type
  635.                     generates an error when it is encountered by
  636.                     Microsoft LINK.
  637.                         
  638.    [C2H/C3] [COMDAT] [Initialized Communal Data Record]
  639.                         
  640.    [C4H/C5H] [LINSYM] [Symbol Line Numbers Record]
  641.                         
  642.    [C6H]   [ALIAS]  [Alias Definition Record]
  643.                         
  644.      [C8H/C9H] [NBKPAT] [Named Backpatch Record]
  645.                         
  646.    [CAH]   [LLNAMES] [Local Logical Names Definition Record]
  647.                         
  648.    [F0H]            [Library Header Record]
  649.                     Although this is not actually an OMF record
  650.                     type, the presence of a record with F0H as
  651.                     the first byte indicates that the module is
  652.                     a Microsoft library. The format of a library
  653.                     file is given in Appendix 2.
  654.  
  655.    [F1H]            [Library End Record]
  656.                         
  657.  
  658. 80H THEADR--TRANSLATOR HEADER RECORD
  659. ====================================
  660.  
  661. Description
  662. -----------
  663.  
  664. The THEADR record contains the name of the object module. This name
  665. identifies an object module within an object library or in messages
  666. produced by the linker.
  667.  
  668. History
  669. -------
  670.  
  671. Unchanged.
  672.  
  673. Record Format
  674. -------------
  675.  
  676.    1    2           1            <-String Length->  1
  677.    80   Record      String       Name String        Checksum
  678.         Length      Length
  679.    
  680. The String Length byte gives the number of characters in the name
  681. string; the name string itself is ASCII. This name is usually that of
  682. the file that contains a program's source code (if supplied by the
  683. language translator), or may be specified directly by the programmer
  684. (for example, TITLE pseudo-operand or assembler NAME directive).
  685.   
  686.   NOTES
  687.   
  688.   The name string is always present; a null name is allowed but not
  689.   recommended (because it doesn't provide much information for a
  690.   debugging program).
  691.   
  692.   In object modules generated by Microsoft compilers, the name string
  693.   indicates the full path and filename of the file that contained the
  694.   source code for the module.
  695.   
  696.   This record, or an LHEADR record must occur as the first object
  697.   record. More than one header record is allowed (as a result of an
  698.   object bind, or if the source arose from multiple files as a result
  699.   of include processing).
  700.  
  701. Examples
  702. --------
  703.  
  704. The following THEADR record was generated by the Microsoft C Compiler:
  705.  
  706.       0   1   2   3   4   5   6   7   8   9   A   B   C D  E  F  
  707. 0000  80  09  00  07  68  65  6C  6C  6F  2E  63  CB           ...hello.c
  708.                                                         
  709.  
  710. Byte 00H contains 80H, indicating a THEADR record.
  711.  
  712. Bytes 01-02H contain 0009H, the length of the remainder of the record.
  713.  
  714. Bytes 03-0AH contain the T-module name. Byte 03H contains 07H, the
  715. length of the name, and bytes 04H through 0AH contain the name itself
  716. (HELLO.C).
  717.  
  718. Byte 0BH contains the Checksum field, 0CBH.
  719.  
  720.  
  721. 82H LHEADR--LIBRARY MODULE HEADER RECORD
  722. ========================================
  723.  
  724. Description
  725. -----------
  726.  
  727. This record is very similar to the THEADR record. It is used to
  728. indicate the name of a module within a library file (which has an
  729. internal organization different from that of an object module).
  730.  
  731. History
  732. -------
  733.  
  734. This record type was defined in the original Intel specification with
  735. the same format but with a different purpose, so its use for libraries
  736. should be considered a Microsoft extension.
  737.  
  738. Record Format
  739. -------------
  740.  
  741.    1    2           1            <-String Length->  1
  742.    82   Record      String       Name String        Checksum
  743.                 Length      Length
  744.  
  745.  
  746.     NOTE: In LINK, THEADR, and LHEADR records are handled identically.
  747.     See Appendix 2 for a complete description of Microsoft's library
  748.     file format.
  749.  
  750.  
  751. **********
  752. Document 2
  753. **********
  754.  
  755.  
  756. 88H COMENT--COMMENT RECORD
  757. ==========================
  758.  
  759. Description
  760. -----------
  761.  
  762. The COMENT record contains a character string that may represent a
  763. plain text comment, a symbol meaningful to a program such as LIB or
  764. LINK, or even binary-encoded identification data. An object module can
  765. contain any number of COMENT records.
  766.  
  767. History
  768. -------
  769.  
  770. New comment classes have been added or changed for LINK386. They are:
  771. 9D, A0, A1, A2, A4, AA, B0, and B1.
  772.  
  773. Comment class A2 was added for C version 5.0. Histories for comment
  774. classes A0, A3, A4, A6, A7, and A8 are given later in this section.
  775.  
  776. 68000 and big-endian comments were added for C version 7.0.
  777.  
  778. Record Format
  779. -------------
  780.  
  781. The comment records are actually a group of items, classified by
  782. comment class.
  783.  
  784.    1   2        1       1          <-Record Length Minus 3-> 1
  785.    88  Record   Comment Comment    Commentary Byte String    Checksum
  786.        Length   Type    Class      (optional)
  787.  
  788. Comment Type
  789. ------------
  790.  
  791. The Comment Type field is bit significant; its layout is
  792.   
  793.   <-------1 byte----------------------------------------------->
  794.    NP     NL      0      0       0      0       0      0
  795.  
  796. where
  797.  
  798.    NP  (no purge bit) is set if the comment is to be preserved by
  799.        utility programs that manipulate object modules. This bit can
  800.        protect an important comment, such as a copyright message,
  801.        from deletion.
  802.        
  803.    NL  (no list bit) is set if the comment is not to be displayed by
  804.        utility programs that list the contents of object modules.
  805.        This bit can hide a comment.
  806.  
  807. The remaining bits are unused and should be set to 0.
  808.  
  809. Comment Class and Commentary Byte String
  810. ----------------------------------------
  811.  
  812. The Comment Class field is an 8-bit numeric field that conveys
  813. information by its value (accompanied by a null byte string) or
  814. indicates the information to be found in the accompanying byte string.
  815. The byte string's length is determined from the record length, not by
  816. an initial count byte.
  817.  
  818. The values that have been defined (including obsolete values) are the
  819. following:
  820.  
  821.    0        Translator     Translator; it may name the source
  822.                            language or translator. We recommend
  823.                            that the translator name and version,
  824.                            plus the optimization level used for
  825.                            compilation, be recorded here. Other
  826.                            compiler or assembler options can be
  827.                            included, although current practice
  828.                            seems to be to place these under
  829.                            comment class 9D.
  830.                            
  831.    1        Intel          Ignored by LINK. Comments of this class
  832.             copyright      are used by QuickC for padding.
  833.                            
  834.    2 - 9B   Intel          The values from 9C through FF are
  835.             reserved       ignored by Intel products.
  836.                            
  837.    81       Library        Replaced by comment class 9F; contents
  838.             specifier--    are identical to 9F.
  839.             obsolete       
  840.             
  841.    9C       MS-DOS         The byte string is then 2 bytes and
  842.             version--      specifies the MS-DOS version number.
  843.             obsolete       This comment class is not supported by
  844.                            LINK.
  845.                            
  846.    9D       Memory model-  This information is currently generated
  847.             -ignored       by the C compiler for use by the XENIX
  848.                            linker; it is ignored by the MS-DOS and
  849.                            OS/2 versions of LINK. The byte string
  850.                            consists of from one to three ASCII
  851.                            characters and indicates the following:
  852.                            
  853.                               0, 1, 2,   8086, 80186, 80286, or 
  854.                               or 3       80386 instructions 
  855.                                          generated, respectively
  856.                        
  857.                               O          Optimization performed on 
  858.                                          code
  859.                        
  860.                               s, m, c,   Small, medium, compact, 
  861.                               l, or h    large, or huge model
  862.                        
  863.                               A, B, C,   68000, 68010, 68020, or 
  864.                               D          68030 instructions 
  865.                                          generated, respectively
  866.                        
  867.    9E       DOSSEG         Sets Microsoft LINK's DOSSEG switch.
  868.                            The byte string is null. This record is
  869.                            included in the startup module in each
  870.                            language library. It directs the linker
  871.                            to use the standardized segment
  872.                            ordering, according to the naming
  873.                            conventions documented with MS-DOS,
  874.                            OS/2, and accompanying language
  875.                            products.
  876.                            
  877.    9F       Default        The byte string contains a library
  878.             library        filename (without a lead count byte and
  879.             search name    without an extension), which is
  880.                            searched in order to resolve external
  881.                            references within the object module.
  882.                            The default library search can be
  883.                            overridden with LINK's
  884.                            /NODEFAULTLIBRARYSEARCH switch.
  885.                            
  886.    A0       OMF            This class consists of a set of
  887.             extensions     records, identified by subtype (first
  888.                            byte of commentary string). Values
  889.                            supported by LINK are:
  890.                            
  891.             01     IMPDEF     Import definition record. See the
  892.                               IMPDEF section in this document for
  893.                               a complete description.
  894.                               
  895.             02     EXPDEF     Export definition record. See the
  896.                               EXPDEF section in this document for
  897.                               a complete description.
  898.                               
  899.             03     INCDEF     Incremental compilation record. See
  900.                               the INCDEF section in this document
  901.                               for a complete description.
  902.                               
  903.             04     Protected  LINK386 only; relevant only to 32-
  904.                    memory     bit dynamic-link libraries (DLLs).
  905.                    library    This comment record is inserted in
  906.                               an object module by the compiler
  907.                               when it encounters the _loadds
  908.                               construct in the source code for a
  909.                               DLL. LINK then sets a flag in the
  910.                               header of the executable file (DLL)
  911.                               to indicate that the DLL should be
  912.                               loaded in such a way that its shared
  913.                               data is protected from corruption.
  914.                               The _loadds keyword tells the
  915.                               compiler to emit modified function
  916.                               prolog code, which loads the DS
  917.                               segment register. (Normal functions
  918.                               don't need this.)
  919.                               
  920.                               When the flag is set in the .EXE
  921.                               header, the loader loads the
  922.                               selector of a protected memory area
  923.                               into DS while performing run-time
  924.                               fixups (relocations). All other DLLs
  925.                               and applications get the regular
  926.                               DGROUP selector, which doesn't allow
  927.                               access to the protected memory area
  928.                               set up by the operating system.
  929.                               
  930.             05     LNKDIR     C++ linker directives record. See
  931.                               the LNKDIR section of this document
  932.                               for a complete description.
  933.                               
  934.             06     Big-       The target for this OMF is a big-
  935.                    endian     endian machine, as opposed to little-
  936.                               endian or Intel format. (For an
  937.                               explanation of big-endian and little-
  938.                               endian, see "On Holy Wars and a Plea
  939.                               for Peace," by Danny Cohen, pages 48-
  940.                               54 in "Computer," volume 14, number
  941.                               10, October 1981.)
  942.                               
  943.             07     PRECOMP    When the CodeView information for
  944.                               this object file is emitted, the
  945.                               directory entry for $$TYPES is to be
  946.                               emitted as sstPreComp instead of
  947.                               sstTypes.
  948.                               
  949.             08-FF             Reserved by Microsoft.
  950.                               
  951.             NOTE: The presence of any unrecognized
  952.             subtype (currently, anything greater than
  953.             07) causes LINK to generate a fatal error.
  954.             
  955.    A1   "New OMF"     This comment class is now used solely to
  956.         extension     indicate the version of the symbolic debug
  957.                       information. If this comment class is not
  958.                       present, the oldest format of CodeView
  959.                       information is written to the .EXE file
  960.                       produced by LINK. If the comment class is
  961.                       present, the latest version format of
  962.                       CodeView information is written.
  963.                       
  964.                       This comment class was previously used to
  965.                       indicate that the obsolete method of
  966.                       communal representation through TYPDEF and
  967.                       EXTDEF pairs was not used and that COMDEF
  968.                       records were used instead. In current
  969.                       linkers, COMDEF records are always enabled,
  970.                       even without this comment record present.
  971.                       
  972.                       The byte string is currently empty, but the
  973.                       planned future contents will be a version
  974.                       number (8-bit numeric field) followed by an
  975.                       ASCII character string indicating the symbol
  976.                       style. Values will be:
  977.                       
  978.                           n,'C','V  CodeView style
  979.                       
  980.                           n,'D','X'  AIX style
  981.                       
  982.    A2   LINK Pass     This record conveys information to the
  983.                       linker about the organization of the file.
  984.                       The value of the first byte of the
  985.                       commentary string specifies the comment
  986.                       subtype. Currently, a single subtype is
  987.                       defined:
  988.                    
  989.                           01            Indicates the start of records 
  990.                                         generated from LINK Pass 2. 
  991.                                         Additional bytes may follow, 
  992.                                         with their number determined 
  993.                                         by the Record Length field, but 
  994.                                         they will be ignored by LINK.
  995.                                         
  996.                                         See the "Order of Records" 
  997.                                         section in this document for 
  998.                                         information on which records must 
  999.                                         come before and after this comment.
  1000.                                         
  1001.                                           Warning: It is assumed that 
  1002.                                           this comment will not be present 
  1003.                                           in a module whose MODEND record 
  1004.                                           contains a program starting
  1005.                                           address. If there are overlays, 
  1006.                                           LINK needs to see the starting 
  1007.                                           address on Pass 1 to define the 
  1008.                                           symbol $$MAIN.
  1009.                                         
  1010.         NOTE: This comment class may become obsolete with the advent of
  1011.         COMDAT records.
  1012.                         
  1013.    A3   LIBMOD        Library module comment record. Ignored by
  1014.                       LINK; used only by Microsoft's LIB utility.
  1015.                       See the LIBMOD section in this document for
  1016.                       a complete description.
  1017.                       
  1018.    A4   EXESTR        Executable string. See the EXESTR section in
  1019.                       this document for a complete description.
  1020.                       
  1021.    A6   INCERR        Incremental compilation error. See the
  1022.                       INCERR section in this document for a
  1023.                       complete description.
  1024.                       
  1025.    A7   NOPAD         No segment padding. See the NOPAD section in
  1026.                       this document for a complete description.
  1027.                       
  1028.    A8   WKEXT         Weak Extern record. See the WKEXT section in
  1029.                       this document for a complete description.
  1030.                       
  1031.    A9   LZEXT         Lazy Extern record. See the LZEXT section in
  1032.                       this document for a complete description.
  1033.                       
  1034.    AA   PharLap       Possibly obsolete; see the PharLap section
  1035.         format        in this document for a complete description.
  1036.                       
  1037.    B0   Initial IBM   Obsolete.
  1038.         OMF386        
  1039.         format.
  1040.         
  1041.    B1   Record order  Obsolete; part of initial IBM OMF386 format.
  1042.                       
  1043.    DA   Comment       For random comment.
  1044.                       
  1045.    DB   Compiler      For pragma comment(compiler); version
  1046.                       number.
  1047.                       
  1048.    DC   Date          For pragma comment(date stamp).
  1049.                       
  1050.    DD   Timestamp     For pragma comment(timestamp).
  1051.                       
  1052.    DF   User          For pragma comment(user). Sometimes used for
  1053.                       copyright notices.
  1054.                       
  1055.    E9   Dependency    Used to show the include files that were
  1056.         file          used to build this .OBJ file.
  1057.         (Borland)     
  1058.         
  1059.    FF   Command line  Shows the compiler options chosen. May be
  1060.         (QuickC)      obsolete. This record is also used by
  1061.                       Phoenix for library comments.
  1062.                       
  1063.    C0H-   Reserved     Reserved for user-defined comment classes.
  1064.    FFH                 
  1065.    and
  1066.    not
  1067.    other-
  1068.    wise
  1069.    used
  1070.    
  1071.   
  1072.   NOTES
  1073.   
  1074.   Microsoft LIB ignores the Comment Type field.
  1075.   
  1076.   A COMENT record can appear almost anywhere in an object module. Only
  1077.   two restrictions apply:
  1078.   
  1079.   - A COMENT record cannot be placed between a FIXUPP record and  the
  1080.     LEDATA or LIDATA record to which it refers.
  1081.   
  1082.   - A COMENT record cannot be the first or last record in an  object
  1083.     module. (The first record must always be THEADR or LHEADR and  the
  1084.     last must always be MODEND.)
  1085.   
  1086. Examples
  1087. --------
  1088.  
  1089. The following three examples are typical COMENT records taken from  an
  1090. object module generated by the Microsoft C Compiler.
  1091.  
  1092. This first example is a language-translator comment:
  1093.  
  1094.         0  1  2  3  4  5  6  7  8  9  A B C D E  F 
  1095.  0000   88 07 00 00 00 4D 53 20 43 6E              .....MS Cn
  1096.                                                 
  1097. Byte 00H contains 88H, indicating that this is a COMENT record.
  1098.  
  1099. Bytes 01-02H contain 0007H, the length of the remainder of the record.
  1100.  
  1101. Byte  03H (the Comment Type field ) contains 00H. Bit 7 (no purge)  is
  1102. set  to  0, indicating that this COMENT record may be purged from  the
  1103. object  module  by a utility program that manipulates object  modules.
  1104. Bit 6 (no list) is set to 0, indicating that this comment need not  be
  1105. excluded from any listing of the module's contents. The remaining bits
  1106. are all 0.
  1107.  
  1108. Byte 04H (the Comment Class field) contains 00H, indicating that this
  1109. COMENT record contains the name of the language translator that
  1110. generated the object module.
  1111.  
  1112. Bytes 05H through 08H contain the name of the language  translator,
  1113. Microsoft C.
  1114.  
  1115. Byte 09H contains the Checksum field, 6EH.
  1116.  
  1117.  
  1118. The second example contains the name of an object library to be
  1119. searched bydefault when LINK processes the object module containing
  1120. this COMENT record:
  1121.  
  1122.         0  1  2  3  4  5  6  7  8  9  A  B  C D E F  
  1123.    0000 88 09 00 00 9F 53 4C 49 42 46 50 10        .....SLIBFP
  1124.  
  1125. Byte 04H (the Comment Class field) contains 9FH, indicating that this
  1126. record contains the name of a library for LINK to use to resolve
  1127. external references.
  1128.  
  1129. Bytes 05-0AH contain the library name, SLIBFP. In this example,  the
  1130. name refers to the Microsoft C Compiler's floating-point function
  1131. library, SLIBFP.LIB.
  1132.  
  1133. The last example indicates that LINK should write the most recent
  1134. format of CodeView information to the executable file.
  1135.  
  1136.       0  1  2  3  4  5  6  7   8  9  A  B   C  D   E  F  
  1137. 0000  88 06 00 00 A1 01 43 56  37                        .....CV7
  1138.  
  1139. Byte 04H indicates the comment class, 0A1H.
  1140.  
  1141. Bytes 05-07H, which contain the comment string, are ignored by LINK.
  1142.  
  1143.  
  1144. 88H IMPDEF--Import Definition Record (Comment Class A0, Subtype 01)
  1145. ===================================================================
  1146.  
  1147. Description
  1148. -----------
  1149.  
  1150. This record describes the imported names for a module.
  1151.  
  1152. History
  1153. -------
  1154.  
  1155. This comment class and subtype is a Microsoft extension added for OS/2
  1156. and Windows.
  1157.  
  1158. Record Format
  1159. -------------
  1160.  
  1161. One import symbol is described; the subrecord format is
  1162.                                                
  1163.    1      1        <variable>   <variable>       2 or <variable>
  1164.    01     Ordinal  Internal     Module           Entry
  1165.           Flag     Name         Name             Ident
  1166.  
  1167. where:
  1168.    
  1169.    01              Identifies the subtype as an IMPDEF. It
  1170.                    determines the form of the Entry Ident field.
  1171.                    
  1172.    
  1173.    Ordinal Flag    Is a byte; if 0, the import is identified by
  1174.                    name. If nonzero, it is identified by ordinal. It
  1175.                    determines the form of the Entry Ident field.
  1176.                    
  1177.    Internal Name   Is in <count, char> string format and is the name
  1178.                    used within this module for the import symbol.
  1179.                    This name will occur again in an EXTDEF record.
  1180.                    
  1181.    Module Name     Is in <count, char> string format and is the name
  1182.                    of the module (a DLL) that supplies an export
  1183.                    symbol matching this import.
  1184.                    
  1185.    Entry Ident     Is an ordinal or the name used by the exporting
  1186.                    module for the symbol, depending upon the Ordinal
  1187.                    Flag.
  1188.                    
  1189.                    If this field is an ordinal (Ordinal Flag is
  1190.                    nonzero), it is a 16-bit word. If this is a name
  1191.                    and the first byte of the name is 0, then the
  1192.                    exported name is the same as the imported name
  1193.                    (in the Internal Name field). Otherwise, it is
  1194.                    the imported name in <count, char> string format
  1195.                    (as exported by Module Name).
  1196.                    
  1197.     
  1198.     NOTE: IMPDEF records are created by the utility IMPLIB, which
  1199.     builds an "import library" from a module definition file or DLL.
  1200.  
  1201. 88H EXPDEF--EXPORT DEFINITION RECORD (COMMENT CLASS A0, SUBTYPE 02)
  1202. ===================================================================
  1203.  
  1204. Description
  1205. -----------
  1206.    
  1207. This record describes the exported names for a module.
  1208.      
  1209. History
  1210. -------
  1211.  
  1212. This comment class and subtype is a Microsoft extension added for C
  1213. version 5.1.
  1214.  
  1215. Record Format
  1216. -------------
  1217.  
  1218. One exported entry point is described; the subrecord format is
  1219.  
  1220.    1      1        <variable>   <variable>       2
  1221.    02     Exported Exported     Internal         Export
  1222.           Flag     Name         Name             Ordinal
  1223.                                                  <conditional>
  1224.  
  1225. where:
  1226.  
  1227.   02                  Identifies the subtype as an EXPDEF.
  1228.                       
  1229.   Exported Flag       Is a bit-significant 8-bit field with the
  1230.                       following format:
  1231.  
  1232.        <-----------------------1 byte---------------------------->
  1233.        Ordinal  Resident    No           Parm Count
  1234.        Bit      Name        Data         
  1235.        1        1           1            <---------5 bits------->
  1236.  
  1237.  
  1238.          Ordinal Bit  Is set if the item is exported by ordinal; in
  1239.                       this case the Export Ordinal field is present.
  1240.                       
  1241.          Resident     Is set if the exported name is to be kept
  1242.          Name         resident by the system loader; this is an
  1243.                       optimization for frequently used items
  1244.                       imported by name.
  1245.                       
  1246.          No Data      Is set if the entry point does not use
  1247.                       initialized data (either instanced or global).
  1248.                       
  1249.          Parm Count   Is the number of parameter words. The Parm
  1250.                       Count field is set to 0 for all but callgates
  1251.                       to 16-bit segments.
  1252.                       
  1253.    Exported Name   Is in <count, char> string format. Name to be
  1254.                    used when the entry point is imported by name.
  1255.                    
  1256.    Internal Name   Is in <count, char> string format. If the name
  1257.                    length is 0, the internal name is the same as the
  1258.                    Exported Name field. Otherwise, it is the name by
  1259.                    which the entry point is known within this
  1260.                    module. This name will appear as a PUBDEF or
  1261.                    LPUBDEF name.
  1262.                    
  1263.    Export Ordinal  Is present if the Ordinal Bit field is set; it is
  1264.                    a 16-bit numeric field whose value is the ordinal
  1265.                    used (must be nonzero).
  1266.                    
  1267.           
  1268.   NOTES
  1269.   
  1270.   EXPDEFs are produced by Microsoft compilers when the keyword _export
  1271.   is used in a source file.
  1272.   
  1273.   Microsoft LINK limits the value of the Export Ordinal field to
  1274.   16,384 bytes (16K) or less.
  1275.  
  1276.  
  1277. 88H INCDEF--INCREMENTAL COMPILATION RECORD
  1278. (COMMENT CLASS A0, SUBTYPE 03)
  1279. ==========================================
  1280.  
  1281. Description
  1282. -----------
  1283.  
  1284. This record is used for incremental compilation. Every FIXUPP and
  1285. LINNUM record following an INCDEF record will adjust all external
  1286. index values and line number values by the appropriate delta. The
  1287. deltas are cumulative if there is more than one INCDEF record per
  1288. module.
  1289.  
  1290. History
  1291. -------
  1292.  
  1293. This comment class subtype is a Microsoft extension added for QuickC
  1294. version 2.0.
  1295.  
  1296. Record Format
  1297. -------------
  1298.  
  1299. The subrecord format is:
  1300.  
  1301.    1      2        2            <variable>
  1302.    03     EXTDEF   LINNUM       Padding
  1303.           Delta    Delta        
  1304.  
  1305. The EXTDEF Delta and LINNUM Delta fields are signed.
  1306.  
  1307. Padding (zeros) is added by QuickC to allow for expansion of the
  1308. object module during incremental compilation and linking.
  1309.   
  1310.   NOTE: Negative deltas are allowed.
  1311.  
  1312.  
  1313. 88H LNKDIR--C++ DIRECTIVES RECORD (COMMENT CLASS A0, SUBTYPE 05)
  1314. =================================-------------------------------
  1315.  
  1316. Description
  1317. -----------
  1318.  
  1319. This record is used by the compiler to pass directives and flags to
  1320. the linker.
  1321.  
  1322. History
  1323. -------
  1324.  
  1325. This comment class and subtype is a Microsoft extension added for C
  1326. 7.0.
  1327.  
  1328. Record Format
  1329. -------------
  1330.  
  1331. The subrecord format is:
  1332.  
  1333.    1      1        1                1
  1334.    05     Bit      Pseudocode       CodeView
  1335.           Flags    Version          Version
  1336.  
  1337. Bit Flags Field
  1338. ---------------
  1339.  
  1340. The format of the Bit Flags byte is:
  1341.  
  1342.    8   1    1    1    1    1    1       1         1 (bits)
  1343.    05  0    0    0    0    0    Run     Omit      New
  1344.                                 MPC     CodeView  .EXE
  1345.                                         $PUBLICS
  1346.  
  1347. The low-order bit, if set, indicates that LINK should output the new
  1348. .EXE format; this flag is ignored for all but linking of pseudocode (p-
  1349. code) applications. (Pseudocode requires a segmented executable.)
  1350.  
  1351. The second low-order bit indicates that LINK should not output the
  1352. $PUBLICS subsection of the CodeView information.
  1353.  
  1354. The third low-order bit indicates that MPC (the Make Pseudocode
  1355. utility) should be run.
  1356.  
  1357. Pseudocode Version Field
  1358. ------------------------
  1359.  
  1360. This field is one byte indicating the pseudocode interpreter version
  1361. number.
  1362.  
  1363. CodeView Version Field
  1364. ----------------------
  1365.  
  1366. This field is one byte indicating the CodeView version number.
  1367.  
  1368.   NOTE: The presence of this record in an object module will indicate
  1369.   the presence of global symbols records. The linker will not emit a
  1370.   $PUBLICS section for those modules with this comment record and a
  1371.   $SYMBOLS section.
  1372.  
  1373.  
  1374. 88H LIBMOD--LIBRARY MODULE NAME RECORD (COMMENT CLASS A3)
  1375. =========================================================
  1376.  
  1377. Description
  1378. -----------
  1379.  
  1380. The LIBMOD comment record is used only by the LIB utility, not by
  1381. LINK. It gives the name of an object module within a library, allowing
  1382. LIB to preserve the source filename in the THEADR record and still
  1383. identify the module names that make up the library. Since the module
  1384. name is the base name of the .OBJ file that was built into the
  1385. library, it may be completely different from the final library name.
  1386.  
  1387. History
  1388. -------
  1389.  
  1390. This comment class and subtype is a Microsoft extension added for LIB
  1391. version 3.07 in MASM version 5.0.
  1392.  
  1393. Record Format
  1394. -------------
  1395.  
  1396. The subrecord format is:
  1397.  
  1398.    1      <variable>
  1399.    A3     Module Name
  1400.  
  1401. The record contains only the ASCII string of the module name, in
  1402. <count, char> format. The module name has no path and no extension,
  1403. just the base of the module name.
  1404.  
  1405.   NOTES
  1406.   
  1407.   LIB adds a LIBMOD record when an .OBJ file is added to a library and
  1408.   strips the LIBMOD record when an .OBJ file is removed from a
  1409.   library, so typically this record exists only in .LIB files.
  1410.   
  1411.   There will be one LIBMOD record in the library file for each object
  1412.   module that was combined to build the library.
  1413.   
  1414.   
  1415. 88H EXESTR--EXECUTABLE STRING RECORD (COMMENT CLASS A4)
  1416. =======================================================
  1417.  
  1418. Description
  1419. -----------
  1420.  
  1421. The EXESTR comment record implements these ANSI and XENIX/UNIX
  1422. features in C:
  1423.  
  1424.    #pragma comment(exestr, <char-sequence>)
  1425.    #ident string
  1426.  
  1427. History
  1428. -------
  1429.  
  1430. This comment class and subtype is a Microsoft extension added for C
  1431. 5.1.
  1432.  
  1433. Record Format
  1434. -------------
  1435.  
  1436. The subrecord format is:
  1437.  
  1438.    1      <variable>
  1439.    A4     Arbitrary Text
  1440.  
  1441. The linker will copy the text in the Arbitrary Text field byte for
  1442. byte to the end of the executable file. The text will not be included
  1443. in the program load image.
  1444.   
  1445.   NOTE: If CodeView information is present, the text will not be at
  1446.   the end of the file but somewhere before so as not to interfere with
  1447.   the CodeView signature.
  1448.   
  1449.   There is no limit to the number of EXESTR comment records.
  1450.   
  1451.   
  1452. 88H INCERR--INCREMENTAL COMPILATION ERROR (COMMENT CLASS A6)
  1453. ============================================================
  1454.  
  1455. Description
  1456. -----------
  1457.  
  1458. This comment record will cause the linker to terminate with a fatal
  1459. error similar to "invalid object--error encountered during incremental
  1460. compilation."
  1461.  
  1462. This behavior is useful when an incremental compilation fails and the
  1463. user tries to link manually. The object module cannot be deleted, in
  1464. order to preserve the base for the next incremental compilation.
  1465.  
  1466. History
  1467. -------
  1468.  
  1469. This comment class and subtype is a Microsoft extension added for
  1470. QuickC 2.0.
  1471.  
  1472. Record Format
  1473. -------------
  1474.  
  1475. The subrecord format is:
  1476.  
  1477.    1      
  1478.    A6     No Fields
  1479.  
  1480.  
  1481. 88H NOPAD--NO SEGMENT PADDING (COMMENT CLASS A7)
  1482. ================================================
  1483.  
  1484. Description
  1485. -----------
  1486.  
  1487. This comment record identifies a set of segments that are to be
  1488. excluded from the padding imposed with the /PADDATA or /PADCODE
  1489. options.
  1490.  
  1491. History
  1492. -------
  1493.  
  1494. This comment class and subtype is a Microsoft extension added for
  1495. COBOL. It was added to LINK to support MicroFocus COBOL version 1.2;
  1496. it was added permanently in LINK version 5.11 to support Microsoft
  1497. COBOL version 3.0.
  1498.  
  1499. Record Format
  1500. -------------
  1501.  
  1502. The subrecord format is:
  1503.  
  1504.    1      1 or 2
  1505.    A7     SEGDEF Index
  1506.           <---------repeated---------->
  1507.  
  1508. The SEGDEF Index field is the standard OMF index type of 1 or 2 bytes.
  1509. It may be repeated.
  1510.  
  1511.  
  1512. 88H WKEXT--WEAK EXTERN RECORD (COMMENT CLASS A8)
  1513. ================================================
  1514.  
  1515. Description
  1516. -----------
  1517.  
  1518. This record marks a set of external names as "weak," and for every
  1519. weak extern, the record associates another external name to use as the
  1520. default resolution.
  1521.  
  1522. History
  1523. -------
  1524.  
  1525. This comment class and subtype is a Microsoft extension added for
  1526. Basic version 7.0. There is no construct in Basic that produces it,
  1527. but the record type is manually inserted into Basic library modules.
  1528.  
  1529. The first user-accessible construct to produce a weak extern was added
  1530. for MASM version 6.0.
  1531.  
  1532. See the "Notes" section below for details on how and why this record
  1533. is used in Basic and MASM.
  1534.  
  1535. Record Format
  1536. -------------
  1537.  
  1538. The subrecord format is:
  1539.  
  1540.    1      1 or 2      1 or 2
  1541.    A8     Weak EXTDEF Default Resolution
  1542.           Index       EXTDEF Index
  1543.           <------------repeated------------>
  1544.  
  1545. The Weak EXTDEF Index field is the 1- or 2-byte index to the EXTDEF of
  1546. the extern that is weak.
  1547.  
  1548. The Default Resolution EXTDEF Index field is the 1- or 2-byte index to
  1549. the EXTDEF of the extern that will be used to resolve the extern if no
  1550. "stronger" link is found to resolve it.
  1551.   
  1552.   NOTES
  1553.   
  1554.   There are two ways to cancel the "weakness" of a weak extern; both
  1555.   result in the extern becoming a "strong" extern (the same as an
  1556.   EXTDEF). They are:
  1557.   
  1558.     -If a PUBDEF for the weak extern is linked in
  1559.     -If an EXTDEF for the weak extern is found in another module
  1560.      (including libraries)
  1561.   
  1562.   If a weak extern becomes strong, then it must be resolved with a
  1563.   matching PUBDEF, just like a regular EXTDEF. If a weak extern has
  1564.   not become strong by the end of the linking process, then the
  1565.   default resolution is used.
  1566.   
  1567.   If two weak externs for the same symbol in different modules have
  1568.   differing default resolutions, LINK will emit a warning.
  1569.   
  1570.   Weak externs do not query libraries for resolution; if an extern is
  1571.   still weak when libraries are searched, it stays weak and gets the
  1572.   default resolution. However, if a library module is linked in for
  1573.   other reasons (say, to resolve strong externs) and there are EXTDEFs
  1574.   for symbols that were weak, the symbols become strong.
  1575.   
  1576.   For example, suppose there is a weak extern for "var" with a default
  1577.   resolution name of "con". If there is a PUBDEF for "var" in some
  1578.   library module that would not otherwise be linked in, then the
  1579.   library module is not linked in, and any references to "var" are
  1580.   resolved to "con". However, if the library module is linked in for
  1581.   other reasons--for example, to resolve references to a strong extern
  1582.   named "bletch"-- then "var" will be resolved by the PUBDEF from the
  1583.   library, not to the default resolution "con".
  1584.   
  1585.   WKEXTs are best understood by explaining why they were added in the
  1586.   first place. The minimum Basic run-time library in the past
  1587.   consisted of a large amount of code that was always linked in, even
  1588.   for the smallest program. Most of this code was never called
  1589.   directly by the user, but it was called indirectly from other
  1590.   routines in other libraries, so it had to be linked in to resolve
  1591.   the external references.
  1592.   
  1593.   For instance, the floating-point library was linked in even if the
  1594.   user's program did not use floating-point operations, because the
  1595.   PRINT library routine contained calls to the floating-point library
  1596.   for support to print floating-point numbers.
  1597.   
  1598.   The solution was to make the function calls between the libraries
  1599.   into weak externals, with the default resolution set to a small stub
  1600.   routine. If the user never used a language construct or feature that
  1601.   needed the additional library support, then no strong extern would
  1602.   be generated by the compiler and the default resolution (to the stub
  1603.   routine) would be used. However, if the user accessed the library's
  1604.   routines or used constructs that required the library's support, a
  1605.   strong extern would be generated by the compiler to cancel the
  1606.   effect of the weak extern, and the library module would be linked
  1607.   in. This required that the compiler know a lot about which libraries
  1608.   are needed for which constructs, but the resulting executable was
  1609.   much smaller.
  1610.   
  1611.   The construct in MASM 6.0 that produces a weak extern is
  1612.   
  1613.       EXTERN var(con): byte
  1614.   
  1615.   which makes "con" the default resolution for weak extern "var".
  1616.  
  1617. **********
  1618. Document 3
  1619. **********
  1620.  
  1621. 88H LZEXT--LAZY EXTERN RECORD (COMMENT CLASS A9)
  1622. ================================================
  1623.  
  1624. Description
  1625. -----------
  1626.  
  1627. This record marks a set of external names as "lazy," and for every
  1628. lazy extern, the record associates another external name to use as the
  1629. default resolution.
  1630.  
  1631. History
  1632. -------
  1633.  
  1634. This comment class and subtype is a Microsoft extension added for C
  1635. 7.0, but was not implemented in the C 7.0 linker.
  1636.  
  1637. Record Format
  1638. -------------
  1639.  
  1640. The subrecord format is:
  1641.  
  1642.    1      1 or 2           1 or 2
  1643.    A9     Lazy EXTDEF      Default Resolution
  1644.           Index            EXTDEF Index
  1645.           <---------------repeated------------->
  1646.  
  1647. The Lazy EXTDEF Index field is the 1- or 2-byte index to the EXTDEF of
  1648. the extern that is lazy.
  1649.  
  1650. The Default Resolution EXTDEF Index field is the 1- or 2-byte index to
  1651. the EXTDEF of the extern that will be used to resolve the extern if no
  1652. "stronger" link is found to resolve it.
  1653.   
  1654.   NOTES
  1655.   
  1656.   There are two ways to cancel the "laziness" of a lazy extern; both
  1657.   result in the extern becoming a "strong" extern (the same as an
  1658.   EXTDEF.) They are:
  1659.   
  1660.     - If a PUBDEF for the lazy extern is linked in
  1661.     - If an EXTDEF for the lazy extern is found in another module
  1662.       (including libraries)
  1663.   
  1664.   If a lazy extern becomes strong, it must be resolved with a matching
  1665.   PUBDEF, just like a regular EXTDEF. If a lazy extern has not become
  1666.   strong by the end of the linking process, then the default
  1667.   resolution is used.
  1668.   
  1669.   If two weak externs for the same symbol in different modules have
  1670.   differing default resolutions, LINK will emit a warning.
  1671.   
  1672.   Unlike weak externs, lazy externs do query libraries for resolution;
  1673.   if an extern is still lazy when libraries are searched, it stays
  1674.   lazy and gets the default resolution.
  1675.   
  1676. 88H PHARLAP FORMAT RECORD (COMMENT CLASS AA)
  1677. ============================================
  1678.  
  1679. Description
  1680. -----------
  1681.  
  1682. The OMF extension designed by PharLap is called "Easy OMF-386."
  1683. Changes to the affected record types are described in this section.
  1684.  
  1685. Most modifications involve only a substitution of 32-bit (4-byte)
  1686. fields for what were formerly 16-bit (2-byte) fields. In the two cases
  1687. where the changes involve more than just a field size (in the SEGDEF
  1688. and FIXUPP records), the information is mentioned in this section, but
  1689. complete details are given in the sections describing the specific
  1690. records.
  1691.  
  1692. History
  1693. -------
  1694.  
  1695. This format is described as "obsolete" in the expectation that
  1696. negotiations between Microsoft and PharLap will result in convergence
  1697. to the new "standard." However, its obsolescence needs to be verified.
  1698. When the new standard is agreed upon, Microsoft encourages you to
  1699. adopt it.
  1700.  
  1701. Record Format
  1702. -------------
  1703.  
  1704. The format of the comment's subrecord is:
  1705.  
  1706.    AA     "80386"
  1707.      
  1708.      
  1709.   NOTES
  1710.   
  1711.   The AA comment record should come immediately after the sole THEADR
  1712.   record. Presence of the comment record indicates that the following
  1713.   other record types have fields that are expanded from 16-bit to 32-
  1714.   bit values:
  1715.   
  1716.      SEGDEF Offset field and Segment Length field
  1717.  
  1718.      PUBDEF Public Offset field
  1719.  
  1720.      LEDATA Enumerated Data Offset field
  1721.  
  1722.      LIDATA Iterated Data Offset field (note that the Repeat Count
  1723.             field is still 16 bits)
  1724.  
  1725.      FIXUPP Target Displacement field in an explicit FIXUP subrecord
  1726.  
  1727.      BLKDEF Return Address Offset field
  1728.  
  1729.      LINNUM Line Number Offset field
  1730.  
  1731.      MODEND Target Displacement field
  1732.  
  1733.   FIXUPP records have the added LOCATION values of 5 and 6, which
  1734.   conflict with the Microsoft 32-bit extensions to this field. See the
  1735.   FIXUPP section of this document for details.
  1736.   
  1737.   SEGDEF records have added alignment values (for 4-byte alignment and
  1738.   4K alignment) and an added optional byte at the end that contains
  1739.   the Use16/Use32 bit flag and access attributes (read/write/execute)
  1740.   for the segment. The alignment values are the same as Microsoft's 32-
  1741.   bit extensions to the field, but the attributes stored in the added
  1742.   byte conflict with Microsoft's way of specifying those attributes.
  1743.   See the SEGDEF sectionof this document for details.
  1744.   
  1745.   
  1746. 8AH OR 8BH MODEND--MODULE END RECORD
  1747. ====================================
  1748.  
  1749. Description
  1750. -----------
  1751.  
  1752. The MODEND record denotes the end of an object module. It also
  1753. indicates whether the object module contains the main routine in a
  1754. program, and it can optionally contain a reference to a program's
  1755. entry point.
  1756.  
  1757. History
  1758. -------
  1759.  
  1760. Record type 8BH is new for LINK386; it has a Target Displacement field
  1761. of 32 bits rather than 16 bytes.
  1762.  
  1763. An IBM extension to this record type (initial values for segment
  1764. registers) was proposed for LINK386 but was never implemented.
  1765.  
  1766. Record Format
  1767. -------------
  1768.    
  1769.   1  2       1      1         1 or 2  1 or 2   2 or 4     1
  1770.  8A  Record  Module End Data  Frame   Target   Target     Checksum
  1771.   or Length  Type             Datum   Datum    Displace-  
  1772.  8B                                            ment
  1773.                     <-Start Address subfield, conditional->
  1774.  
  1775. where:
  1776.    
  1777.    Module Type Field
  1778.    
  1779.    The Module Type byte is bit significant; its layout is
  1780.    
  1781.       MATTR         Segment                                      
  1782.       Main  Start   Bit      0          0       0       0       X
  1783.       <--2 bits-->                                  
  1784.  
  1785.   where:
  1786.  
  1787.       MATTR           Is a 2-bit field.
  1788.                       
  1789.       Main            Is set if the module is a main program
  1790.                       module.
  1791.                       
  1792.       Start           Is set if the module contains a start
  1793.                       address; if this bit is set, the field
  1794.                       starting with the End Data byte is present
  1795.                       and specifies the start address.
  1796.                       
  1797.       Segment Bit     Is reserved by IBM. Only 0 is supported by
  1798.                       MS-DOS and OS/2.
  1799.                       
  1800.       X               Is set if the Start Address subfield
  1801.                       contains a relocatable address reference
  1802.                       that LINK must fix up. (The Intel
  1803.                       specification allows this bit to be 0, to
  1804.                       indicate that the start address is an
  1805.                       absolute physical address that is stored as
  1806.                       a 16-bit frame number and 16-bit offset,
  1807.                       but this capability is not supported by
  1808.                       LINK.) This bit should always be set;
  1809.                       however, the value will be ignored.
  1810.                       
  1811.       Start Address   The Start Address subfield is present only
  1812.                       if the Start bit in the Module Type byte is
  1813.                       set. Its format is identical to the Fix
  1814.                       Data, Frame Datum, Target Datum, and Target
  1815.                       Displacement fields in a FIXUP subrecord of
  1816.                       a FIXUPP record. Bit 2 of the End Data
  1817.                       field, which corresponds to the P bit in a
  1818.                       Fix Data field, must be 0. The Target
  1819.                       Displacement field (if present) is a 4-byte
  1820.                       field if the record type is 8BH and a 2-
  1821.                       byte field otherwise. This value provides
  1822.                       the initial contents of CS:(E)IP.
  1823.                       
  1824.                       If overlays are used, the start address
  1825.                       must be given in the MODEND record of the
  1826.                       root module.
  1827.                       
  1828.   
  1829.   NOTES
  1830.   
  1831.   A MODEND record can appear only as the last record in an object
  1832.   module.
  1833.   
  1834.   It is assumed that the Link Pass Separator comment record (COMENT
  1835.   A2, subtype 01) will not be present in a module whose MODEND record
  1836.   contains a program starting address. If there are overlays, LINK
  1837.   needs to see the starting address on Pass 1 to define the symbol
  1838.   $$MAIN.
  1839.  
  1840. Examples
  1841. --------
  1842.  
  1843. Consider the MODEND record of a simple HELLO.ASM program:
  1844.  
  1845.        0  1   2  3   4  5   6  7   8  9 A B C D E F 
  1846.   0000 8A 07  00 C1  00 01  01 00  00                AC.....
  1847.  
  1848. Byte 00H contains 8AH, indicating a MODEND record.
  1849.  
  1850. Bytes 01-02H contain 0007H, the length of the remainder of the record.
  1851.  
  1852. Byte 03H contains 0C1H (11000001B). Bit 7 is set to 1, indicating that
  1853. this module is the main module of the program. Bit 6 is set to 1,
  1854. indicating that a Start Address subfield is present. Bit 0 is set to
  1855. 1, indicating that the address referenced in the Start Address
  1856. subfield must be fixed up by LINK.
  1857.  
  1858. Byte 04H (End Data in the Start Address subfield) contains 00H. As in
  1859. a FIXUPP record, bit 7 indicates that the frame for this fixup is
  1860. specified explicitly, and bits 6 through 4 indicate that a SEGDEF
  1861. index specifies the frame. Bit 3 indicates that the target reference
  1862. is also specified explicitly, and bits 2 through 0 indicate that a
  1863. SEGDEF index also specifies the target. See also "9CH or 9DH FIXUPP--
  1864. Fixup Record" in this document.
  1865.  
  1866. Byte 05H (Frame Datum in the Start Address subfield) contains 01H.
  1867. This is a reference to the first SEGDEF record in the module, which in
  1868. this example corresponds to the _TEXT segment. This reference tells
  1869. LINK that the start address lies in the _TEXT segment of the module.
  1870.  
  1871. Byte 06H (Target Datum in the Start Address subfield) contains 01H.
  1872. This also is a reference to the first SEGDEF record in the object
  1873. module, which corresponds to the _TEXT segment. LINK uses the
  1874. following Target Displacement field to determine where in the _TEXT
  1875. segment the address lies.
  1876.  
  1877. Bytes 07-08H (Target Displacement in the Start Address subfield)
  1878. contain 0000H. This is the offset (in bytes) of the start address.
  1879.  
  1880. Byte 09H contains the Checksum field, 0ACH.
  1881.  
  1882.  
  1883. 8CH EXTDEF--EXTERNAL NAMES DEFINITION RECORD
  1884. ============================================
  1885.  
  1886. Description
  1887. -----------
  1888.  
  1889. The EXTDEF record contains a list of symbolic external references--
  1890. that is, references to symbols defined in other object modules. The
  1891. linker resolves external references by matching the symbols declared
  1892. in EXTDEF records with symbols declared in PUBDEF records.
  1893.  
  1894. History
  1895. -------
  1896.  
  1897. In the Intel specification and older linkers, the Type Index field was
  1898. used as an index into TYPDEF records. This is no longer true; the
  1899. field now encodes CodeView type information (see Appendix 1 for
  1900. details.) LINK ignores the old style TYPDEF.
  1901.  
  1902. Record Format
  1903. -------------
  1904.    
  1905.    1      2       1       <String Length>   1 or 2      1
  1906.    8C     Record  String  External          Type Index  Checksum
  1907.           Length  Length  Name String                   
  1908.  
  1909. This record provides a list of unresolved references, identified by
  1910. name and with optional associated type information. The external names
  1911. are ordered by occurrence jointly with the COMDEF and LEXTDEF records,
  1912. and referenced by an index in other records (FIXUPP records); the name
  1913. may not be null. Indexes start from 1.
  1914.  
  1915. String Length is a 1-byte field containing the length of the name
  1916. field that follows it. LINK restricts the name length to a value
  1917. between 1 and 7FH.
  1918.  
  1919. The Type Index field is encoded as an index field and contains
  1920. proprietary CodeView-type information. At this time, the linker does
  1921. not perform any type checking.
  1922.   
  1923.   NOTES
  1924.   
  1925.   For Microsoft compilers, all referenced functions of global scope
  1926.   and all referenced variables explicitly declared "extern" will
  1927.   generate an EXTDEF record.
  1928.   
  1929.   LINK imposes a limit of 1023 external names.
  1930.   
  1931.   Any EXTDEF records in an object module must appear before the FIXUPP
  1932.   records that reference them.
  1933.   
  1934.   Resolution of an external reference is by name match (case
  1935.   sensitive) and symbol type match. The search looks for a matching
  1936.   name in the following sequence:
  1937.     
  1938.    1. Searches PUBDEF and COMDEF records.
  1939.    
  1940.    2.  If linking a segmented executable, searches imported names
  1941.       (IMPDEF).
  1942.    
  1943.    3. If linking a segmented executable and not a DLL, searches for an
  1944.       exported name (EXPDEF) with the same name--a self-imported
  1945.       alias.
  1946.    
  1947.    4. Searches for the symbol name among undefined symbols. If the
  1948.       reference is to a weak extern, the default resolution is used.
  1949.       If the reference is to a strong extern, it's an undefined
  1950.       external, and LINK generates an error.
  1951.   
  1952.   All external references must be resolved at link time (using the
  1953.   above search order). Even though LINK produces an executable file
  1954.   for an unsuccessful link session, an error bit is set in the header
  1955.   that prevents the loader from running the executable.
  1956.  
  1957. Examples
  1958. --------
  1959.  
  1960. Consider this EXTDEF record generated by the Microsoft C Compiler:
  1961.  
  1962.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F 
  1963. 0000 8C 25 00 0A 5F 5F 61 63 72 74 75 73 65 64 00 05 .%.__acrtused..
  1964. 0010 5F 6D 61 69 6E 00 05 5F 70 75 74 73 00 08 5F 5F _main.._puts..__ 
  1965. 0020 63 68 6B 73 74 6B 00 A5                         chkstk..                      
  1966.  
  1967. Byte 00H contains 8CH, indicating that this is an EXTDEF record.
  1968.  
  1969. Bytes 01-02H contain 0025H, the length of the remainder of the record.
  1970.  
  1971. Bytes 03-26H contain a list of external references. The first
  1972. reference starts in byte 03H, which contains 0AH, the length of the
  1973. name __acrtused. The name itself follows in bytes 04-0DH. Byte 0EH
  1974. contains 00H, which indicates that the symbol's type is not defined by
  1975. any TYPDEF record in this object module. Bytes 0F-26H contain similar
  1976. references to the external symbols _main, _puts, and __chkstk.
  1977.  
  1978. Byte 27H contains the Checksum field, 0A5H.
  1979.  
  1980.  
  1981. 8EH TYPDEF--TYPE DEFINITION RECORD
  1982. ==================================
  1983.  
  1984. Description
  1985. -----------
  1986.  
  1987. The TYPDEF record contains details about the type of data represented
  1988. by a name declared in a PUBDEF or an EXTDEF record. This information
  1989. may be used by a linker to validate references to names, or it may be
  1990. used by a debugger to display data according to type.
  1991.  
  1992. Although the original Intel specification allowed for many different
  1993. type specifications, such as scalar, pointer, and mixed data
  1994. structure, LINK used TYPDEF records to declare only communal
  1995. variables. Communal variables represent globally shared memory areas--
  1996. for example, FORTRAN common blocks or uninitialized public variables
  1997. in C.
  1998.  
  1999. The size of a communal variable is declared explicitly in the TYPDEF
  2000. record. If a communal variable has different sizes in different object
  2001. modules, LINK uses the largest declared size when it generates an
  2002. executable module.
  2003.  
  2004. History
  2005. -------
  2006.  
  2007. Starting with Microsoft LINK version 3.5, the COMDEF record should be
  2008. used for declaration of communal variables. However, for
  2009. compatibility, later versions of LINK recognize TYPDEF records as well
  2010. as COMDEF records.
  2011.  
  2012. Record Format
  2013. -------------
  2014.    
  2015.    1   2          <variable>     1       <variable>  1
  2016.    8E  Record     Name           0       Leaf        Checksum
  2017.        Length                    (EN)    Descriptor  
  2018.  
  2019. The name field of a TYPDEF record is in <count, char> format and is
  2020. always ignored. It is usually a 1-byte field containing a single 0
  2021. byte.
  2022.  
  2023. The Eight-Leaf Descriptor field in the original Intel specification
  2024. was a variable-length (and possibly repeated) field that contained as
  2025. many as eight "leaves" that could be used to describe mixed data
  2026. structures. Microsoft uses a stripped-down version of the Eight-Leaf
  2027. Descriptor, of which the first byte, the EN byte, is always set to 0.
  2028.  
  2029. The Leaf Descriptor field is a variable-length field that describes
  2030. the type and size of a variable. The two possible variable types are
  2031. NEAR and FAR.
  2032.  
  2033. If the field describes a NEAR variable (one that can be referenced as
  2034. an offset within a default data segment), the format of the Leaf
  2035. Descriptor field is:
  2036.  
  2037.    1      1           <variable>
  2038.    62H    Variable    Length in Bits
  2039.           Type
  2040.  
  2041. The 1-byte field containing 62H signifies a NEAR variable.
  2042.  
  2043. The Variable Type field is a 1-byte field that specifies the variable
  2044. type:
  2045.    
  2046.    77H    Array
  2047.    79H    Structure
  2048.    7BH    Scalar
  2049.  
  2050. This field must contain one of the three values given above, but the
  2051. specific value is ignored by LINK.
  2052.  
  2053. The Length in Bits field is a variable-length field that indicates the
  2054. size of the communal variable. Its format depends on the size it
  2055. represents.
  2056.  
  2057. If the first byte of the size is 128 (80H) or less, then the size is
  2058. that value. If the first byte of the size is 81H, then a 2-byte size
  2059. follows. If the first byte of the size is 84H, then a 3-byte size
  2060. follows. If the first byte of the size is 88H, then a 4-byte size
  2061. follows.
  2062.  
  2063. If the Leaf Descriptor field describes a FAR variable (one that must
  2064. be referenced with an explicit segment and offset), the format is:
  2065.  
  2066.    1      1           <variable>          <variable>
  2067.    61H    Variable    Number of Elements  Element Type Index
  2068.           Type (77H)                      
  2069.  
  2070. The 1-byte field containing 61H signifies a FAR variable.
  2071.  
  2072. The 1-byte variable type for a FAR communal variable is restricted to
  2073. 77H (array). (As with the NEAR Variable Type field, LINK ignores this
  2074. field, but it must have the value 77H.)
  2075.  
  2076. The Number of Elements field is a variable-length field that contains
  2077. the number of elements in the array. It has the same format as the
  2078. Length in Bits field in the Leaf Descriptor field for a NEAR variable.
  2079.  
  2080. The Element Type Index field is an index field that references a
  2081. previous TYPDEF record. A value of 1 indicates the first TYPDEF record
  2082. in the object module, a value of 2 indicates the second TYPDEF record,
  2083. and so on. The TYPDEF record referenced must describe a NEAR variable.
  2084. This way, the data type and size of the elements in the array can be
  2085. determined.
  2086.  
  2087.   NOTE: LINK limits the number of TYPDEF records in an object module
  2088.   to 256.
  2089.  
  2090. Examples
  2091. --------
  2092.  
  2093. The following three examples of TYPDEF records were generated by
  2094. Microsoft C Compiler version 3.0. (Later versions use COMDEF records.)
  2095.  
  2096. The first sample TYPDEF record corresponds to the public declaration:
  2097.  
  2098.    int   var;     /* 16-bit integer */
  2099.  
  2100. The TYPDEF record is:
  2101.  
  2102.         0  1   2  3   4  5  6  7  8  9  A  B   C D  E  F  
  2103.   0000  8E 06  00 00  00 62 7B 10 7F                     .....b{..
  2104.  
  2105. Byte 00H contains 8EH, indicating that this is a TYPDEF record.
  2106.  
  2107. Bytes 01-02H contain 0006H, the length of the remainder of the record.
  2108.  
  2109. Byte 03H (the name field) contains 00H, a null name.
  2110.  
  2111. Bytes 04-07H represent the Eight-Leaf Descriptor field. The first byte
  2112. of this field (byte 04H) contains 00H. The remaining bytes (bytes 05-
  2113. 07H) represent the Leaf Descriptor field:
  2114.    
  2115.     - Byte 05H contains 62H, indicating that this TYPDEF record
  2116.       describes a NEAR variable.
  2117.  
  2118.     - Byte 06H (the Variable Type field) contains 7BH, which describes
  2119.       this variable as scalar.
  2120.  
  2121.     - Byte 07H (the Length in Bits field) contains 10H, the size of
  2122.       the variable in bits.
  2123.  
  2124. Byte 08H contains the Checksum field, 7FH.
  2125.  
  2126. The next example demonstrates how the variable size contained in the
  2127. Length in Bits field of the Leaf Descriptor field is formatted:
  2128.  
  2129.    char var2[32768];   /* 32 KB array */
  2130.  
  2131. The TYPDEF record is:
  2132.  
  2133.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  
  2134. 0000 8E 09 00 00 00 62 7B 84 00 00 04 04           .....bc{.....
  2135.  
  2136. The Length in Bits field (bytes 07-0AH) starts with a byte containing
  2137. 84H, which indicates that the actual size of the variable is
  2138. represented as a 3-byte value (the following three bytes). Bytes 08-
  2139. 0AH contain the value 040000H, the size of the 32K array in bits.
  2140.  
  2141. This third C statement, because it declares a FAR variable, causes two
  2142. TYPDEF records to be generated:
  2143.  
  2144.    char far  var3[10][2][20];    /* 400-element FAR array*/
  2145.  
  2146. The two TYPDEF records are:
  2147.  
  2148.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F 
  2149. 0000 8E 06 00 00 62 7B 08 87 8E 09 00 00 00 00 61 77 ....bc{......aw
  2150. 0010 81 90 01 01 7E                                  .....|
  2151.  
  2152. Bytes 00-08H contain the first TYPDEF record, which defines the data
  2153. type of the elements of the array (NEAR, scalar, 8 bits in size).
  2154.  
  2155. Bytes 09-14H contain the second TYPDEF record. The Leaf Descriptor
  2156. field of this record declares that the variable is FAR (byte 0EH
  2157. contains 61H) and an array (byte 0FH, the variable type, contains
  2158. 77H).
  2159.  
  2160.   NOTE: Because this TYPDEF record describes a FAR variable, bytes 10-
  2161.   12H represent a Number of Elements field. The first byte of the
  2162.   field is 81H, indicating a 2-byte value, so the next two bytes
  2163.   (bytes 11-12H) contain the number of elements in the array, 0190H
  2164.   (400D).
  2165.  
  2166. Byte 13H (the Element Type Index field) contains 01H, which is a
  2167. reference to the first TYPDEF record in the object module--in this
  2168. example, the one in bytes 00-08H.
  2169.  
  2170.  
  2171. 90H OR 91H PUBDEF--PUBLIC NAMES DEFINITION RECORD
  2172. =================================================
  2173.  
  2174. Description
  2175. -----------
  2176.  
  2177. The PUBDEF record contains a list of public names. It makes items
  2178. defined in this object module available to satisfy external references
  2179. in other modules with which it is bound or linked.
  2180.  
  2181. The symbols are also available for export if so indicated in an EXPDEF
  2182. comment record.
  2183.  
  2184. History
  2185. -------
  2186.  
  2187. Record type 91H is new for LINK386; it has a Public Offset field of 32
  2188. bits rather than 16 bits.
  2189.  
  2190. Record Format
  2191. -------------
  2192.    
  2193. 1   2       1 or 2 1 or 2   2      1      <String     2 or 4  1 or 2 1
  2194.                        Length>
  2195. --------------------------------------------------------------------------
  2196. 90  Record Base   Base     Base   String  Public      Public  Type  Check
  2197. or  Length Group  Segment  Frame  Length  Name String Offset  Index sum
  2198. 91              
  2199. --------------------------------------------------------------------------
  2200.               <condi <-------------repeated------------------>                
  2201.                tional>
  2202.  
  2203. Base Group, Base Segment, and Base Frame Fields
  2204. -----------------------------------------------
  2205.           
  2206. The Base Group and Base Segment fields are indexes specifying
  2207. previously defined SEGDEF and GRPDEF records. The group index may be
  2208. 0, meaning that no group is associated with this PUBDEF record.
  2209.  
  2210. The Base Frame field is present only if the Base Segment field is 0,
  2211. but the contents of the Base Frame field are always ignored by LINK.
  2212.  
  2213. The segment index is normally nonzero and no Base Frame field is
  2214. present.
  2215.  
  2216. According to the Intel specification, if both the segment and group
  2217. indexes are 0, the Base Frame field contains a 16-bit paragraph (when
  2218. viewed as a linear address); this may be used to define public symbols
  2219. that are absolute. Absolute addressing is not fully supported by LINK-
  2220. -it can be used for read-only access to absolute memory locations;
  2221. however, writing to absolute memory locations may not work in current
  2222. linkers. This feature is so rarely used that it should be considered
  2223. unsupported.
  2224.  
  2225. Public Name String, Public Offset, and Type Index Fields
  2226. --------------------------------------------------------
  2227.           
  2228. The Public Name String field is in <count, char> form and cannot be
  2229. null. Microsoft LINK restricts the maximum length of a public name to
  2230. 255 bytes.
  2231.  
  2232. The Public Offset field is a 2- or 4-byte numeric field containing the
  2233. offset of the location referred to by the public name. This offset is
  2234. assumed to lie within the group, segment, or frame specified in the
  2235. Base Group, Base Segment, or Base Frame fields.
  2236.  
  2237. The Type Index field is encoded in index format; it contains either
  2238. proprietary CodeView-type information or an old-style TYPDEF index. If
  2239. this index is 0, there is no associated type data. Old-style TYPDEF
  2240. indexes are ignored by LINK. Current linkers perform no type checking.
  2241.  
  2242.   NOTES
  2243.   
  2244.   All defined functions and initialized global variables generate
  2245.   PUBDEF records in Microsoft compilers. No PUBDEF record will be
  2246.   generated, however, for instantiated inline functions in C++.
  2247.   
  2248.   Any PUBDEF records in an object module must appear after the GRPDEF
  2249.   and SEGDEF records to which they refer. Because PUBDEF records are
  2250.   not themselves referenced by any other type of object record, they
  2251.   are generally placed near the end of an object module.
  2252.   
  2253.   Record type 90H uses 16-bit encoding of the Public Offset field, but
  2254.   it is zero-extended to 32 bits if applied to Use32 segments.
  2255.  
  2256. Examples
  2257. --------
  2258. The following two examples show PUBDEF records created by MASM.
  2259.  
  2260. The first example is the record for the statement:
  2261.    
  2262.    PUBLIC    GAMMA
  2263.    
  2264. The PUBDEF record is:
  2265.  
  2266.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  
  2267. 0000 90 0C 00 00 01 05 47 41 4D 4D 41 02 00 00 F9  .....GAMMA.....
  2268.  
  2269. Byte 00H contains 90H, indicating a PUBDEF record.
  2270.  
  2271. Bytes 01-02H contain 000CH, the length of the remainder of the record.
  2272.  
  2273. Bytes 03-04H represent the Base Group, Base Segment, and Base Frame
  2274. fields. Byte 03H (the group index) contains 0, indicating that no
  2275. group is associated with the name in this PUBDEF record. Byte 04H (the
  2276. segment index) contains 1, a reference to the first SEGDEF record in
  2277. the object module. This is the segment to which the name in this
  2278. PUBDEF record refers.
  2279.  
  2280. Bytes 05-0AH represent the Public Name String field. Byte 05H contains
  2281. 05H (the length of the name), and bytes 06-0AH contain the name
  2282. itself, GAMMA.
  2283.  
  2284. Bytes 0B-0CH contain 0002H, the Public Offset field. The name GAMMA
  2285. thus refers to the location that is offset two bytes from the
  2286. beginning of the segment referenced by the Base Group, Base Segment,
  2287. and Base Frame fields.
  2288.  
  2289. Byte 0DH is the Type Index field. The value of the Type Index field is
  2290. 0, indicating that no data type is associated with the name GAMMA.
  2291.  
  2292. Byte 0EH contains the Checksum field, 0F9H.
  2293.  
  2294.  
  2295. The next example is the PUBDEF record for the following absolute
  2296. symbol declaration:
  2297.    
  2298.             PUBLIC    ALPHA
  2299.    ALPHA    EQU       1234h
  2300.    
  2301. The PUBDEF record is:
  2302.  
  2303.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  
  2304. 0000 90 0E 00 00 00 00 00 05 41 4C 50 48 41 34 12 00 ...ALPHA4...
  2305. 0010 B1                
  2306.  
  2307. Bytes 03-06H (the Base Group, Base Segment, and Base Frame fields)
  2308. contain a group index of 0 (byte 03H) and a segment index of 0 (byte
  2309. 04H). Since both the group index and segment index are 0, a frame
  2310. number also appears in the Base Group, Base Segment, and Base Frame
  2311. fields. In this instance, the frame number (bytes 05-06H) also happens
  2312. to be 0.
  2313.  
  2314. Bytes 07-0CH (the Public Name String field) contain the name ALPHA,
  2315. preceded by its length.
  2316.  
  2317. Bytes 0D-0EH (the Public Offset field) contain 1234H. This is the
  2318. value associated with the symbol ALPHA in the assembler EQU directive.
  2319. If ALPHA is declared in another object module with the declaration
  2320.  
  2321.    EXTRN     ALPHA:ABS
  2322.  
  2323. any references to ALPHA in that object module are fixed up as absolute
  2324. references to offset 1234H in frame 0. In other words, ALPHA would
  2325. have the value 1234H.
  2326.  
  2327. Byte 0FH (the Type Index field) contains 0.
  2328.  
  2329.  
  2330. 94H OR 95H LINNUM--LINE NUMBERS RECORD
  2331. ======================================
  2332.  
  2333. Description
  2334. -----------
  2335.  
  2336. The LINNUM record relates line numbers in source code to addresses in
  2337. object code.
  2338.  
  2339. For instantiated inline functions in C 7.0, line numbers will be
  2340. output in LINSYM records with a reference to the function name instead
  2341. of the segment.
  2342.  
  2343. History
  2344. -------
  2345.  
  2346. Record type 95H is new for LINK386; it has a Line Number Offset field
  2347. of 32 bits rather than 16 bits.
  2348.  
  2349. Record Format
  2350. -------------
  2351.    
  2352.    1    2      1 or 2  1 or 2     2          2 or 4       1
  2353.    94   Record Base    Base       Line       Line Number  Checksum
  2354.    or   Length Group   Segment    Number     Offset       
  2355.    95
  2356.                                   <--------repeated------>
  2357.  
  2358. Base Group and Base Segment Fields
  2359. ----------------------------------
  2360.  
  2361. The Base Group and Base Segment fields are indexes specifying
  2362. previously defined GRPDEF and SEGDEF records. The Base Group field is
  2363. ignored, and the Base Segment field must be nonzero.
  2364.  
  2365. Although the complete Intel specification allows the Base Group and
  2366. Base Segment fields to refer to a group or to an absolute segment as
  2367. well as to a relocatable segment, Microsoft restricts references in
  2368. this field to relocatable segments.
  2369.  
  2370. Line Number and Line Number Offset Fields
  2371. -----------------------------------------
  2372.  
  2373. The Line Number field is a 16-bit quantity, in the range 0 through
  2374. 7FFF and is, as its name indicates, a line number in the source code.
  2375. The Line Number Offset field is a 2- or 4-byte quantity that gives the
  2376. translated code or data's start byte in the program segment defined by
  2377. the SEGDEF index (4 bytes if the record type is 95H; 2 bytes for type
  2378. 94H).
  2379.  
  2380. The Line Number and Line Number Offset fields can be repeated, so a
  2381. single LINNUM record can specify multiple line numbers in the same
  2382. segment.
  2383.  
  2384. Line Number 0 has a special meaning: it is used for the offset of the
  2385. first byte after the end of the function. This is done so that the
  2386. length of the last line (in bytes) can be determined.
  2387.   
  2388.   NOTES
  2389.   
  2390.   The source file corresponding to a line number group is determined
  2391.   from the THEADR record.
  2392.   
  2393.   Any LINNUM records in an object module must appear after the SEGDEF
  2394.   records to which they refer. Because LINNUM records are not
  2395.   themselves referenced by any other type of object record, they are
  2396.   generally placed near the end of an object module.
  2397.   
  2398.   Also see the INCDEF record of this document, which is used to
  2399.   maintain line numbers after incremental compilation.
  2400.  
  2401. Examples
  2402. --------
  2403.  
  2404. The following LINNUM record was generated by the Microsoft C Compiler:
  2405.  
  2406.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  
  2407. 0000 94 0F 00 00 01 02 00 00 00 03 00 08 00 04 00 0F ...........
  2408. 0010 00 3C                                           ..
  2409.  
  2410. Byte 00H contains 94H, indicating that this is a LINNUM record.
  2411.  
  2412. Bytes 01-02H contain 000FH, the length of the remainder of the record.
  2413.  
  2414. Bytes 03-04H represent the Base Group and Base Segment fields. Byte
  2415. 03H (the Base Group field) contains 00H, as it must. Byte 04H (the
  2416. Base Segment field) contains 01H, indicating that the line numbers in
  2417. this LINNUM record refer to code in the segment defined in the first
  2418. SEGDEF record in this object module.
  2419.  
  2420. Bytes 05-06H (the Line Number field) contain 0002H, and bytes 07-08H
  2421. (the Line Number Offset field) contain 0000H. Together, they indicate
  2422. that source-code line number 0002 corresponds to offset 0000H in the
  2423. segment indicated in the Base Group and Base Segment fields.
  2424.  
  2425. Similarly, the two pairs of Line Number and Line Number Offset fields
  2426. in bytes 09-10H specify that line number 0003 corresponds to offset
  2427. 0008H and that line number 0004 corresponds to offset 000FH.
  2428.  
  2429. Byte 11H contains the Checksum field, 3CH.
  2430.  
  2431. **********
  2432. Document 4
  2433. **********
  2434.  
  2435. 96H LNAMES--LIST OF NAMES RECORD
  2436. ================================
  2437.  
  2438. Description
  2439. -----------
  2440.  
  2441. The LNAMES record is a list of names that can be referenced by
  2442. subsequent SEGDEF and GRPDEF records in the object module.
  2443.  
  2444. The names are ordered by occurrence and referenced by index from
  2445. subsequent records. More than one LNAMES record may appear. The names
  2446. themselves are used as segment, class, group, overlay, and selector
  2447. names.
  2448.  
  2449. History
  2450. -------
  2451.  
  2452. This record has not changed since the original Intel 8086 OMF
  2453. specification.
  2454.  
  2455. Record Format
  2456. -------------
  2457.                                                         
  2458.    1     2             1           <--String Length--> 1
  2459.    96    Record        String      Name String         Checksum
  2460.          Length        Length
  2461.                                                         
  2462.                      <-----------repeated----------->
  2463.  
  2464. Each name appears in <count, char> format, and a null name is valid.
  2465. The character set is ASCII. Names can be up to 254 characters long.
  2466.   
  2467.   NOTE: Any LNAMES records in an object module must appear before the
  2468.   records that refer to them. Because it does not refer to any other
  2469.   type of object record, an LNAMES record usually appears near the
  2470.   start of an object module.
  2471.  
  2472. Examples
  2473. --------
  2474.  
  2475. The following LNAMES record contains the segment and class names
  2476. specified in all three of the following full-segment definitions:
  2477.    
  2478.    _TEXT     SEGMENT byte public 'CODE'
  2479.    _DATA     SEGMENT word public 'DATA'
  2480.    _STACK    SEGMENT para public 'STACK'      
  2481.  
  2482. The LNAMES record is:
  2483.  
  2484.      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  
  2485. 0000 96 25 00 00 04 43 4F 44 45 04 44 41 54 41 05 53 .%...CODE.DATA.S.
  2486. 0010 54 41 43 4B 05 5F 44 41 54 41 06 5F 53 54 41 43 TACK._DATA._STAC
  2487. 0020 4B 05 5F 54 45 58 54 8B                         K._TEXT.
  2488.  
  2489. Byte 00H contains 96H, indicating that this is an LNAMES record.
  2490.  
  2491. Bytes 01-02H contain 0025H, the length of the remainder of the record.
  2492.  
  2493. Byte 03H contains 00H, a zero-length name.
  2494.  
  2495. Byte 04H contains 04H, the length of the class name CODE, which is
  2496. found in bytes 05-08H. Bytes 09-26H contain the class names DATA and
  2497. STACK and the segment names _DATA, _STACK, and _TEXT, each preceded by
  2498. 1 byte that gives its length.
  2499.  
  2500. Byte 27H contains the Checksum field, 8BH.
  2501.  
  2502.  
  2503. 98H OR 99H SEGDEF--SEGMENT DEFINITION RECORD
  2504. ============================================
  2505.  
  2506. Description
  2507. -----------
  2508.  
  2509. The SEGDEF record describes a logical segment in an object module. It
  2510. defines the segment's name, length, and alignment, and the way the
  2511. segment can be combined with other logical segments at bind, link, or
  2512. load time.
  2513.  
  2514. Object records that follow a SEGDEF record can refer to it to identify
  2515. a particular segment. The SEGDEF records are ordered by occurrence,
  2516. and are referenced by segment indexes (starting from 1) in subsequent
  2517. records.
  2518.  
  2519. History
  2520. -------
  2521.  
  2522. Record type 99H is new for LINK386: the Segment Length field is 32
  2523. bits rather than 16 bits, there is one newly implemented alignment
  2524. type (page alignment), the B bit flag of the ACBP byte indicates a
  2525. segment of 4 GB, and the P bit flag of the ACBP byte is the
  2526. Use16/Use32 flag.
  2527.  
  2528. Starting with version 2.4, LINK ignores the Overlay Name Index field.
  2529. In versions 2.4 and later, command-line parameters to LINK, rather
  2530. than information contained in object modules, determine the creation
  2531. of run-time overlays.
  2532.  
  2533. The length does not include COMDAT records. If selected, their size is
  2534. added.
  2535.  
  2536. Record Format
  2537. -------------
  2538.    
  2539.    1      2        <variable>  2 or 4  1 or 2  1 or 2 1 or 2   1
  2540.    98     Record   Segment     Segment Segment Class  Overlay  Checksum
  2541.    or 99  Length   Attributes  Length  Name    Name   Name     
  2542.                                        Index   Index  Index
  2543.  
  2544. Segment Attributes Field
  2545. ------------------------
  2546.  
  2547. The Segment Attributes field is a variable-length field;
  2548. its layout is:
  2549.  
  2550.   <-3 bits->  <-3 bits-> <-1 bit-> <-1 bit->  <-2 bytes-->  <--1 byte-->
  2551.   A           C          B         P          Frame Number  Offset
  2552.                                               <conditional> <conditional>
  2553.  
  2554. The fields have the following meanings:
  2555.  
  2556.    A     Alignment
  2557.          
  2558.          A 3-bit field that specifies the alignment required when
  2559.          this program segment is placed within a logical segment.
  2560.          Its values are:
  2561.          
  2562.            0    Absolute segment.
  2563.                 
  2564.            1    Relocatable, byte aligned.
  2565.                 
  2566.            2    Relocatable, word (2-byte, 16-bit) aligned.
  2567.                 
  2568.            3    Relocatable, paragraph (16-byte) aligned.
  2569.                 
  2570.            4    Relocatable, aligned on 256-byte boundary (a "page"
  2571.                 in the original Intel specification).
  2572.                 
  2573.            5    Relocatable, aligned on a double word (4-byte)
  2574.                 boundary. This value is used by the PharLap OMF for
  2575.                 the same alignment.
  2576.                 
  2577.            6    This value is used by the PharLap OMF for page (4K)
  2578.                 alignment. It is not supported by LINK.
  2579.                 
  2580.            7    Not defined.
  2581.                 
  2582.            The new values for LINK386 are A=4 and A=5. Double word
  2583.            alignment is expected to be useful as 32-bit memory paths
  2584.            become more prevalent. Page-align is useful for certain
  2585.            hardware-defined items (such as page tables) and error
  2586.            avoidance.
  2587.            
  2588.            If A=0, the conditional Frame Number and Offset fields
  2589.            are present and indicate the starting address of the
  2590.            absolute segment. LINK ignores the Offset field.
  2591.            
  2592.            Conflict: The original Intel specification included
  2593.            additional segment-alignment values not supported by
  2594.            Microsoft; alignment 5 now conflicts with the following
  2595.            LINK386 extensions:
  2596.            
  2597.            5    "unnamed absolute portion of memory address space"
  2598.                 
  2599.            6    "load-time locatable (LTL), paragraph aligned if not
  2600.                 part of any group"
  2601.                 
  2602.     C    Combination
  2603.          
  2604.          A 3-bit field that describes how the linker can combine the
  2605.          segment with other segments. Under MS-DOS, segments with
  2606.          the same name and class can be combined in two ways: they
  2607.          can be concatenated to form one logical segment, or they
  2608.          can be overlapped. In the latter case, they have either the
  2609.          same starting address or the same ending address, and they
  2610.          describe a common area in memory. Values for the C field
  2611.          are:
  2612.          
  2613.            0    Private. Do not combine with any other program
  2614.                 segment.
  2615.                 
  2616.            1    Reserved by IBM. Not supported by Microsoft.
  2617.                 
  2618.            2    Public. Combine by appending at an offset that meets
  2619.                 the alignment requirement.
  2620.                 
  2621.            3    Reserved by IBM. Not supported by Microsoft.
  2622.                 
  2623.            4    As defined by Microsoft, same as C=2 (public).
  2624.                 
  2625.            5    Stack. Combine as for C=2. This combine type forces
  2626.                 byte alignment.
  2627.                 
  2628.            6    Common. Combine by overlay using maximum size.
  2629.                 
  2630.            7    As defined by Microsoft, same as C=2 (public).
  2631.                 
  2632.            Conflict: The Intel specification lists C=1 as Common,
  2633.            not C=6.
  2634.  
  2635.   B     Big
  2636.         
  2637.         Used as the high-order bit of the Segment Length field. If
  2638.         this bit is set, the segment length value must be 0. If the
  2639.         record type is 98H and this bit is set, the segment is
  2640.         exactly 64K long. If the record type is 99H and this bit is
  2641.         set, the segment is exactly 2^32 bytes, or 4 GB, long.
  2642.         
  2643.           NOTE: A problem in the 286 chip makes code unreliable if
  2644.           it is executed between bytes 65,500 and 65,535. LINK
  2645.           warns of this problem if code segments reach that size.
  2646.         
  2647.   P     This bit corresponds to the bit field for segment
  2648.         descriptors, known as the B bit for data segments and the D
  2649.         bit for code segments in the Intel documentation.
  2650.         If 0, then the segment is no larger than 64K (if data), and
  2651.         16-bit addressing and operands are the default (if code).
  2652.         This is a Use16 segment.
  2653.        
  2654.         If nonzero, then the segment may be larger than 64K (if
  2655.         data), and 32-bit addressing and operands are the default
  2656.         (if code). This is a Use32 segment.
  2657.         
  2658.            NOTE: This is the only method for defining Use32 segments
  2659.            in the Microsoft OMF. The PharLap OMF uses an additional
  2660.            byte of bit flags at the end of the SEGDEF record to hold
  2661.            this and other flags (described later in this section).
  2662.            Even if the P bit is 0, the PharLap OMF assumes all
  2663.            segments are Use32.
  2664.   
  2665. Segment Length Field
  2666. --------------------
  2667.  
  2668. The Segment Length field is a 2- or 4-byte numeric quantity and
  2669. specifies the number of bytes in this program segment. For record type
  2670. 98H, the length can be from 0 to 64K; if a segment is exactly 64K, the
  2671. segment length should be 0, and the B field in the ACBP byte should be
  2672. 1. For record type 99H, the length can be from 0 to 4 GB; if a segment
  2673. is exactly 4 GB in size, the segment length should be 0 and the B
  2674. field in the ACBP byte should be 1.
  2675.  
  2676. Segment Name Index, Class Name Index, Overlay Name Index Fields
  2677. ---------------------------------------------------------------
  2678.  
  2679. The three name indexes (Segment Name Index, Class Name Index, and
  2680. Overlay Name Index) refer to names that appeared in previous LNAMES
  2681. record(s). LINK ignores the Overlay Name Index field. The full name of
  2682. a segment consists of the segment and class names, and segments in
  2683. different object modules are normally combined according to the A and
  2684. C values if their full names are identical. These indexes must be
  2685. nonzero, although the name itself may be null.
  2686.  
  2687. The Segment Name Index field identifies the segment with a name. The
  2688. name need not be unique--other segments of the same name will be
  2689. concatenated onto the first segment with that name. The name may have
  2690. been assigned by the programmer, or it may have been generated by a
  2691. compiler.
  2692.  
  2693. The Class Name Index field identifies the segment with a class name
  2694. (such as CODE, FAR_DATA, or STACK). The linker places segments with
  2695. the same class name into a contiguous area of memory in the run-time
  2696. memory map.
  2697.  
  2698. The Overlay Name Index field identifies the segment with a run-time
  2699. overlay. It is ignored by current versions of the linker.
  2700.  
  2701. PharLap Extensions to This Record
  2702. ---------------------------------
  2703.  
  2704. In the PharLap 32-bit OMF, there is an additional optional field that
  2705. follows the Overlay Name Index field. The reserved bits should always
  2706. be 0. The format of this field is
  2707.  
  2708.    <------------5 bits----------------> <--1 bit-->  <--2 bits-->
  2709.    Reserved                             U            AT
  2710.  
  2711. where AT is the access type for the segment and has the following
  2712. possible values
  2713.    
  2714.    0    Read only
  2715.    1    Execute only
  2716.    2    Execute/read
  2717.    3    Read/write
  2718.  
  2719. and U is the Use16/Use32 bit for the segment and has the following
  2720. possible values:
  2721.    
  2722.    0    Use16
  2723.    1    Use32
  2724.   
  2725.   Conflicts: The Microsoft-defined OMF has Use16/Use32 stored as the P
  2726.   bit of the ACBP field. Microsoft's OMF does not specify the access
  2727.   for the segment--it is specified in the .DEF file given to LINK.
  2728.   
  2729.   NOTES
  2730.   
  2731.   LINK imposes a limit of 255 SEGDEF records per object module.
  2732.   
  2733.   Certain name/class combinations are reserved for use by CodeView and
  2734.   have special significance to the linker: name $$TYPES with class
  2735.   name DEBTYP, and $$SYMBOLS with class name DEBSYM. See Appendix 1
  2736.   for more information.
  2737.  
  2738. Examples
  2739. --------
  2740.  
  2741. The following examples of Microsoft assembler SEGMENT directives show
  2742. the resulting values for the A field in the corresponding SEGDEF
  2743. object record:
  2744.    
  2745.    aseg  SEGMENT at 400h              ; A = 0
  2746.    bseg  SEGMENT byte public 'CODE'   ; A = 1
  2747.    cseg  SEGMENT para stack 'STACK'   ; A = 3
  2748.  
  2749. The following examples of assembler SEGMENT directives show the
  2750. resulting values for the C field in the corresponding SEGDEF object
  2751. record:
  2752.  
  2753.    aseg  SEGMENT at 400H            ; C = 0
  2754.    bseg  SEGMENT public 'DATA'      ; C = 2
  2755.    cseg  SEGMENT stack 'STACK'      ; C = 5
  2756.    dseg  SEGMENT common 'COMMON'    ; C = 6
  2757.  
  2758. In this first example, the segment is byte aligned:
  2759.  
  2760.         0   1  2  3  4  5  6  7  8  9  A  B  C  D E  F 
  2761.    0000 98  07 00 28 11 00 07 02 01 1E                 ....(.....
  2762.   
  2763.  
  2764. Byte 00H contains 98H, indicating that this is a SEGDEF record.
  2765.  
  2766. Bytes 01-02H contain 0007H, the length of the remainder of the record.
  2767.  
  2768. Byte 03H contains 28H (00101000B), the ACBP byte. Bits 7-5 (the A
  2769. field) contain 1 (001B), indicating that this segment is relocatable
  2770. and byte aligned. Bits 4-2 (the C field) contain 2 (010B), which
  2771. represents a public combine type. (When this object module is linked,
  2772. this segment will be concatenated with all other segments with the
  2773. same name.) Bit 1 (the B field) is 0, indicating that this segment is
  2774. smaller than 64K. Bit 0 (the P field) is ignored and should be 0, as
  2775. it is here.
  2776.  
  2777. Bytes 04-05H contain 0011H, the size of the segment in bytes.
  2778.  
  2779. Bytes 06-08H index the list of names defined in the module's LNAMES
  2780. record. Byte 06H (the Segment Name Index field) contains 07H, so the
  2781. name of this segment is the seventh name in the LNAMES record. Byte
  2782. 07H (the Class Name Index field) contains 02H, so the segment's class
  2783. name is the second name in the LNAMES record. Byte 08H (the Overlay
  2784. Name Index field) contains 1, a reference to the first name in the
  2785. LNAMES record. (This name is usually null, as MS-DOS ignores it
  2786. anyway.)
  2787.  
  2788. Byte 09H contains the Checksum field, 1EH.
  2789.  
  2790. The second SEGDEF record declares a word-aligned segment. It differs
  2791. only slightly from the first.
  2792.  
  2793.      0  1  2  3  4  5  6  7  8  9  A B  C  D  E  F 
  2794. 0000 98 07 00 48 0F 00 05 03 01 01                 .. H......
  2795.  
  2796. Bits 7-5 (the A field) of byte 03H (the ACBP byte) contain 2 (010B),
  2797. indicating that this segment is relocatable and word aligned.
  2798.  
  2799. Bytes 04-05H contain the size of the segment, 000FH.
  2800.  
  2801. Byte 06H (the Segment Name Index field) contains 05H, which refers to
  2802. the fifth name in the previous LNAMES record.
  2803.  
  2804. Byte 07H (the Class Name Index field) contains 03H, a reference to the
  2805. third name in the LNAMES record.
  2806.  
  2807.  
  2808. 9AH GRPDEF--GROUP DEFINITION RECORD
  2809. ===================================
  2810.  
  2811. Description
  2812. -----------
  2813.  
  2814. This record causes the program segments identified by SEGDEF records
  2815. to be collected together (grouped). For OS/2, the segments are
  2816. combined into a logical segment that is to be addressed through a
  2817. single selector. For MS-DOS, the segments are combined within the same
  2818. 64K frame in the run-time memory map.
  2819.  
  2820. History
  2821. -------
  2822.  
  2823. The special group name "FLAT" was added for LINK386.
  2824.  
  2825. Record Format
  2826. -------------
  2827.    
  2828.    1    2        1 or 2     1        1 or 2       1
  2829.    9A   Record   Group Name FF       Segment      Checksum
  2830.         Length   Index      Index    Definition   
  2831.                             <-----repeated----->  
  2832.  
  2833. Group Name Field
  2834. ----------------
  2835.  
  2836. The Group Name field is specified as an index into a previously
  2837. defined LNAMES name and must be nonzero.
  2838.  
  2839. Groups from different object modules are combined if their names are
  2840. identical.
  2841.  
  2842. Group Components
  2843. ----------------
  2844.  
  2845. The group's components are segments, specified as indexes into
  2846. previously defined SEGDEF records.
  2847.  
  2848. The first byte of each group component is a type field for the
  2849. remainder of the component. LINK requires a type value of FFH and
  2850. always assumes that the component contains a segment index value. See
  2851. the "Notes" section below for other types defined by Intel.
  2852.  
  2853. The component fields are usually repeated so that all the segments
  2854. constituting a group can be included in one GRPDEF record.
  2855.   
  2856.   NOTES
  2857.   
  2858.   LINK imposes a limit of 31 GRPDEF records in a single object module
  2859.   and limits the total number of group definitions across all object
  2860.   modules to 31.
  2861.   
  2862.   This record is frequently followed by a THREAD FIXUPP record.
  2863.   
  2864.   The most common group is DGROUP, which is used to group the default
  2865.   data segments (_DATA, CONST, and _BSS).
  2866.   
  2867.   LINK does special handling of the pseudo-group name FLAT for LINK386
  2868.   only. All address references to this group are made as offsets from
  2869.   the Virtual Zero Address, which is the start of the memory image of
  2870.   the executable.
  2871.   
  2872.   The additional group component types defined by Intel and the fields
  2873.   that follow them are:
  2874.   
  2875.     FE   External Index
  2876.     FD   Segment Name Index, Class Name Index, Overlay Name Index
  2877.     FB   LTL Data field, Maximum Group Length, Group Length
  2878.     FA   Frame Number, Offset
  2879.     
  2880.   None of these types is supported by LINK.
  2881.  
  2882. Examples
  2883. --------
  2884.  
  2885. The example of a GRPDEF record below corresponds to the following
  2886. assembler directive:
  2887.    
  2888.    tgroup GROUP seg1,seg2,seg3
  2889.  
  2890. The GRPDEF record is:
  2891.  
  2892.      0   1  2   3  4   5  6  7  8   9  A   B  C  D  E F   
  2893. 0000 9A  08 00  06 FF  01 FF 02 FF  03 55                 .....U
  2894.  
  2895. Byte 00H contains 9AH, indicating that this is a GRPDEF record.
  2896.  
  2897. Bytes 01-02H contain 0008H, the length of the remainder of the record.
  2898.  
  2899. Byte 03H contains 06H, the Group Name Index field. In this instance,
  2900. the index number refers to the sixth name in the previous LNAMES
  2901. record in the object module. That name is the name of the group of
  2902. segments defined in the remainder of the record.
  2903.  
  2904. Bytes 04-05H contain the first of three group component descriptor
  2905. fields. Byte 04H contains the required 0FFH, indicating that the
  2906. subsequent field is a segment index. Byte 05H contains 01H, a segment
  2907. index that refers to the first SEGDEF record in the object module.
  2908. This SEGDEF record declared the first of three segments in the group.
  2909.  
  2910. Bytes 06-07H represent the second group component descriptor, this one
  2911. referring to the second SEGDEF record in the object module.
  2912.  
  2913. Similarly, bytes 08-09H are a group component descriptor field that
  2914. references the third SEGDEF record.
  2915.  
  2916. Byte 0AH contains the Checksum field, 55H.
  2917.  
  2918.  
  2919. 9CH OR 9DH FIXUPP--FIXUP RECORD
  2920. ===============================
  2921.  
  2922. Description
  2923. -----------
  2924.  
  2925. The FIXUPP record contains information that allows the linker to
  2926. resolve (fix up) and eventually relocate references between object
  2927. modules. FIXUPP records describe the LOCATION of each address value to
  2928. be fixed up, the TARGET address to which the fixup refers, and the
  2929. FRAME relative to which the address computation is performed.
  2930.  
  2931. History
  2932. -------
  2933.  
  2934. Record type 9DH is new for LINK386; it has a Target Displacement field
  2935. of 32 bits rather than 16 bits, and the Location field of the Locat
  2936. word has been extended to 4 bits (using the previously unused higher
  2937. order S bit) to allow new LOCATION values of 9, 11, and 13.
  2938.  
  2939. Record Format
  2940. -------------
  2941.    
  2942.    1          2          <------from Record Length----->  1
  2943.    9C         Record     THREAD subrecord or              Checksum
  2944.    or 9D      Length     FIXUP subrecord                  
  2945.                          <--------repeated------------->  
  2946.  
  2947. Each subrecord in a FIXUPP object record either defines a thread for
  2948. subsequent use, or refers to a data location in the nearest previous
  2949. LEDATA or LIDATA record. The high-order bit of the subrecord
  2950. determines the subrecord type: if the high-order bit is 0, the
  2951. subrecord is a THREAD subrecord; if the high-order bit is 1, the
  2952. subrecord is a FIXUP subrecord. Subrecords of different types can be
  2953. mixed within one object record.
  2954.  
  2955. Information that determines how to resolve a reference can be
  2956. specified explicitly in a FIXUP subrecord, or it can be specified
  2957. within a FIXUP subrecord by a reference to a previous THREAD
  2958. subrecord. A THREAD subrecord describes only the method to be used by
  2959. the linker to refer to a particular target or frame. Because the same
  2960. THREAD subrecord can be referenced in several subsequent FIXUP
  2961. subrecords, a FIXUPP object record that uses THREAD subrecords may be
  2962. smaller than one in which THREAD subrecords are not used.
  2963.  
  2964. THREAD subrecords can be referenced in the same object record in which
  2965. they appear and also in subsequent FIXUPP object records.
  2966.  
  2967. THREAD Subrecord
  2968. ----------------
  2969.  
  2970. There are four FRAME threads and four TARGET threads; not all need be
  2971. defined, and they can be redefined by later THREAD subrecords in the
  2972. same or later FIXUPP object records. The FRAME threads are used to
  2973. specify the Frame Datum field in a later FIXUP subrecord; the TARGET
  2974. threads are used to specify the Target Datum field in a later FIXUP
  2975. subrecord.
  2976.  
  2977. A THREAD subrecord does not require that a previous LEDATA or LIDATA
  2978. record occur.
  2979.  
  2980. The layout of the THREAD subrecord is as follows:
  2981.  
  2982.    <--------------1 byte-------------------->  <---1 or 2 bytes--->
  2983.    0      D       0      Method     Thred      Index
  2984.    1      1       1      3          2 (bits)   <---conditional---->
  2985.  
  2986. where:
  2987.  
  2988.    0      The high-order bit is 0 to indicate that this is a THREAD
  2989.           subrecord.
  2990.           
  2991.    D      Is 0 for a TARGET thread, 1 for a FRAME thread.
  2992.           
  2993.    Method Is a 3-bit field.
  2994.       
  2995.           For TARGET threads, only the lower two bits of the field
  2996.           are used; the high-order bit of the method is derived from
  2997.           the P bit in the Fix Data field of FIXUP subrecords that
  2998.           refer to this thread. (The full list of methods is given
  2999.           here for completeness.) This field determines the kind of
  3000.           index required to specify the Target Datum field.
  3001.           
  3002.             T0   Specified by a SEGDEF index.
  3003.                  
  3004.             T1   Specified by a GRPDEF index.
  3005.                  
  3006.             T2   Specified by a EXTDEF index.
  3007.                  
  3008.             T3   Specified by an explicit frame number (not
  3009.                  supported by LINK).
  3010.                  
  3011.             T4   Specified by a SEGDEF index only; the displacement
  3012.                  in the FIXUP subrecord is assumed to be 0.
  3013.                  
  3014.             T5   Specified by a GRPDEF index only; the displacement
  3015.                  in the FIXUP subrecord is assumed to be 0.
  3016.                  
  3017.             T6   Specified by a EXTDEF index only; the displacement
  3018.                  in the FIXUP subrecord is assumed to be 0.
  3019.                  
  3020.                  The index type specified by the TARGET thread
  3021.                  method is encoded in the Index field.
  3022.                  
  3023.                  For FRAME threads, the Method field determines the
  3024.                  Frame Datum field of subsequent FIXUP subrecords
  3025.                  that refer to this thread. Values for the Method
  3026.                  field are:
  3027.                  
  3028.                     F0    The FRAME is specified by a SEGDEF index.
  3029.                           
  3030.                     F1    The FRAME is specified by a GRPDEF index.
  3031.                           
  3032.                     F2    The FRAME is specified by a EXTDEF index.
  3033.                           LINK determines the FRAME from the external
  3034.                           name's corresponding PUBDEF record in
  3035.                           another object module, which specifies
  3036.                           either a logical segment or a group.
  3037.                           
  3038.                     F3    Invalid. (The FRAME is identified by an
  3039.                           explicit frame number; this is not
  3040.                           supported by LINK.)
  3041.                           
  3042.                     F4    The FRAME is determined by the segment
  3043.                           index of the previous LEDATA or LIDATA
  3044.                           record (that is, the segment in which the
  3045.                           location is defined).
  3046.                           
  3047.                     F5    The FRAME is determined by the TARGET's
  3048.                           segment, group, or external index.
  3049.                           
  3050.                     F6    Invalid.
  3051.                           
  3052.                           NOTE: The Index field is present for FRAME
  3053.                           methods F0, F1, and F2 only.
  3054.                           
  3055.    Thred  A 2-bit field that determines the thread number (0 through
  3056.           3, for the four threads of each kind).
  3057.    Index  A conditional field that contains an index value that
  3058.           refers to a previous SEGDEF, GRPDEF, or EXTDEF record. The
  3059.           field is present only if the thread method is 0, 1, or 2.
  3060.           (If method 3 were supported by LINK, the Index field would
  3061.           contain an explicit frame number.)
  3062.  
  3063. FIXUP Subrecord
  3064. ---------------
  3065.  
  3066. A FIXUP subrecord gives the how/what/why/where/who information
  3067. required to resolve or relocate a reference when program segments are
  3068. combined or placed within logical segments. It applies to the nearest
  3069. previous LEDATA or LIDATA record, which must be defined before the
  3070. FIXUP subrecord. The FIXUP subrecord is as follows
  3071.  
  3072.    2      1               1 or 2         1 or 2          2 or 4
  3073.    Locat  Fix             Frame          Target          Target
  3074.           Data            Datum          Datum           Displacement
  3075.           <conditional>   <conditional>  <conditional>   
  3076.  
  3077. where the Locat field has an unusual format. Contrary to the usual
  3078. byte order in Intel data structures, the most significant bits of the
  3079. Locat field are found in the low-order, rather than the high-order,
  3080. byte
  3081.    
  3082.    <-----low-order byte----><----high-order byte--->
  3083.    1    M   Location        Data Record Offset
  3084.    1    1   4               10 (bits)
  3085.  
  3086. where:
  3087.  
  3088.    1          The high-order bit of the low-order byte is set to
  3089.               indicate a FIXUP subrecord.
  3090.               
  3091.    M          Is the mode; M=1 for segment-relative fixups, and M=0
  3092.               for self-relative fixups.
  3093.               
  3094.    Location   Is a 4-bit field that determines what type of LOCATION
  3095.               is to be fixed up:
  3096.               
  3097.                 0    Low-order byte (8-bit displacement or low byte
  3098.                      of 16-bit offset).
  3099.                      
  3100.                 1    16-bit offset.
  3101.                      
  3102.                 2    16-bit base--logical segment base (selector).
  3103.                      
  3104.                 3    32-bit Long pointer (16-bit base:16-bit
  3105.                      offset).
  3106.                      
  3107.                 4    High-order byte (high byte of 16-bit offset).
  3108.                      LINK does not support this type.
  3109.                      
  3110.                 5    16-bit loader-resolved offset, treated as
  3111.                      Location=1 by the linker.
  3112.                      
  3113.                      Conflict: The PharLap OMF uses Location=5 to
  3114.                      indicate a 32-bit offset, whereas Microsoft
  3115.                      uses Location=9.
  3116.                      
  3117.                 6    Not defined, reserved.
  3118.                     
  3119.                        Conflict: The PharLap OMF uses Location=6 to
  3120.                        indicate a 48-bit pointer (16-bit base:32-bit
  3121.                        offset), whereas Microsoft uses Location=11.
  3122.                     
  3123.                 7    Not defined, reserved.
  3124.                      
  3125.                 9    32-bit offset.
  3126.                      
  3127.                 11   48-bit pointer (16-bit base:32-bit offset).
  3128.                      
  3129.                 13   32-bit loader-resolved offset, treated as
  3130.                      Location=9 by the linker.
  3131.                      
  3132.    Data       Indicates the position of the LOCATION to be fixed up
  3133.    Record     in the LEDATA or LIDATA record immediately preceding
  3134.    Offset     the FIXUPP record. This offset indicates either a byte
  3135.               in the Data Bytes field of an LEDATA record or a data
  3136.               byte in the Content field of a Data Block field in an
  3137.               LIDATA record.
  3138.  
  3139. The Fix Data bit layout is
  3140.  
  3141.    F    Frame  T    P    Targt
  3142.    1    3      1    1    2 (bits)
  3143.  
  3144. and is interpreted as follows:
  3145.  
  3146.    F        If F=1, the FRAME is given by a FRAME thread whose
  3147.             number is in the Frame field (modulo 4). There is no
  3148.             Frame Datum field in the subrecord.
  3149.             
  3150.             If F=0, the FRAME method (in the range F0 to F5) is
  3151.             explicitly defined in this FIXUP subrecord. The method
  3152.             is stored in the Frame field.
  3153.             
  3154.    Frame    A 3-bit numeric field, interpreted according to the F
  3155.             bit. The Frame Datum field is present and is an index
  3156.             field for FRAME methods F0, F1, and F2 only.
  3157.             
  3158.    T        If T=1, the TARGET is defined by a TARGET thread whose
  3159.             thread number is given in the 2-bit Targt field. The
  3160.             Targt field contains a number between 0 and 3 that
  3161.             refers to a previous THREAD subrecord containing the
  3162.             TARGET method. The P bit, combined with the two low-
  3163.             order bits of the Method field in the THREAD subrecord,
  3164.             determines the TARGET method.
  3165.             
  3166.             If T=0, the TARGET is specified explicitly in this FIXUP
  3167.             subrecord. In this case, the P bit and the Targt field
  3168.             can be considered a 3-bit field analogous to the Frame
  3169.             field.
  3170.             
  3171.    P        Determines whether the Target Displacement field is
  3172.             present.
  3173.             
  3174.             If P=1, there is no Target Displacement field.
  3175.             
  3176.             If P=0, the Target Displacement field is present. It is
  3177.             a 4-byte field if the record type is 9DH; it is a 2-byte
  3178.             field otherwise.
  3179.             
  3180.    Targt    A 2-bit numeric field, which gives the lower two bits of
  3181.             the TARGET method (if T=0) or gives the TARGET thread
  3182.             number (if T=1).
  3183.  
  3184. Frame Datum, Target Datum, and Target Displacement Fields
  3185. ---------------------------------------------------------
  3186.  
  3187. The Frame Datum field is an index field that refers to a previous
  3188. SEGDEF, GRPDEF, or EXTDEF record, depending on the FRAME method.
  3189.  
  3190. Similarly, the Target Datum field contains a segment index, a group
  3191. index, or an external name index, depending on the TARGET method.
  3192.  
  3193. The Target Displacement field, a 16-bit or 32-bit field, is present
  3194. only if the P bit in the Fix Data field is set to 0, in which case the
  3195. Target Displacement field contains the offset used in methods 0, 1,
  3196. and 2 of specifying a TARGET.
  3197.   
  3198.   NOTES
  3199.   
  3200.   FIXUPP records are used to fix references in the immediately
  3201.   preceding LEDATA, LIDATA, or COMDAT record.
  3202.   
  3203.   The Frame field is the translator's way of telling the linker the
  3204.   contents of the segment register used for the reference; the TARGET
  3205.   is the item being referenced whose address was not completely
  3206.   resolved by the translator. In protected mode, the only legal
  3207.   segment register values are selectors; every segment and group of
  3208.   segments is mapped through some selector and addressed by an offset
  3209.   within the underlying memory defined by that selector.
  3210.  
  3211. Examples
  3212. --------
  3213.  
  3214. Due to the incredible length of the FIXUPP examples in "The MS-DOS
  3215. Encyclopedia," they are not repeated here. However, the examples are
  3216. highly recommended if you want to understand what is happening.
  3217.  
  3218. **********
  3219. Document 5
  3220. **********
  3221.  
  3222. A0H OR A1H LEDATA--LOGICAL ENUMERATED DATA RECORD
  3223. =================================================
  3224.  
  3225. Description
  3226. -----------
  3227.  
  3228. This record provides contiguous binary data--executable code or
  3229. program data--that is part of a program segment. The data is
  3230. eventually copied into the program's executable binary image by the
  3231. linker.
  3232.  
  3233. The data bytes may be subject to relocation or fixing up as determined
  3234. by the presence of a subsequent FIXUPP record, but otherwise they
  3235. require no expansion when mapped to memory at run time.
  3236.  
  3237. History
  3238. -------
  3239.  
  3240. Record type A1H is new for LINK386; it has an Enumerated Data Offset
  3241. field of 32 bits rather than 16 bits.
  3242.  
  3243. Record Format
  3244. -------------
  3245.    
  3246.    1      2       1 or 2   2 or 4      <from Record Length>  1
  3247.    A0     Record  Segment  Enumerated  Data                  Checksum
  3248.    or A1  Length  Index    Data        Bytes                 
  3249.                            Offset
  3250.  
  3251. Segment Index Field
  3252. -------------------
  3253.  
  3254. The Segment Index field must be nonzero and is the index of a
  3255. previously defined SEGDEF record. This is the segment into which the
  3256. data in this LEDATA record is to be placed.
  3257.  
  3258. Enumerated Data Offset Field
  3259. ----------------------------
  3260.  
  3261. The Enumerated Data Offset field is either a 2- or 4-byte field
  3262. (depending on the record type) that determines the offset at which the
  3263. first data byte is to be placed relative to the start of the SEGDEF
  3264. segment. Successive data bytes occupy successively higher locations.
  3265.  
  3266. Data Bytes Field
  3267. ----------------
  3268.  
  3269. The maximum number of data bytes is 1024, so that a FIXUPP Location
  3270. field, which is 10 bits, can reference any of these data bytes. The
  3271. number of data bytes is computed from the Record Length field minus 5,
  3272. minus the size of the Segment Index field (1 or 2 bytes).
  3273.   
  3274.   NOTES
  3275.   
  3276.   Record type A1H has the offset stored as a 32-bit value. Record type
  3277.   A0H encodes the offset value as a 16-bit numeric field (zero-
  3278.   extended if applied to a Use32 segment).
  3279.   
  3280.   If an LEDATA record requires a fixup, a FIXUPP record must
  3281.   immediately follow the LEDATA record.
  3282.   
  3283.   Code for functions is output in LEDATA records currently. The
  3284.   segment for code is usually named _TEXT (or module_TEXT, depending
  3285.   on the memory model), unless #pragma alloc_text is used to specify a
  3286.   different code segment for the specified functions.
  3287.   
  3288.   For instantiated functions in C++, code will simply be output in
  3289.   COMDAT records that refer to the function and identify the
  3290.   function's segment.
  3291.   
  3292.   Data, usually generated by initialized variables (global or static),
  3293.   is output in LEDATA/LIDATA records referring to either a data
  3294.   segment or, possibly, a segment created for a based variable.
  3295.  
  3296. Examples
  3297. --------
  3298.  
  3299. The following LEDATA record contains a simple text string:
  3300.  
  3301.       0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F   
  3302.  0000 A0 13 00 02 00 00 48 65 6C 6C 6F 2C 20 77 6F 72......Hello, wor
  3303.  0010 6C 64 0D 0A 24 A8                              ld..$.
  3304.  
  3305. Byte 00H contains 0A0H, which identifies this as an LEDATA record.
  3306.  
  3307. Bytes 01-02H contain 0013H, the length of the remainder of the record.
  3308.  
  3309. Byte 03H (the Segment Index field) contains 02H, a reference to the
  3310. second SEGDEF record in the object module.
  3311.  
  3312. Bytes 04-05H (the Enumerated Data Offset field) contain 0000H. This is
  3313. the offset, from the base of the segment indicated by the Segment
  3314. Index field, at which the data in the Data Bytes field will be placed
  3315. when the program is linked. Of course, this offset is subject to
  3316. relocation by the linker because the segment declared in the specified
  3317. SEGDEF record may be relocatable and may be combined with other
  3318. segments declared in other object modules.
  3319.  
  3320. Bytes 06-14H (the Data Bytes field) contain the actual data.
  3321.  
  3322. Byte 15H contains the Checksum field, 0A8H.
  3323.  
  3324.  
  3325. A2H OR A3H LIDATA--LOGICAL ITERATED DATA RECORD
  3326. ===============================================
  3327.  
  3328. Description
  3329. -----------
  3330.  
  3331. Like the LEDATA record, the LIDATA record contains binary data--
  3332. executable code or program data. The data in an LIDATA record,
  3333. however, is specified as a repeating pattern (iterated), rather than
  3334. by explicit enumeration.
  3335.  
  3336. The data in an LIDATA record can be modified by the linker if the
  3337. LIDATA record is followed by a FIXUPP record, although this is not
  3338. recommended.
  3339.  
  3340. History
  3341. -------
  3342.  
  3343. Record type A3H is new for LINK386; it has Iterated Data Offset and
  3344. Repeat Count fields of 32 bits rather than 16 bits.
  3345.  
  3346. Record Format
  3347. -------------
  3348.  
  3349.    1    2       1 or 2  2 or 4    <from Record Length>  1
  3350.    A2   Record  Segment Iterated  Data                  Checksum
  3351.    or   Length  Index   Data      Block                 
  3352.    A3                   Offset                          
  3353.                                   <-----------repeated----------->
  3354.    
  3355. Segment Index and Interated Data Offset Fields
  3356. ----------------------------------------------
  3357.  
  3358. The Segment Index and Iterated Data Offset fields (2 or 4 bytes) are
  3359. the same as for an LEDATA record. The index must be nonzero. This
  3360. indicates the segment and offset at which the data in this LIDATA
  3361. record is to be placed when the program is loaded.
  3362.  
  3363. Data Block Field
  3364. ----------------
  3365.  
  3366. The data blocks have the following form:
  3367.                        
  3368.    2 or 4    2         <from Block Count>
  3369.    Repeat    Block     Content
  3370.    Count     Count     
  3371.  
  3372. Repeat Count Field
  3373. ------------------
  3374.  
  3375. The Repeat Count field is a 16-bit or 32-bit value that determines the
  3376. number of times the Content field is to be repeated. The Repeat Count
  3377. field is 32 bits only if the record type is A3H.
  3378.   
  3379.   Conflict: The PharLap OMF uses a 16-bit Repeat Count field, even in
  3380.   32-bit records.
  3381.  
  3382. Block Count Field
  3383. -----------------
  3384.  
  3385. The Block Count field is a 16-bit word whose value determines the
  3386. interpretation of the Content field, as follows:
  3387.  
  3388.    0      Indicates that the Content field that follows is a 1-byte
  3389.           count value followed by count data bytes. The data bytes
  3390.           will be mapped to memory, repeated as many times as are
  3391.           specified in the Repeat Count field.
  3392.           
  3393.    != 0   Indicates that the Content field that follows is composed
  3394.           of one or more Data Block fields. The value in the Block
  3395.           Count field specifies the number of Data Block fields
  3396.           (recursive definition).
  3397.           
  3398.   
  3399.   NOTES
  3400.   
  3401.   The Microsoft C Compiler generates LIDATA records for initialized
  3402.   data. For example:
  3403.    
  3404.       static int a[100] = { 1, };
  3405.   
  3406.   A FIXUPP record may occur after the LIDATA record; however, the
  3407.   fixup is applied before the iterated data block is expanded. It is a
  3408.   translator error for a fixup to reference any of the Count fields.
  3409.  
  3410. Example 1
  3411. ---------
  3412.    
  3413.       02 00 02 00 03 00 00 00 02 40 41 02 00 00 00 02 50 51
  3414.  
  3415. is an iterated data block with 16-bit repeat counts that expands to:
  3416.  
  3417.       40 41 40 41 40 41 50 51 50 51 40 41 40 41 40 41 50 51 50 51
  3418.  
  3419. Here, the outer data block has a repeat count of 2 and a block count
  3420. of 2 (which means to repeat twice the result of expanding the two
  3421. inner data blocks). The first inner data block has repeat count = 3,
  3422. block count = 0. The content is 2 bytes of data (40 41); the repeat
  3423. count expands the data to a string of 6 bytes. The second (and last)
  3424. inner data block has a repeat count = 2, block count = 0, content 2
  3425. bytes of data (50 51). This expands to 4 bytes, which is concatenated
  3426. with the 6 bytes from the first inner data block. The resulting 10
  3427. bytes are then expanded by 2 (the repeat count of the outer data
  3428. block) to form the 20-byte sequence illustrated.
  3429.  
  3430. Example 2
  3431. ---------
  3432.  
  3433. This sample LIDATA record corresponds to the following assembler
  3434. statement, which declares a 10-element array containing the strings
  3435. ALPHA and BETA:
  3436.    
  3437.    db   10 dup('ALPHA','BETA')
  3438.  
  3439. The LIDATA record is
  3440.    
  3441.       0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  3442. 0000  A2 1B 00 01 00 00 0A 00 02 00 01 00 00 00 05 41 ...............A
  3443. 0010  4C 50 48 41 01 00 00 00 04 42 45 54 41 A9       LPHA.....BETA.
  3444.  
  3445. Byte 00H contains 0A2H, identifying this as an LIDATA record.
  3446.  
  3447. Bytes 01-02H contain 1BH, the length of the remainder of the record.
  3448.  
  3449. Byte 03H (the Segment Index field) contains 01H, a reference to the
  3450. first SEGDEF record in this object module, indicating that the data
  3451. declared in this LIDATA record is to be placed into the segment
  3452. described by the first SEGDEF record.
  3453.  
  3454. Bytes 04-05H (the Iterated Data Offset field) contain 0000H, so the
  3455. data in this LIDATA record is to be located at offset 0000H in the
  3456. segment designated by the segment.
  3457.  
  3458. Bytes 06-1CH represent an iterated data block:
  3459.  
  3460.  - Bytes 06-07H contain the repeat count, 000AH, which indicates that
  3461.    the Content field of this iterated data block is to be repeated 10
  3462.    times.
  3463.  
  3464.  - Bytes 08-09H (the block count for this iterated data block) contain
  3465.    0002H, which indicates that the Content field of this iterated data
  3466.    block (bytes 0A-1CH) contains two nested iterated data block fields
  3467.    (bytes 0A-13H and bytes 14-1CH).
  3468.  
  3469.  - Bytes 0A-0BH contain 0001H, the repeat count for the first nested
  3470.    iterated data block. Bytes 0C-0DH contain 0000H, indicating that
  3471.    the Content field of this nested iterated data block contains data
  3472.    rather than more nested iterated data blocks. The Content field
  3473.    (bytes 0E-13H) contains the data; byte 0EH contains 05H, the number
  3474.    of subsequent data bytes; and bytes 0F-13H contain the actual data
  3475.    (the string ALPHA).
  3476.  
  3477.  - Bytes 14-1CH represent the second nested iterated data block, which
  3478.    has a format similar to that of the block in bytes 0A-13H. This
  3479.    second nested iterated data block represents the 4-byte string
  3480.    BETA.
  3481.  
  3482.  - Byte 1DH is the Checksum field, 0A9H.
  3483.  
  3484.  
  3485. B0H COMDEF--COMMUNAL NAMES DEFINITION RECORD
  3486. ============================================
  3487.  
  3488. Description
  3489. -----------
  3490.  
  3491. The COMDEF record is a Microsoft extension to the basic set of 8086
  3492. object record types. It declares a list of one or more communal
  3493. variables (uninitialized static data, or data that may match
  3494. initialized static data in another compilation unit).
  3495.  
  3496. The size of such a variable is the maximum size defined in any module
  3497. naming the variable as communal or public. The placement of communal
  3498. variables is determined by the data type using established conventions
  3499. (noted below).
  3500.  
  3501. History
  3502. -------
  3503.  
  3504. The COMDEF record is recognized by versions 3.5 and later of LINK.
  3505.  
  3506. Record Format
  3507. -------------
  3508.  
  3509.   1  2      1      <String Length> 1 or 2 1    1 or 2 1 <from Data Type>    
  3510.   B0 Record String Communal        Type   Data Communal Checksum
  3511.      Length Length Name            Index  Type Length          
  3512.             <----------------repeated------------------>
  3513.              
  3514. Communal Name Field
  3515. -------------------
  3516.  
  3517. The name is in <count, char> string format, and the name may be null.
  3518. NEAR and FAR communals from different object files are matched at bind
  3519. or link time if their names agree; the variable's size is the maximum
  3520. of the sizes specified (subject to some constraints, as documented
  3521. below).
  3522.  
  3523. Type Index Field
  3524. ----------------
  3525.  
  3526. This field encodes symbol information; it is parsed as an index field
  3527. (1 or 2 bytes) and is not inspected by current linkers. This field is
  3528. now used by CodeView instead of for its original purpose.
  3529.  
  3530. Data Type and Communal Length Fields
  3531.  
  3532. The Data Type field indicates the contents of the Communal Length
  3533. field. All Data Type values for NEAR data indicate that the Communal
  3534. Length field has only one numeric value: the amount of memory to be
  3535. allocated for the communal variable. All Data Type values for FAR data
  3536. indicate that the Communal Length field has two numeric values: the
  3537. first is the number of elements, and the second is the element size.
  3538.  
  3539. The Data Type field is one of the following hexadecimal values:
  3540.  
  3541.    61H   FAR data; the length is specified as the number of the
  3542.          elements followed by the element size in bytes
  3543.          
  3544.    62H   NEAR data; the length is specified as the number of bytes
  3545.  
  3546. The Communal Length field is a single numeric field or a pair of
  3547. numeric fields (as specified by the Data Type field), encoded as
  3548. follows:
  3549.  
  3550.                    Number    
  3551.    Value Range     of Bytes   Allocation
  3552.    ----------------------------------------------------------------
  3553.    0 through 128       1      This byte contains the value
  3554.   
  3555.    0 to 64K-1          3      First byte is 81H, followed by a 16-bit
  3556.                               word whose value is used
  3557.  
  3558.    0 to 16 MB-1        4      First byte is 84H, followed by a 3-byte
  3559.                               value
  3560.  
  3561.    -2 GB-1 to 2 GB-1   5      First byte is 88H, followed by a 4-byte
  3562.                               value
  3563.  
  3564. Groups of Communal Name, Type Index, Data Type, and Communal Length
  3565. fields can be repeated so that more than one communal variable can be
  3566. declared in the same COMDEF record.
  3567.   
  3568.   NOTES
  3569.   
  3570.   If a public or exported symbol with the same name is found in
  3571.   another module to which this module is bound or linked, LINK gives
  3572.   the error "symbol defined more than once."
  3573.   
  3574.   Communal variables cannot be resolved to dynamic links (that is,
  3575.   imported symbols).
  3576.   
  3577.   The records are ordered by occurrence, together with the items named
  3578.   in EXTDEF and LEXTDEF records (for reference in FIXUP subrecords).
  3579.   
  3580.   In older versions of the linker, any object module that contains
  3581.   COMDEF records is required to also contain one COMENT record with
  3582.   the comment class 0A1H, indicating that Microsoft extensions to the
  3583.   Intel object record specification are included in the object module.
  3584.   This COMENT record is no longer required; current versions of the
  3585.   linker always interpret COMDEF records.
  3586.  
  3587. Examples
  3588. --------
  3589.  
  3590. The following COMDEF record was generated by Microsoft C Compiler
  3591. version 4.0 for these public variable declarations:
  3592.  
  3593.    int   var;                   /* 2-byte integer */
  3594.    char  var2[32768];           /* 32768-byte array */
  3595.    char  far var3[10][2][20];   /* 400-byte array */
  3596.  
  3597. The COMDEF record is:
  3598.  
  3599.          0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  3600. 0000 B0 20 00 04 5F 66 6F 6F 00 62 02 05 5F 66 6F 6F  . .._var.b.._var
  3601. 0010 32 00 62 81 00 80 05 5F 66 6F 6F 33 00 61 81 90  2.b...._var3.a..
  3602. 0020 01 01 99                                         ...
  3603.  
  3604. Byte 00H contains 0B0H, indicating that this is a COMDEF record.
  3605.  
  3606. Bytes 01-02H contain 0020H, the length of the remainder of the record.
  3607.  
  3608. Bytes 03-0AH, 0B-15H, and 16-21H represent three declarations for the
  3609. communal variables var, var2, and var3. The C compiler prepends an
  3610. underscore to each of the names declared in the source code, so the
  3611. symbols represented in this COMDEF record are _var, _var2, and _var3.
  3612.  
  3613. Byte 03H contains 04H, the length of the first Communal Name field in
  3614. this record. Bytes 04-07H contain the name itself (_var). Byte 08H
  3615. (the Type Index field) contains 00H, as required. Byte 09H (the Data
  3616. Type field) contains 62H, indicating that this is a NEAR variable.
  3617. Byte 0AH (the Communal Length field) contains 02H, the size of the
  3618. variable in bytes.
  3619.  
  3620. Byte 0BH contains 05H, the length of the second Communal Name field.
  3621. Bytes 0C-10H contain the name _var2. Byte 11H is the Type Index field,
  3622. which again contains 00H, as required. Byte 12H (the Data Type field)
  3623. contains 62H, indicating that _var2 is a NEAR variable.
  3624.  
  3625. Bytes 13-15H (the Communal Length field) contain the size in bytes of
  3626. the variable. The first byte of the Communal Length field (byte 13H)
  3627. is 81H, indicating that the size is represented in the subsequent two
  3628. bytes of data--bytes 14-15H, which contain the value 8000H.
  3629.  
  3630. Bytes 16-1BH represent the Communal Name field for _var3, the third
  3631. communal variable declared in this record. Byte 1CH (the Type Index
  3632. field) again contains 00H as required. Byte 1DH (the Data Type field)
  3633. contains 61H, indicating that this is a FAR variable. This means the
  3634. Communal Length field is formatted as a Number of Elements field
  3635. (bytes 1E-20H, which contain the value 0190H) and an Element Size
  3636. field (byte 21H, which contains 01H). The total size of this communal
  3637. variable is thus 190H times 1, or 400 bytes.
  3638.  
  3639. Byte 22H contains the Checksum field, 99H.
  3640.  
  3641.  
  3642. B2H OR B3H BAKPAT--BACKPATCH RECORD
  3643. ===================================
  3644.  
  3645. Description
  3646. -----------
  3647.  
  3648. This record is for backpatches to LOCATIONs that cannot be
  3649. conveniently handled by a FIXUPP record at reference time (for
  3650. example, forward references in a one-pass compiler). It is essentially
  3651. a specialized fixup.
  3652.  
  3653. History
  3654. -------
  3655.  
  3656. Record type B2H is a Microsoft extension that was added for QuickC
  3657. version 1.0. Record type B3H is the 32-bit equivalent: the Offset and
  3658. Value fields are 32 bits rather than 16 bits.
  3659.  
  3660. Record Format
  3661. -------------
  3662.  
  3663.   1     2       1 or 2   1         2 or 4     2 or 4    1
  3664.   B2    Record  Segment  Location  Offset     Value     Checksum
  3665.   or B3 Length  Index    Type                         
  3666.   
  3667.                                    <-----repeated----->
  3668.                             
  3669. Segment Index Field
  3670. -------------------
  3671.  
  3672. Segment index to which all "backpatch" FIXUPP records are to be
  3673. applied. Note that, in contrast to FIXUPP records, these records do
  3674. not need to follow the data record to be fixed up. Hence, the segment
  3675. to which the backpatch applies must be specified explicitly.
  3676.  
  3677. Location Type Field
  3678. -------------------
  3679.  
  3680. Type of LOCATION to be patched; the only valid values are:
  3681.    
  3682.    0    8-bit low-order byte
  3683.    1    16-bit offset
  3684.    2    32-bit offset, record type B3H only (not supported yet)
  3685.  
  3686. Offset and Value Fields
  3687. -----------------------
  3688.  
  3689. These fields are 32 bits for record type B3H, and 16 bits for B2H.
  3690.  
  3691. The Offset field specifies the LOCATION to be patched (as an offset
  3692. into the SEGDEF record whose index is Segment Index).
  3693.  
  3694. The associated Value field is added to the LOCATION being patched
  3695. (unsigned addition, ignoring overflow). The Value field is a fixed
  3696. length (16 bits or 32 bits, depending on the record type) to make
  3697. object-module processing easier.
  3698.   
  3699.   NOTE: BAKPAT records can occur anywhere in the object module
  3700.   following the SEGDEF record to which they refer. They do not have to
  3701.   immediately follow the appropriate LEDATA record as FIXUPP records
  3702.   do.
  3703.   
  3704.   These records are buffered by the linker in Pass 2 until the end of
  3705.   the module, after the linker applies all other FIXUPP records. LINK
  3706.   then processes these records as fixups.
  3707.  
  3708. Examples
  3709. --------
  3710.  
  3711. For example, to generate a self-relative address whose TARGET is a
  3712. forward reference (JZ forwardlabel), the translator can insert the
  3713. negative offset of the next instruction (-*) from the start of the
  3714. SEGDEF record, followed by an additive backpatch (meaning that the
  3715. backpatch is added to the original value and the sum replaces the
  3716. original value) whose Value is the offset of the TARGET of the jump,
  3717. which is done last.
  3718.  
  3719.  
  3720. B4H OR B5H LEXTDEF--LOCAL EXTERNAL NAMES DEFINITION RECORD
  3721. ==========================================================
  3722.  
  3723. Description
  3724. -----------
  3725.  
  3726. This record is identical in form to the EXTDEF record described
  3727. earlier. However, the symbols named in this record are not visible
  3728. outside the module in which they are defined.
  3729.  
  3730. History
  3731. -------
  3732.  
  3733. This record was a Microsoft extension for C 5.0. There is no semantic
  3734. difference between the B4H and B5H types.
  3735.  
  3736. Record Format
  3737. -------------
  3738.  
  3739.    1    2        1       <String Length>  1 or 2  1
  3740.    B4   Record   String  External         Type    Checksum
  3741.    B5   Length   Length  Name String      Index   
  3742.                  <--------------repeated------->
  3743.   
  3744.   NOTE: These records are associated with LPUBDEF and LCOMDEF records
  3745.   and ordered with the EXTDEF records by occurrence, so that they may
  3746.   be referenced by an external name index for fixups.
  3747.   
  3748.   The name string, when stored in LINK's internal data structures, is
  3749.   encoded with spaces and digits at the beginning of the name.
  3750.  
  3751. Examples
  3752. --------
  3753.  
  3754. This record type is produced in C from static functions, such as:
  3755.    
  3756.    static int var() { }
  3757.  
  3758.  
  3759. B6H OR B7H LPUBDEF--LOCAL PUBLIC NAMES DEFINITION RECORD
  3760. ========================================================
  3761.  
  3762. Description
  3763. -----------
  3764.  
  3765. This record is identical in form to the PUBDEF record described
  3766. earlier. However, the symbols named in this record are not visible
  3767. outside the module in which they are defined.
  3768.  
  3769. History
  3770. -------
  3771.  
  3772. This record was a Microsoft extension for C 5.0. Record type B7H is
  3773. new for LINK386: the Local Offset field is 32 bits rather than 16
  3774. bits.
  3775.  
  3776. Record Format
  3777. -------------
  3778.    1  2       1 or 2 1 or 2 2      1      <String  2 or 4 1 or 2 1
  3779.                                            Length>  
  3780.    B6 Record  Base   Base    Base   String Local   Local   Type  Checksum
  3781.    or Length  Group  Segment Frame  Length Name    Offset  Index  
  3782.    B7                                      String 
  3783.                              <cond.><----------repeated---------->  
  3784.   
  3785. Examples
  3786. --------
  3787.  
  3788. In C, the static keyword on functions or initialized variables
  3789. produces LPUBDEF records. Uninitialized static variables produce
  3790. LCOMDEF records.
  3791.  
  3792.  
  3793. B8H LCOMDEF--LOCAL COMMUNAL NAMES DEFINITION RECORD
  3794. ===================================================
  3795.  
  3796. Description
  3797. -----------
  3798.  
  3799. This record is identical in form to the COMDEF record described
  3800. previously. However, the symbols named in this record are not visible
  3801. outside the module in which they are defined.
  3802.  
  3803. History
  3804. -------
  3805.  
  3806. This record was a Microsoft extension for C 5.0.
  3807.  
  3808. Record Format
  3809. -------------
  3810.  
  3811.    1  2       1       <String      1      1      <from      1
  3812.                       Length>      or 2          Data Type>
  3813.    B8 Record  String  Communal     Type   Data   Communal   Checksum
  3814.       Length  Length  Name         Index  Type   Length          
  3815.               <--------------repeated---------------------->  
  3816.  
  3817. Examples
  3818. --------
  3819.  
  3820. In C, uninitialized static variables produce an LCOMDEF record.
  3821.  
  3822.  
  3823. BCH CEXTDEF--COMDAT EXTERNAL NAMES DEFINITION RECORD
  3824. ====================================================
  3825.  
  3826. Description
  3827. -----------
  3828.  
  3829. This record serves the same purpose as the EXTDEF record described
  3830. earlier. However, the symbol named is referred to through a Logical
  3831. Name Index field. Such a Logical Name Index field is defined through
  3832. an LNAMES or LLNAMES record.
  3833.  
  3834. History
  3835. -------
  3836.  
  3837. The record is a Microsoft extension for C 7.0.
  3838.  
  3839. Record Format
  3840. -------------
  3841.  
  3842.                                             
  3843.    1    2      1 or 2          1 or 2       1
  3844.    BC   Record Logical Name    Type         Checksum
  3845.         Length Index           Index        
  3846.                <---------repeated-------->  
  3847.                
  3848.                
  3849.   NOTE: A CEXTDEF can precede the COMDAT to which it will be resolved.
  3850.   In this case, the location of the COMDAT is not known at the time
  3851.   the CEXTDEF is seen.
  3852.  
  3853. Examples
  3854. --------
  3855.  
  3856. This record is produced when a FIXUPP record refers to a COMDAT
  3857. symbol.
  3858.  
  3859.  
  3860. C2H OR C3H COMDAT--INITIALIZED COMMUNAL DATA RECORD
  3861. ===================================================
  3862.  
  3863. Description
  3864. -----------
  3865.  
  3866. The purpose of the COMDAT record is to combine logical blocks of code
  3867. and data that may be duplicated across a number of compiled modules.
  3868.  
  3869. History
  3870. -------
  3871.  
  3872. The record is a Microsoft extension for C 7.0.
  3873.  
  3874. Record Format
  3875. -------------
  3876.  1  2      1      1      1      2 or 4 1 or  2      1 or 2 1    1     
  3877.  C2 Record Flags  Attrib Align  Enumer Type  Public Public Data Check
  3878.  or Length        -utes         -ated  Index Base   Name        Sum  
  3879.  C3                             Data                Index     
  3880.                                 Offset                       
  3881.  
  3882.                                                     <repeated> 
  3883.                                                      
  3884. Flags Field
  3885. -----------
  3886.  
  3887. This field contains the following defined bits:
  3888.  
  3889.    01H   Continuation bit. If clear, this COMDAT record establishes
  3890.          a new instance of the COMDAT variable; otherwise, the data
  3891.          is a continuation of the previous COMDAT of the symbol.
  3892.          
  3893.    02H   Iterated data bit. If clear, the Data field contains
  3894.          enumerated data; otherwise, the Data field contains
  3895.          iterated data, as in an LIDATA record.
  3896.          
  3897.    04H   Local bit (effectively an "LCOMDAT"). This is used in
  3898.          preference to LLNAMES.
  3899.          
  3900.    08H   Data in code segment. If the application is overlayed, this
  3901.          COMDAT must be forced into the root text. Also, do not
  3902.          apply FARCALLTRANSLATION to this COMDAT.
  3903.  
  3904. Attributes Field
  3905. ----------------
  3906.           
  3907. This field contains two 4-bit fields: the Selection Criteria to be
  3908. used, and the Allocation Type, an ordinal specifying the type of
  3909. allocation to be performed. Values are:
  3910.  
  3911.    Selection Criteria (High-Order 4 Bits):
  3912.  
  3913.    Bit       Selection Criteria
  3914.                        
  3915.    00H       No match  Only one instance of this COMDAT allowed.
  3916.                        
  3917.    10H       Pick Any  Pick any instance of this COMDAT.
  3918.                        
  3919.    20H       Same      Pick any instance, but instances must have
  3920.              Size      the same length or the linker will generate
  3921.                        an error.
  3922.                        
  3923.    30H       Exact     Pick any instance, but checksums of the
  3924.              Match     instances must match or the linker will
  3925.                        generate an error. Fixups are ignored.
  3926.                        
  3927.    40H -               Reserved.
  3928.    F0H
  3929.  
  3930.    Allocation Type (Low-Order 4 bits):
  3931.    
  3932.    Bit       Allocation 
  3933.                                   
  3934.    00H       Explicit Allocate in the segment specified in the
  3935.                       ensuing Base Group, Base Segment, and Base
  3936.                       Frame fields.
  3937.                                           
  3938.    01H       Far      Allocate as CODE16. The linker will create
  3939.              Code     segments to contain all COMDATs of this type.
  3940.                       
  3941.    02H       Far      Allocate as DATA16. The linker will create
  3942.              Data     segments to contain all COMDATs of this type.
  3943.                       
  3944.    03H       Code32   Allocate as CODE32. The linker will create
  3945.                       segments to contain all COMDATs of this type.
  3946.                       
  3947.    04H       Data32   Allocate as DATA32. The linker will create
  3948.                       segments to contain all COMDATs of this type.
  3949.                       
  3950.    05H -              Reserved.
  3951.    0FH
  3952.  
  3953. Align Field
  3954.  
  3955. These codes are based on the ones used by the SEGDEF record:
  3956.    
  3957.    0   Use value from SEGDEF
  3958.    1   Byte aligned
  3959.    2   Word aligned
  3960.    3   Paragraph (16 byte) aligned
  3961.    4   256-byte aligned
  3962.    5   Double word (4 byte) aligned
  3963.    6   Not defined
  3964.    7   Not defined
  3965.  
  3966. Enumerated Data Offset Field
  3967. ----------------------------
  3968.           
  3969. This field specifies an offset relative to the beginning location of
  3970. the symbol specified in the Public Name Index field and defines the
  3971. relative location of the first byte of the Data field. Successive data
  3972. bytes in the Data field occupy higher locations of memory. This works
  3973. very much like the Enumerated Data Offset field in an LEDATA record,
  3974. but instead of an offset relative to a segment, this is relative to
  3975. the beginning of the COMDAT symbol.
  3976.  
  3977. Type Index Field
  3978. ----------------
  3979.  
  3980. The Type Index field is encoded in index format; it contains either
  3981. proprietary CodeView-type information or an old-style TYPDEF index. If
  3982. this index is 0, there is no associated type data. Old-style TYPDEF
  3983. indexes are ignored by LINK. Current linkers do not perform type
  3984. checking.
  3985.  
  3986. Public Base Field
  3987. -----------------
  3988.  
  3989. This field is conditional and is identical to the public base fields
  3990. (Base Group, Base Segment, and Base Frame) stored in the PUBDEF
  3991. record. This field is present only if the Allocation Type field
  3992. specifies Explicit allocation.
  3993.  
  3994. Public Name Index Field
  3995. -----------------------
  3996.  
  3997. This field is a regular logical name index (1 or 2 bytes).
  3998.  
  3999. Data Field
  4000. ----------
  4001.  
  4002. The Data field provides up to 1024 consecutive bytes of data. If there
  4003. are fixups, they must be emitted in a FIXUPP record that follows the
  4004. COMDAT record. The data can be either enumerated or iterated,
  4005. depending on the Flags field.
  4006.  
  4007.   NOTES
  4008.   
  4009.   Record type C3H has an Enumerated Data Offset field of 32 bits.
  4010.   
  4011.   While creating addressing frames, the linker will add the COMDAT
  4012.   data to the appropriate logical segments, adjusting their sizes. At
  4013.   that time, the offset at which the data will go inside the logical
  4014.   segment will be calculated. Next, the linker will create physical
  4015.   segments from adjusted logical segments, reporting any 64K boundary
  4016.   overflows.
  4017.   
  4018.   If the allocation type is not explicit, COMDAT code and data is
  4019.   accumulated by the linker and broken up into segments, so that the
  4020.   total can exceed 64K.
  4021.   
  4022.   In Pass 2, only the selected occurrence of COMDAT data will be
  4023.   stored in virtual memory, fixed up, and later written into the .EXE
  4024.   file.
  4025.   
  4026.   COMDATs are allocated in the order of their appearance in the .OBJ
  4027.   files if no explicit ordering is given.
  4028.   
  4029.   A COMDAT record cannot be continued across modules. A COMDAT record
  4030.   can be duplicated in a single module.
  4031.   
  4032.   If any COMDAT record on a given symbol has the local bit set, all
  4033.   the COMDAT records on that symbol have that bit set.
  4034.  
  4035.  
  4036. **********
  4037. Document 6
  4038. **********
  4039.  
  4040. C4H OR C5H LINSYM--SYMBOL LINE NUMBERS RECORD
  4041. =============================================
  4042.  
  4043. Description
  4044. -----------
  4045.  
  4046. This record will be used to output line numbers for functions
  4047. specified through COMDAT records. Each LINSYM record is associated
  4048. with a preceding COMDAT record.
  4049.  
  4050. History
  4051. -------
  4052.  
  4053. This record is a Microsoft extension for C 7.0.
  4054.  
  4055. Record Format
  4056. -------------
  4057.    1     2       1      1 or 2  2       2 or 4     1
  4058.    C4    Record  Flags  Public  Line    Line       Checksum
  4059.    or    Length         Name    Number  Number     
  4060.    C5                   Index           Offset     
  4061.                                 <---repeated--->   
  4062.  
  4063. Flags Field
  4064. -----------
  4065.           
  4066. This field contains one defined bit:
  4067.    
  4068.   01H   Continuation bit. If clear, this COMDAT record establishes a
  4069.         new instance of the COMDAT variable; otherwise, the data is a
  4070.         continuation of the previous COMDAT of the symbol.
  4071.    
  4072. Public Name Index Field
  4073. -----------------------
  4074.  
  4075. A regular logical name index, indicating the name of the base of the
  4076. LINSYM record.
  4077.  
  4078. Line Number Field
  4079. -----------------
  4080.  
  4081. An unsigned number in the range 0 to 65,535.
  4082.  
  4083. Line Number Offset Field
  4084. ------------------------
  4085.  
  4086. The offset relative to the base specified by the symbol name base. The
  4087. size of this field depends on the record type.
  4088.   
  4089.   NOTES
  4090.   
  4091.   Record type C5H is identical to C4H except that the Line Number
  4092.   Offset field is 4 bytes instead of 2.
  4093.   
  4094.   This record is used to output line numbers for functions specified
  4095.   through COMDAT records. Often, the residing segment as well as the
  4096.   relative offsets of such functions is unknown at compile time, in
  4097.   that the linker is the final arbiter of such information. For such
  4098.   cases, the compiler will generate this record to specify the line
  4099.   number/offset pairs relative to a symbolic name.
  4100.   
  4101.   This record will also be used to discard duplicate LINNUM
  4102.   information. If the linker encounters two or more LINSYM records
  4103.   with matching symbolic names (corresponding to multiple COMDAT
  4104.   records with the same name), the linker will keep the one that
  4105.   corresponds to the retained COMDAT.
  4106.   
  4107.   LINSYM records must follow the COMDATs to which they refer. A LINSYM
  4108.   on a given symbol refers to the most recent COMDAT on the same
  4109.   symbol.
  4110.   
  4111.   LINSYMs inherit the "localness" of their COMDATs.
  4112.  
  4113.  
  4114. C6H ALIAS--ALIAS DEFINITION RECORD
  4115. ==================================
  4116.  
  4117. Description
  4118. -----------
  4119.  
  4120. This record has been introduced to support link-time aliasing, a
  4121. method by which compilers or assemblers may direct the linker to
  4122. substitute all references to one symbol for another.
  4123.  
  4124. History
  4125. -------
  4126.  
  4127. The record is a Microsoft extension for FORTRAN version 5.1 (LINK
  4128. version 5.13).
  4129.  
  4130. Record Format
  4131. -------------
  4132.  
  4133.    1   2              <variable>   <variable>         1
  4134.    C6  Record Length  Alias Name   Substitute Name    Checksum
  4135.                       <-----------repeated--------->  
  4136.    
  4137.    Alias Name Field
  4138.    ----------------
  4139.    
  4140.    A regular length-preceded name of the alias symbol.
  4141.    
  4142.    Substitute Name Field
  4143.    ---------------------
  4144.    
  4145.    A regular length-preceded name of the substitute symbol.
  4146.    
  4147.   NOTES
  4148.   
  4149.   This record consists of two symbolic names: the alias symbol and the
  4150.   substitute symbol. The alias symbol behaves very much like a PUBDEF
  4151.   in that it must be unique. If a PUBDEF of an alias symbol is
  4152.   encountered later, the PUBDEF overrides the alias. If another ALIAS
  4153.   record with a different substitute symbol is encountered, a warning
  4154.   is emitted by the linker, and the second substitute symbol is used.
  4155.   
  4156.   When attempting to satisfy an external reference, if an ALIAS record
  4157.   whose alias symbol matches is found, the linker will halt the search
  4158.   for alias symbol definitions and will attempt to satisfy the
  4159.   reference with the substitute symbol.
  4160.   
  4161.   All ALIAS records must appear before the LINK Pass 2 record.
  4162.  
  4163.  
  4164. C8H OR C9H NBKPAT--NAMED BACKPATCH RECORD
  4165. =========================================
  4166.  
  4167. Description
  4168. -----------
  4169.  
  4170. The Named Backpatch record is similar to a BAKPAT record, except that
  4171. it refers to a COMDAT record, by logical name index, rather than an
  4172. LIDATA or LEDATA record. NBKPAT records must immediately follow the
  4173. COMDAT/FIXUPP block to which they refer.
  4174.  
  4175. History
  4176. -------
  4177.  
  4178. This record is a Microsoft extension for C 7.0.
  4179.  
  4180. Record Format
  4181. -------------
  4182.    
  4183.    1      2        1          1 or 2  2 or 4   2 or 4  1
  4184.    C8     Record   Location   Public  Offset   Value   Checksum
  4185.    or C9  Length   Type       Name
  4186.                                       <---repeated---> 
  4187.                                 
  4188. Location Type Field
  4189. -------------------
  4190.           
  4191. Type of location to be patched; the only valid values are:
  4192.    
  4193.    0    8-bit byte
  4194.    1    16-bit word
  4195.    2    32-bit double word, record type C9H only
  4196.  
  4197. Public Name Index Field
  4198. -----------------------
  4199.           
  4200. Regular logical name index of the COMDAT record to be back patched.
  4201.  
  4202. Offset and Value Fields
  4203. -----------------------
  4204.    
  4205. These fields are 32 bits for record type C8H, 16 bits for C9H.
  4206.  
  4207. The Offset field specifies the location to be patched, as an offset
  4208. into the COMDAT.
  4209.  
  4210. The associated Value field is added to the location being patched
  4211. (unsigned addition, ignoring overflow). The Value field is a fixed
  4212. length (16 bits or 32 bits, depending on the record type) to make
  4213. object module processing easier.
  4214.  
  4215.  
  4216. CAH LLNAMES--LOCAL LOGICAL NAMES DEFINITION RECORD
  4217. ==================================================
  4218.  
  4219. Description
  4220. -----------
  4221.  
  4222. The LLNAMES record is a list of local names that can be referenced by
  4223. subsequent SEGDEF and GRPDEF records in the object module.
  4224.  
  4225. The names are ordered by their occurrence, with the names in LNAMES
  4226. records and referenced by index from subsequent records. More than one
  4227. LNAMES and LLNAMES record may appear. The names themselves are used as
  4228. segment, class, group, overlay, COMDAT, and selector names.
  4229.  
  4230. History
  4231. -------
  4232.  
  4233. This record is a Microsoft extension for C 7.0.
  4234.  
  4235. Record Format
  4236. -------------
  4237.    
  4238.    1         2         1         <--String Length--> 1
  4239.    CA        Record    String    Name                Checksum
  4240.              Length    Length    String              
  4241.                        <----------repeated---------> 
  4242.  
  4243. Each name appears in <count, char> format, and a null name is valid.
  4244. The character set is ASCII. Names can be up to 254 characters long.
  4245.  
  4246.   NOTE: Any LLNAMES records in an object module must appear before the
  4247.   records that refer to them.
  4248.   
  4249.  
  4250. APPENDIX 1: CODEVIEW EXTENSIONS
  4251. ===============================
  4252.  
  4253. Calling the following information "CodeView's OMF" is a misnomer,
  4254. since CodeView actually does very little to extend the OMF. Most
  4255. CodeView information is stored within the confines of the existing
  4256. OMF, except where noted below.
  4257.  
  4258. CodeView information is stored on a per-module basis in specially-
  4259. named logical segments. These segments are defined in the usual way
  4260. (SEGDEF records), but LINK handles them specially, and they do not end
  4261. up as segments in the .EXE file. These segment names are reserved:
  4262.  
  4263.    Segment Name        Class Name          Combine Type
  4264.    ------------        ----------          ------------
  4265.  
  4266.    $$TYPES             DEBTYP              Private
  4267.    $$SYMBOLS           DEBSYM              Private
  4268.  
  4269. The segment $$IMPORT should also be considered a reserved name,
  4270. although it is not used anymore. This segment was not part of any
  4271. object files but was emitted by the linker to get the loader to
  4272. automatically do fixups for CodeView information. The linker emitted a
  4273. standard set of imports, not just ones referenced by the program being
  4274. linked. Use of this segment may be revisited in the future.
  4275.  
  4276. CodeView-specific data is stored in LEDATA records for the $$TYPES and
  4277. $$SYMBOLS segments, in various proprietary formats. The $$TYPES
  4278. segment contains information on user-defined variable types; $$SYMBOLS
  4279. contains information about nonpublic symbols: stack, local, procedure,
  4280. block start, constant, and register symbols and code labels.
  4281.  
  4282. For instantiated functions in C 7.0, symbol information for CodeView
  4283. will be output in COMDAT records that refer to segment $$SYMBOLS and
  4284. have decorated names based on the function names. Type information
  4285. will still go into the $$TYPES segment in LEDATA records.
  4286.  
  4287. All OMF records that specify a Type Index field, including EXTDEF,
  4288. PUBDEF, and COMDEF records, use proprietary CodeView values. Since
  4289. many types are common, Type Index values in the range 0 through 511
  4290. (1FFH) are reserved for a set of predefined primitive types. Indexes
  4291. in the range 512 through 32767 (200H-7FFFH) index into the set of type
  4292. definitions in the module's $$TYPES segment, offset by 512. Thus 512
  4293. is the first new type, 513 the second, and so on.
  4294.  
  4295.  
  4296. APPENDIX 2: MICROSOFT MS-DOS LIBRARY FORMAT
  4297. ===========================================
  4298.  
  4299. Libraries under MS-DOS are always multiples of 512-byte blocks.
  4300.  
  4301. The first record in the library is a header. This first record looks
  4302. very much like any other Microsoft object module format record.
  4303.  
  4304.   Library Header Record (<n> bytes)
  4305.   ---------------------------------
  4306.                                                              
  4307.    1     2                    4           2            1       <n - 10>
  4308.    Type  Record Length        Dictionary  Dictionary   Flags   Padding
  4309.                               Offest      Size
  4310.    (F0H)  (Page Size Minus 3)             in Blocks            
  4311.     
  4312.    The first byte of the record identifies the record's type, and the
  4313.    next two bytes specify the number of bytes remaining in the record.
  4314.    Note that this word field is byte-swapped (that is, the low-order
  4315.    byte precedes the high-order byte). The record type for this
  4316.    library header is F0H (240 decimal).
  4317.    
  4318.    The Record Length field specifies the page size within the library.
  4319.    Modules in a library always start at the beginning of a page. Page
  4320.    size is determined by adding three to the value in the Record
  4321.    Length field (thus the header record always occupies exactly one
  4322.    page). Legal values for the page size are given by 2 to the <n>,
  4323.    where <n> is greater than or equal to 4 and less than or equal to
  4324.    15.
  4325.    
  4326.    The four bytes immediately following the Record Length field are a
  4327.    byte-swapped long integer specifying the byte offset within the
  4328.    library of the first byte of the first block of the dictionary.
  4329.    
  4330.    The next two bytes are a byte-swapped word field that specifies the
  4331.    number of blocks in the dictionary. (The MS-DOS Library Manager
  4332.    cannot create a library whose dictionary would require more than
  4333.    251 512-byte pages.)
  4334.    
  4335.    The next byte contains flags describing the library. The current
  4336.    flag definition is:
  4337.    
  4338.      0x01 = case sensitive (applies to both regular and extended
  4339.      dictionaries)
  4340.      
  4341.    All other values are reserved for future use and should be 0.
  4342.    
  4343.    The remaining bytes in the library header record are not
  4344.    significant. This record deviates from the typical Microsoft OMF
  4345.    record in that the last byte is not used as a checksum on the rest
  4346.    of the record.
  4347.  
  4348. Immediately following the header is the first object module in the
  4349. library. It, in turn, is succeeded by all other object modules in the
  4350. library. Each module is in Microsoft OMF (that is, it starts with a
  4351. LHEADR record and ends with a MODEND record). Individual modules are
  4352. aligned so as to begin at the beginning of a new page. If, as is
  4353. commonly the case, a module does not occupy a number of bytes that is
  4354. exactly a multiple of the page size, then its last block will be
  4355. padded with as many null bytes as are required to fill it.
  4356.  
  4357. Following the last object module in the library is a record that
  4358. serves as a marker between the object modules and the dictionary. It
  4359. also resembles a Microsoft OMF record.
  4360.  
  4361.    Library End Record (marks end of objects and beginning of
  4362.    dictionary)
  4363.  
  4364.    1           2                 <n>
  4365.    Type (F1H)  Record Length     Padding
  4366.    
  4367.    The record's Type field contains F1H (241 decimal), and its Record
  4368.    Length field is set so that the dictionary begins on a 512-byte
  4369.    boundary. The record contains no further useful information; the
  4370.    remaining bytes are insignificant. As with the library header, the
  4371.    last byte is not a checksum.
  4372.  
  4373. Dictionary
  4374. ----------
  4375.    
  4376. The remaining blocks in the library compose the dictionary. The number
  4377. of blocks in the dictionary is given in the library header. Note that
  4378. there should always be a prime number of blocks in the dictionary.
  4379.  
  4380. The dictionary is a hashed index to the library. Public symbols are
  4381. essentially hashed twice, though in fact, both hash indexes are
  4382. produced simultaneously. The first hash index, the block index, is
  4383. used to determine a block within the dictionary in which to place the
  4384. symbol. The second hash index, the bucket index, is used to choose a
  4385. bucket within the block for the symbol. Blocks always have 37 buckets;
  4386. they are the first 37 bytes of each block. If a bucket is full, it
  4387. contains a nonzero value that points to the text of the symbol. To
  4388. actually find the symbol, take the bucket value, multiply it by two,
  4389. and use the resulting number as a byte offset from the beginning of
  4390. the block.
  4391.  
  4392. Collisions (that is, two or more distinct symbols hashing to the same
  4393. block and bucket in the dictionary) are resolved by a technique known
  4394. as linear open addressing. At the same time the hash indexes are
  4395. produced, two hash deltas are also produced. If a symbol collides with
  4396. a symbol already installed in the dictionary, the librarian attempts
  4397. to find an empty bucket for it by adding the bucket delta to the
  4398. bucket index and using the result mod 37 as a new bucket index. If
  4399. this new bucket index points to a bucket that is empty, the librarian
  4400. will install the symbol in that bucket. If the bucket is not empty,
  4401. the delta is applied repeatedly until an empty bucket is found or
  4402. until it is determined that there are no empty buckets on the block.
  4403. If the latter is the case, the block delta is added to the block
  4404. index, and the result mod the number of blocks in the dictionary is
  4405. used as a new block index. With the new block index and the original
  4406. bucket index, the sequence is repeated until an empty bucket on some
  4407. block is found.
  4408.  
  4409. The number of blocks and the number of buckets are prime so that no
  4410. matter what values of hash indexes and deltas are produced for a
  4411. symbol, in the worst case, all possible block-bucket combinations will
  4412. be tried. Once a free block-bucket pair has been found for a symbol,
  4413. the pair and information concerning its place of definition must be
  4414. installed. Since a bucket is a single byte pointing into a 512-byte
  4415. block, the bucket can give at best a word offset within that block.
  4416. Thus, symbol entries within a dictionary must start on word
  4417. boundaries. Since bytes 0 through 36 of each dictionary block make up
  4418. the hash table, the first symbol entry will begin at byte 38
  4419. (decimal).
  4420.  
  4421.    Dictionary Record (length is the dictionary size in 512-byte
  4422.    blocks)
  4423.  
  4424.    37     1      <variable>  2                <conditional>
  4425.    HTAB   FFLAG  Name        Block Number      Align Byte
  4426.                  <-------------------repeated------------->
  4427.    
  4428.    Entries consist of the following: the first byte is the length of
  4429.    the symbol to follow, the following bytes are the text of the
  4430.    symbol, and the last two bytes are a byte-swapped word field that
  4431.    specifies the page number (counting the library header as the 0th
  4432.    page) at which the module defining the symbol begins.
  4433.    
  4434.    All entries may have at most one trailing null byte in order to
  4435.    align the next entry on a word boundary.
  4436.    
  4437.    It is possible for a dictionary block to be full without all its
  4438.    buckets being used. Such will be the case, for example, if symbol
  4439.    names are longer on average than nine characters each. Therefore,
  4440.    there must be some way to mark a block as full so that empty
  4441.    buckets will be ignored.
  4442.    
  4443.    Byte 37 decimal (counting from 0) is reserved for this purpose. If
  4444.    the block is not full, byte 37 will contain the word offset of the
  4445.    beginning of free space in the block, but if the block is full,
  4446.    byte 37 will contain the special value 255 decimal (FFH). Module
  4447.    names are stored in the LHEADR record of each module.
  4448.    
  4449. Extended Dictionary
  4450. -------------------
  4451.  
  4452. The extended dictionary is optional and indicates dependencies between
  4453. modules in the library. Versions of LIB earlier than 3.09 do not
  4454. create an extended dictionary. The extended dictionary is placed at
  4455. the end of the library.
  4456.  
  4457. The dictionary is preceded by these values:
  4458.  
  4459.    BYTE =0xF2 Extended Dictionary header
  4460.    WORD length of extended dictionary in bytes excluding first three
  4461.         bytes
  4462.  
  4463. Start of extended dictionary:
  4464.  
  4465.    WORD number of modules in library = N
  4466.  
  4467. Module table, indexed by module number, with N + 1 fixed-length
  4468. entries:
  4469.  
  4470.    WORD module page number
  4471.    WORD offset from start of extended dictionary to list of required
  4472.         modules
  4473.  
  4474. Last entry is null.
  4475.  
  4476. Dictionary Hashing Algorithm
  4477. ----------------------------
  4478.  
  4479. The last part of each library file is a dictionary, which contains
  4480. indexes to all symbols in the library. The dictionary is divided into
  4481. 512-byte pages. Each page consists of a 37-byte bucket table and a 475-
  4482. byte table of symbol entries.
  4483.  
  4484. To find the right spot in the dictionary for a given symbol, the
  4485. hashing algorithm is used. The hashing algorithm analyzes the name of
  4486. the symbol and produces two indexes: a page and a bucket index, which
  4487. together point to a single entry in the dictionary. The only problem
  4488. is that more than one symbol name can generate exactly the same
  4489. address. Because of this, the name found in the dictionary entry must
  4490. be compared with the symbol's name, and if they are not identical, a
  4491. correction to the address must be made. To make this correction
  4492. possible, the hashing algorithm, in addition to the base address
  4493. (page, bucket), also produces the correction values (delta-page, delta-
  4494. bucket), which are added to the base address if the symbol's name does
  4495. not match the name in an entry. The number of pages in the dictionary
  4496. must always be prime, so if the symbol is not found, the consecutive
  4497. adding of deltas produces the starting address again.
  4498.  
  4499. Below is psueudocode illustrating the hashing algorithm used by the
  4500. LIB (librarian) utility.
  4501.  
  4502.    extern char *symbol;   /* Symbol to find        */
  4503.    extern int dictlength;  /* Dictionary length in pages  */
  4504.    extern int buckets;   /* Number of buckets on one page */
  4505.    
  4506.    
  4507.    
  4508.    char *pb;  /* A pointer to the beginning of the symbol  */
  4509.    char *pe;  /*   "      end     "      */
  4510.    int slength;  /* Length of the symbol's name      */
  4511.    
  4512.    int page_index;   /*  Page index           */
  4513.    int page_index_delta;/*  Page index delta        */
  4514.    int page_offset;   /*  Page offset (bucket #)     */
  4515.    int page_offset_delta;/* Page offset delta        */
  4516.    
  4517.    unsigned c;
  4518.    
  4519.    slength = strlen(symbol);
  4520.    pb = symbol;
  4521.    pe = symbol + slength;
  4522.    page_index = 0;
  4523.    page_index_delta = 0;
  4524.    page_offset = 0;
  4525.    page_offset_delta = 0;
  4526.    
  4527.    while( slength-)
  4528.    {
  4529.         c = *(pf++) | 32; /* Convert character to lowercase */
  4530.         page_index = (page_index<<2) XOR c;    /* Hash */
  4531.         page_offset_delta = (page_offset_delta>>2)XORc;
  4532.         c = *(pe++) | 32;
  4533.         page_offset = (page_offset>>2) XOR c;     /* Hash */
  4534.         pageiindexdelta = (page_index_delta<<2) XOR c;
  4535.    }
  4536.    
  4537.    /* Calculate page index */
  4538.    page_index = page_index MODULO dictlength;
  4539.    
  4540.    
  4541.    /* Calculate page index delta */
  4542.    if((page_index_delta = page_index_delta MODULO dictlength) == 0)
  4543.         page_index_delta = 1;
  4544.    
  4545.    
  4546.    /* Calculate page offset */
  4547.    page_offset = page_offset MODULO buckets;
  4548.    
  4549.    
  4550.    /* Calculate page offset delta */
  4551.    if( (page_offset_delta = page_offset_delta MODULO buckets) == 0)
  4552.      page_offset_delta = 1;
  4553.