Leaked source code of windows server 2003
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.

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