Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

443 lines
16 KiB

  1. /*** cvexefmt.h - format of CodeView information in exe
  2. *
  3. * Structures, constants, etc. for reading CodeView information
  4. * from the executable.
  5. *
  6. */
  7. /*** The master copy of this file resides in the LANGAPI project.
  8. * All Microsoft projects are required to use the master copy without
  9. * modification. Modification of the master version or a copy
  10. * without consultation with all parties concerned is extremely
  11. * risky.
  12. *
  13. */
  14. #ifndef _VC_VER_INC
  15. #include "..\include\vcver.h"
  16. #endif
  17. // The following structures and constants describe the format of the
  18. // CodeView Debug OMF for that will be accepted by CodeView 4.0 and
  19. // later. These are executables with signatures of NB05, NB06 and NB08.
  20. // There is some confusion about the signatures NB03 and NB04 so none
  21. // of the utilites will accept executables with these signatures. NB07 is
  22. // the signature for QCWIN 1.0 packed executables.
  23. // All of the structures described below must start on a long word boundary
  24. // to maintain natural alignment. Pad space can be inserted during the
  25. // write operation and the addresses adjusted without affecting the contents
  26. // of the structures.
  27. #ifndef _CV_INFO_INCLUDED
  28. #include "cvinfo.h"
  29. #endif
  30. #ifndef FAR
  31. #if _M_IX86 >= 300
  32. #define FAR
  33. #else
  34. #define FAR far
  35. #endif
  36. #endif
  37. // Type of subsection entry.
  38. #define sstModule 0x120
  39. #define sstTypes 0x121
  40. #define sstPublic 0x122
  41. #define sstPublicSym 0x123 // publics as symbol (waiting for link)
  42. #define sstSymbols 0x124
  43. #define sstAlignSym 0x125
  44. #define sstSrcLnSeg 0x126 // because link doesn't emit SrcModule
  45. #define sstSrcModule 0x127
  46. #define sstLibraries 0x128
  47. #define sstGlobalSym 0x129
  48. #define sstGlobalPub 0x12a
  49. #define sstGlobalTypes 0x12b
  50. #define sstMPC 0x12c
  51. #define sstSegMap 0x12d
  52. #define sstSegName 0x12e
  53. #define sstPreComp 0x12f // precompiled types
  54. #define sstPreCompMap 0x130 // map precompiled types in global types
  55. #define sstOffsetMap16 0x131
  56. #define sstOffsetMap32 0x132
  57. #define sstFileIndex 0x133 // Index of file names
  58. #define sstStaticSym 0x134
  59. typedef enum OMFHash {
  60. OMFHASH_NONE, // no hashing
  61. OMFHASH_SUMUC16, // upper case sum of chars in 16 bit table
  62. OMFHASH_SUMUC32, // upper case sum of chars in 32 bit table
  63. OMFHASH_ADDR16, // sorted by increasing address in 16 bit table
  64. OMFHASH_ADDR32 // sorted by increasing address in 32 bit table
  65. } OMFHASH;
  66. // CodeView Debug OMF signature. The signature at the end of the file is
  67. // a negative offset from the end of the file to another signature. At
  68. // the negative offset (base address) is another signature whose filepos
  69. // field points to the first OMFDirHeader in a chain of directories.
  70. // The NB05 signature is used by the link utility to indicated a completely
  71. // unpacked file. The NB06 signature is used by ilink to indicate that the
  72. // executable has had CodeView information from an incremental link appended
  73. // to the executable. The NB08 signature is used by cvpack to indicate that
  74. // the CodeView Debug OMF has been packed. CodeView will only process
  75. // executables with the NB08 signature.
  76. typedef struct OMFSignature {
  77. char Signature[4]; // "NBxx"
  78. long filepos; // offset in file
  79. } OMFSignature;
  80. // directory information structure
  81. // This structure contains the information describing the directory.
  82. // It is pointed to by the signature at the base address or the directory
  83. // link field of a preceeding directory. The directory entries immediately
  84. // follow this structure.
  85. typedef struct OMFDirHeader {
  86. unsigned short cbDirHeader; // length of this structure
  87. unsigned short cbDirEntry; // number of bytes in each directory entry
  88. unsigned long cDir; // number of directorie entries
  89. long lfoNextDir; // offset from base of next directory
  90. unsigned long flags; // status flags
  91. } OMFDirHeader;
  92. // directory structure
  93. // The data in this structure is used to reference the data for each
  94. // subsection of the CodeView Debug OMF information. Tables that are
  95. // not associated with a specific module will have a module index of
  96. // oxffff. These tables are the global types table, the global symbol
  97. // table, the global public table and the library table.
  98. typedef struct OMFDirEntry {
  99. unsigned short SubSection; // subsection type (sst...)
  100. unsigned short iMod; // module index
  101. long lfo; // large file offset of subsection
  102. unsigned long cb; // number of bytes in subsection
  103. } OMFDirEntry;
  104. // information decribing each segment in a module
  105. typedef struct OMFSegDesc {
  106. unsigned short Seg; // segment index
  107. unsigned short pad; // pad to maintain alignment
  108. unsigned long Off; // offset of code in segment
  109. unsigned long cbSeg; // number of bytes in segment
  110. } OMFSegDesc;
  111. // per module information
  112. // There is one of these subsection entries for each module
  113. // in the executable. The entry is generated by link/ilink.
  114. // This table will probably require padding because of the
  115. // variable length module name.
  116. typedef struct OMFModule {
  117. unsigned short ovlNumber; // overlay number
  118. unsigned short iLib; // library that the module was linked from
  119. unsigned short cSeg; // count of number of segments in module
  120. char Style[2]; // debugging style "CV"
  121. OMFSegDesc SegInfo[1]; // describes segments in module
  122. char Name[]; // length prefixed module name padded to
  123. // long word boundary
  124. } OMFModule;
  125. // Symbol hash table format
  126. // This structure immediately preceeds the global publics table
  127. // and global symbol tables.
  128. typedef struct OMFSymHash {
  129. unsigned short symhash; // symbol hash function index
  130. unsigned short addrhash; // address hash function index
  131. unsigned long cbSymbol; // length of symbol information
  132. unsigned long cbHSym; // length of symbol hash data
  133. unsigned long cbHAddr; // length of address hashdata
  134. } OMFSymHash;
  135. // Global types subsection format
  136. // This structure immediately preceeds the global types table.
  137. // The offsets in the typeOffset array are relative to the address
  138. // of ctypes. Each type entry following the typeOffset array must
  139. // begin on a long word boundary.
  140. typedef struct OMFTypeFlags {
  141. unsigned long sig :8;
  142. unsigned long unused :24;
  143. } OMFTypeFlags;
  144. typedef struct OMFGlobalTypes {
  145. OMFTypeFlags flags;
  146. unsigned long cTypes; // number of types
  147. unsigned long typeOffset[]; // array of offsets to types
  148. } OMFGlobalTypes;
  149. // Precompiled types mapping table
  150. // This table should be ignored by all consumers except the incremental
  151. // packer.
  152. typedef struct OMFPreCompMap {
  153. CV_typ_t FirstType; // first precompiled type index
  154. CV_typ_t cTypes; // number of precompiled types
  155. unsigned long signature; // precompiled types signature
  156. CV_typ_t map[]; // mapping of precompiled types
  157. } OMFPreCompMap;
  158. // Source line to address mapping table.
  159. // This table is generated by the link/ilink utility from line number
  160. // information contained in the object file OMF data. This table contains
  161. // only the code contribution for one segment from one source file.
  162. typedef struct OMFSourceLine {
  163. unsigned short Seg; // linker segment index
  164. unsigned short cLnOff; // count of line/offset pairs
  165. unsigned long offset[1]; // array of offsets in segment
  166. unsigned short lineNbr[1]; // array of line lumber in source
  167. } OMFSourceLine;
  168. typedef OMFSourceLine * LPSL;
  169. // Source file description
  170. // This table is generated by the linker
  171. typedef struct OMFSourceFile {
  172. unsigned short cSeg; // number of segments from source file
  173. unsigned short reserved; // reserved
  174. unsigned long baseSrcLn[1]; // base of OMFSourceLine tables
  175. // this array is followed by array
  176. // of segment start/end pairs followed by
  177. // an array of linker indices
  178. // for each segment in the file
  179. unsigned short cFName; // length of source file name
  180. char Name; // name of file padded to long boundary
  181. } OMFSourceFile;
  182. typedef OMFSourceFile * LPSF;
  183. // Source line to address mapping header structure
  184. // This structure describes the number and location of the
  185. // OMFAddrLine tables for a module. The offSrcLine entries are
  186. // relative to the beginning of this structure.
  187. typedef struct OMFSourceModule {
  188. unsigned short cFile; // number of OMFSourceTables
  189. unsigned short cSeg; // number of segments in module
  190. unsigned long baseSrcFile[1]; // base of OMFSourceFile table
  191. // this array is followed by array
  192. // of segment start/end pairs followed
  193. // by an array of linker indices
  194. // for each segment in the module
  195. } OMFSourceModule;
  196. typedef OMFSourceModule * LPSM;
  197. // sstLibraries
  198. typedef struct OMFLibrary {
  199. unsigned char cbLibs; // count of library names
  200. char Libs[1]; // array of length prefixed lib names (first entry zero length)
  201. } OMFLibrary;
  202. // sstFileIndex - An index of all of the files contributing to an
  203. // executable.
  204. typedef struct OMFFileIndex {
  205. unsigned short cmodules; // Number of modules
  206. unsigned short cfilerefs; // Number of file references
  207. unsigned short modulelist[1]; // Index to beginning of list of files
  208. // for module i. (0 for module w/o files)
  209. unsigned short cfiles[1]; // Number of file names associated
  210. // with module i.
  211. unsigned long ulNames[1]; // Offsets from the beginning of this
  212. // table to the file names
  213. char Names[]; // The length prefixed names of files
  214. } OMFFileIndex;
  215. // Offset mapping table
  216. // This table provides a mapping from logical to physical offsets.
  217. // This mapping is applied between the logical to physical mapping
  218. // described by the seg map table.
  219. typedef struct OMFOffsetMap16 {
  220. unsigned long csegment; // Count of physical segments
  221. // The next six items are repeated for each segment
  222. unsigned long crangeLog; // Count of logical offset ranges
  223. unsigned short rgoffLog[1]; // Array of logical offsets
  224. short rgbiasLog[1]; // Array of logical->physical bias
  225. unsigned long crangePhys; // Count of physical offset ranges
  226. unsigned short rgoffPhys[1]; // Array of physical offsets
  227. short rgbiasPhys[1]; // Array of physical->logical bias
  228. } OMFOffsetMap16;
  229. typedef struct OMFOffsetMap32 {
  230. unsigned long csection; // Count of physical sections
  231. // The next six items are repeated for each section
  232. unsigned long crangeLog; // Count of logical offset ranges
  233. unsigned long rgoffLog[1]; // Array of logical offsets
  234. long rgbiasLog[1]; // Array of logical->physical bias
  235. unsigned long crangePhys; // Count of physical offset ranges
  236. unsigned long rgoffPhys[1]; // Array of physical offsets
  237. long rgbiasPhys[1]; // Array of physical->logical bias
  238. } OMFOffsetMap32;
  239. // Pcode support. This subsection contains debug information generated
  240. // by the MPC utility used to process Pcode executables. Currently
  241. // it contains a mapping table from segment index (zero based) to
  242. // frame paragraph. MPC converts segmented exe's to non-segmented
  243. // exe's for DOS support. To avoid backpatching all CV info, this
  244. // table is provided for the mapping. Additional info may be provided
  245. // in the future for profiler support.
  246. typedef struct OMFMpcDebugInfo {
  247. unsigned short cSeg; // number of segments in module
  248. unsigned short mpSegFrame[1]; // map seg (zero based) to frame
  249. } OMFMpcDebugInfo;
  250. // The following structures and constants describe the format of the
  251. // CodeView Debug OMF for linkers that emit executables with the NB02
  252. // signature. Current utilities with the exception of cvpack and cvdump
  253. // will not accept or emit executables with the NB02 signature. Cvdump
  254. // will dump an unpacked executable with the NB02 signature. Cvpack will
  255. // read an executable with the NB02 signature but the packed executable
  256. // will be written with the table format, contents and signature of NB08.
  257. // subsection type constants
  258. #define SSTMODULE 0x101 // Basic info. about object module
  259. #define SSTPUBLIC 0x102 // Public symbols
  260. #define SSTTYPES 0x103 // Type information
  261. #define SSTSYMBOLS 0x104 // Symbol Data
  262. #define SSTSRCLINES 0x105 // Source line information
  263. #define SSTLIBRARIES 0x106 // Names of all library files used
  264. #define SSTIMPORTS 0x107 // Symbols for DLL fixups
  265. #define SSTCOMPACTED 0x108 // Compacted types section
  266. #define SSTSRCLNSEG 0x109 // Same as source lines, contains segment
  267. typedef struct DirEntry{
  268. unsigned short SubSectionType;
  269. unsigned short ModuleIndex;
  270. long lfoStart;
  271. unsigned short Size;
  272. } DirEntry;
  273. // information decribing each segment in a module
  274. typedef struct oldnsg {
  275. unsigned short Seg; // segment index
  276. unsigned short Off; // offset of code in segment
  277. unsigned short cbSeg; // number of bytes in segment
  278. } oldnsg;
  279. // old subsection module information
  280. typedef struct oldsmd {
  281. oldnsg SegInfo; // describes first segment in module
  282. unsigned short ovlNbr; // overlay number
  283. unsigned short iLib;
  284. unsigned char cSeg; // Number of segments in module
  285. char reserved;
  286. unsigned char cbName[1]; // length prefixed name of module
  287. oldnsg arnsg[]; // cSeg-1 structures exist for alloc text or comdat code
  288. } oldsmd;
  289. typedef struct{
  290. unsigned short Seg;
  291. unsigned long Off;
  292. unsigned long cbSeg;
  293. } oldnsg32;
  294. typedef struct {
  295. oldnsg32 SegInfo; // describes first segment in module
  296. unsigned short ovlNbr; // overlay number
  297. unsigned short iLib;
  298. unsigned char cSeg; // Number of segments in module
  299. char reserved;
  300. unsigned char cbName[1]; // length prefixed name of module
  301. oldnsg32 arnsg[]; // cSeg-1 structures exist for alloc text or comdat code
  302. } oldsmd32;
  303. // OMFSegMap - This table contains the mapping between the logical segment indices
  304. // used in the symbol table and the physical segments where the program is loaded
  305. typedef struct OMFSegMapFlags {
  306. union {
  307. struct {
  308. unsigned short fRead :1;
  309. unsigned short fWrite :1;
  310. unsigned short fExecute:1;
  311. unsigned short f32Bit :1;
  312. unsigned short res1 :4;
  313. unsigned short fSel :1;
  314. unsigned short fAbs :1;
  315. unsigned short res2 :2;
  316. unsigned short fGroup :1; // OBSOLETE - do not use, debugger will assert
  317. unsigned short res3 :3;
  318. };
  319. unsigned short fAll;
  320. };
  321. } OMFSegMapFlags;
  322. typedef struct OMFSegMapDesc {
  323. OMFSegMapFlags flags; // descriptor flags bit field.
  324. unsigned short ovl; // the logical overlay number
  325. unsigned short group; // group index into the descriptor array
  326. unsigned short frame; // logical segment index - interpreted via flags
  327. unsigned short iSegName; // segment or group name - index into sstSegName
  328. unsigned short iClassName; // class name - index into sstSegName
  329. unsigned long offset; // byte offset of the logical within the physical segment
  330. unsigned long cbSeg; // byte count of the logical segment or group
  331. } OMFSegMapDesc;
  332. typedef struct OMFSegMap {
  333. unsigned short cSeg; // total number of segment descriptors
  334. unsigned short cSegLog; // number of logical segment descriptors
  335. OMFSegMapDesc rgDesc[0]; // array of segment descriptors
  336. } OMFSegMap;