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