Windows NT 4.0 source code leak
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.

487 lines
18 KiB

4 years ago
  1. /*
  2. * |-----------------------------------------------------------|
  3. * | Copyright (c) 1990 MIPS Computer Systems, Inc. |
  4. * | All Rights Reserved |
  5. * |-----------------------------------------------------------|
  6. * | Restricted Rights Legend |
  7. * | Use, duplication, or disclosure by the Government is |
  8. * | subject to restrictions as set forth in |
  9. * | subparagraph (c)(1)(ii) of the Rights in Technical |
  10. * | Data and Computer Software Clause of DFARS 52.227-7013. |
  11. * | MIPS Computer Systems, Inc. |
  12. * | 950 DeGuigne Drive |
  13. * | Sunnyvale, CA 94086 |
  14. * |-----------------------------------------------------------|
  15. */
  16. /* $Header: sym.h,v 2020.2.2.1 91/02/25 17:49:34 jalal Exp $ */
  17. #ifndef __SYM_H
  18. #define __SYM_H
  19. /* (C) Copyright 1984 by Third Eye Software, Inc.
  20. *
  21. * Third Eye Software, Inc. grants reproduction and use rights to
  22. * all parties, PROVIDED that this comment is maintained in the copy.
  23. *
  24. * Third Eye makes no claims about the applicability of this
  25. * symbol table to a particular use.
  26. */
  27. /*
  28. * This file contains the definition of the Third Eye Symbol Table.
  29. *
  30. * Symbols are assumed to be in 'encounter order' - i.e. the order that
  31. * the things they represent were encountered by the compiler/assembler/loader.
  32. * EXCEPT for globals! These are assumed to be bunched together,
  33. * probably right after the last 'normal' symbol. Globals ARE sorted
  34. * in ascending order.
  35. *
  36. * -----------------------------------------------------------------------
  37. * A brief word about Third Eye naming/use conventions:
  38. *
  39. * All arrays and index's are 0 based.
  40. * All "ifooMax" values are the highest legal value PLUS ONE. This makes
  41. * them good for allocating arrays, etc. All checks are "ifoo < ifooMax".
  42. *
  43. * "isym" Index into the SYMbol table.
  44. * "ipd" Index into the Procedure Descriptor array.
  45. * "ifd" Index into the File Descriptor array.
  46. * "iss" Index into String Space.
  47. * "cb" Count of Bytes.
  48. * "rgPd" array whose domain is "0..ipdMax-1" and RanGe is PDR.
  49. * "rgFd" array whose domain is "0..ifdMax-1" and RanGe is FDR.
  50. */
  51. /*
  52. * Symbolic Header (HDR) structure.
  53. * As long as all the pointers are set correctly,
  54. * we don't care WHAT order the various sections come out in!
  55. *
  56. * A file produced solely for the use of CDB will probably NOT have
  57. * any instructions or data areas in it, as these are available
  58. * in the original.
  59. */
  60. #ifdef LANGUAGE_C
  61. #ifdef lint
  62. #include <exception.h> /* defines struct exception_info */
  63. #endif
  64. typedef struct {
  65. short magic; /* to verify validity of the table */
  66. short vstamp; /* version stamp */
  67. long ilineMax; /* number of line number entries */
  68. long cbLine; /* number of bytes for line number entries */
  69. long cbLineOffset; /* offset to start of line number entries*/
  70. long idnMax; /* max index into dense number table */
  71. long cbDnOffset; /* offset to start dense number table */
  72. long ipdMax; /* number of procedures */
  73. long cbPdOffset; /* offset to procedure descriptor table */
  74. long isymMax; /* number of local symbols */
  75. long cbSymOffset; /* offset to start of local symbols*/
  76. long ioptMax; /* max index into optimization symbol entries */
  77. long cbOptOffset; /* offset to optimization symbol entries */
  78. long iauxMax; /* number of auxillary symbol entries */
  79. long cbAuxOffset; /* offset to start of auxillary symbol entries*/
  80. long issMax; /* max index into local strings */
  81. long cbSsOffset; /* offset to start of local strings */
  82. long issExtMax; /* max index into external strings */
  83. long cbSsExtOffset; /* offset to start of external strings */
  84. long ifdMax; /* number of file descriptor entries */
  85. long cbFdOffset; /* offset to file descriptor table */
  86. long crfd; /* number of relative file descriptor entries */
  87. long cbRfdOffset; /* offset to relative file descriptor table */
  88. long iextMax; /* max index into external symbols */
  89. long cbExtOffset; /* offset to start of external symbol entries*/
  90. /* If you add machine dependent fields, add them here */
  91. } HDRR, *pHDRR;
  92. #define cbHDRR sizeof(HDRR)
  93. #define hdrNil ((pHDRR)0)
  94. /*
  95. * The FDR and PDR structures speed mapping of address <-> name.
  96. * They are sorted in ascending memory order and are kept in
  97. * memory by CDB at runtime.
  98. */
  99. /*
  100. * File Descriptor
  101. *
  102. * There is one of these for EVERY FILE, whether compiled with
  103. * full debugging symbols or not. The name of a file should be
  104. * the path name given to the compiler. This allows the user
  105. * to simply specify the names of the directories where the COMPILES
  106. * were done, and we will be able to find their files.
  107. * A field whose comment starts with "R - " indicates that it will be
  108. * setup at runtime.
  109. */
  110. typedef struct fdr {
  111. unsigned long adr; /* memory address of beginning of file */
  112. long rss; /* file name (of source, if known) */
  113. long issBase; /* file's string space */
  114. long cbSs; /* number of bytes in the ss */
  115. long isymBase; /* beginning of symbols */
  116. long csym; /* count file's of symbols */
  117. long ilineBase; /* file's line symbols */
  118. long cline; /* count of file's line symbols */
  119. long ioptBase; /* file's optimization entries */
  120. long copt; /* count of file's optimization entries */
  121. short ipdFirst; /* start of procedures for this file */
  122. short cpd; /* count of procedures for this file */
  123. long iauxBase; /* file's auxiliary entries */
  124. long caux; /* count of file's auxiliary entries */
  125. long rfdBase; /* index into the file indirect table */
  126. long crfd; /* count file indirect entries */
  127. unsigned lang: 5; /* language for this file */
  128. unsigned fMerge : 1; /* whether this file can be merged */
  129. unsigned fReadin : 1; /* true if it was read in (not just created) */
  130. unsigned fBigendian : 1;/* if set, was compiled on big endian machine */
  131. /* aux's will be in compile host's sex */
  132. unsigned glevel : 2; /* level this file was compiled with */
  133. unsigned reserved : 22; /* reserved for future use */
  134. long cbLineOffset; /* byte offset from header for this file ln's */
  135. long cbLine; /* size of lines for this file */
  136. } FDR, *pFDR;
  137. #define cbFDR sizeof(FDR)
  138. #define fdNil ((pFDR)0)
  139. #define ifdNil -1
  140. #define ifdTemp 0
  141. #define ilnNil -1
  142. /*
  143. * Procedure Descriptor
  144. *
  145. * There is one of these for EVERY TEXT LABEL.
  146. * If a procedure is in a file with full symbols, then isym
  147. * will point to the PROC symbols, else it will point to the
  148. * global symbol for the label.
  149. */
  150. typedef struct pdr {
  151. unsigned long adr; /* memory address of start of procedure */
  152. long isym; /* start of local symbol entries */
  153. long iline; /* start of line number entries*/
  154. long regmask; /* save register mask */
  155. long regoffset; /* save register offset */
  156. long iopt; /* start of optimization symbol entries*/
  157. long fregmask; /* save floating point register mask */
  158. long fregoffset; /* save floating point register offset */
  159. long frameoffset; /* frame size */
  160. short framereg; /* frame pointer register */
  161. short pcreg; /* offset or reg of return pc */
  162. long lnLow; /* lowest line in the procedure */
  163. long lnHigh; /* highest line in the procedure */
  164. long cbLineOffset; /* byte offset for this procedure from the fd base */
  165. } PDR, *pPDR;
  166. #define cbPDR sizeof(PDR)
  167. #define pdNil ((pPDR) 0)
  168. #define ipdNil -1
  169. /*
  170. * Line Numbers
  171. *
  172. * Line Numbers are segregated from the normal symbols because they
  173. * are [1] smaller , [2] are of no interest to your
  174. * average loader, and [3] are never needed in the middle of normal
  175. * scanning and therefore slow things down.
  176. *
  177. * By definition, the first LINER for any given procedure will have
  178. * the first line of a procedure and represent the first address.
  179. */
  180. typedef long LINER, *pLINER;
  181. #define lineNil ((pLINER)0)
  182. #define cbLINER sizeof(LINER)
  183. #define ilineNil -1
  184. /*
  185. * The Symbol Structure (GFW, to those who Know!)
  186. */
  187. typedef struct {
  188. long iss; /* index into String Space of name */
  189. long value; /* value of symbol */
  190. unsigned long st : 6; /* symbol type */
  191. unsigned long sc : 5; /* storage class - text, data, etc */
  192. unsigned long reserved : 1; /* reserved */
  193. unsigned long index : 20; /* index into sym/aux table */
  194. } SYMR, *pSYMR;
  195. #define symNil ((pSYMR)0)
  196. #define cbSYMR sizeof(SYMR)
  197. #define isymNil -1
  198. #define indexNil 0xfffff
  199. #define issNil -1
  200. #define issNull 0
  201. /* The following converts a memory resident string to an iss.
  202. * This hack is recognized in SbFIss, in sym.c of the debugger.
  203. */
  204. #define IssFSb(sb) (0x80000000 | ((unsigned long)(sb)))
  205. /* E X T E R N A L S Y M B O L R E C O R D
  206. *
  207. * Same as the SYMR except it contains file context to determine where
  208. * the index is.
  209. */
  210. typedef struct {
  211. unsigned jmptbl:1; /* symbol is a jump table entry for shlibs */
  212. unsigned cobol_main:1; /* symbol is a cobol main procedure */
  213. unsigned weakext:1; /* symbol is weak external */
  214. unsigned reserved:13; /* reserved for future use */
  215. short ifd; /* where the iss and index fields point into */
  216. SYMR asym; /* symbol for the external */
  217. } EXTR, *pEXTR;
  218. #define extNil ((pEXTR)0)
  219. #define cbEXTR sizeof(EXTR)
  220. /* A U X I L L A R Y T Y P E I N F O R M A T I O N */
  221. /*
  222. * Type Information Record
  223. */
  224. typedef struct {
  225. unsigned fBitfield : 1; /* set if bit width is specified */
  226. unsigned continued : 1; /* indicates additional TQ info in next AUX */
  227. unsigned bt : 6; /* basic type */
  228. unsigned tq4 : 4;
  229. unsigned tq5 : 4;
  230. /* ---- 16 bit boundary ---- */
  231. unsigned tq0 : 4;
  232. unsigned tq1 : 4; /* 6 type qualifiers - tqPtr, etc. */
  233. unsigned tq2 : 4;
  234. unsigned tq3 : 4;
  235. } TIR, *pTIR;
  236. #define cbTIR sizeof(TIR)
  237. #define tiNil ((pTIR)0)
  238. #define itqMax 6
  239. /*
  240. * Relative symbol record
  241. *
  242. * If the rfd field is 4095, the index field indexes into the global symbol
  243. * table.
  244. */
  245. typedef struct {
  246. unsigned rfd : 12; /* index into the file indirect table */
  247. unsigned index : 20; /* index int sym/aux/iss tables */
  248. } RNDXR, *pRNDXR;
  249. #define cbRNDXR sizeof(RNDXR)
  250. #define rndxNil ((pRNDXR)0)
  251. /* dense numbers or sometimes called block numbers are stored in this type,
  252. * a rfd of 0xffffffff is an index into the global table.
  253. */
  254. typedef struct {
  255. unsigned long rfd; /* index into the file table */
  256. unsigned long index; /* index int sym/aux/iss tables */
  257. } DNR, *pDNR;
  258. #define cbDNR sizeof(DNR)
  259. #define dnNil ((pDNR)0)
  260. /*
  261. * Auxillary information occurs only if needed.
  262. * It ALWAYS occurs in this order when present.
  263. isymMac used by stProc only
  264. TIR type info
  265. TIR additional TQ info (if first TIR was not enough)
  266. rndx if (bt == btStruct,btUnion,btEnum,btSet,btRange,
  267. btTypedef):
  268. rsym.index == iaux for btSet or btRange
  269. else rsym.index == isym
  270. dimLow btRange, btSet
  271. dimMac btRange, btSet
  272. rndx0 As many as there are tq arrays
  273. dimLow0
  274. dimHigh0
  275. ...
  276. rndxMax-1
  277. dimLowMax-1
  278. dimHighMax-1
  279. width in bits if (bit field), width in bits.
  280. */
  281. #define cAuxMax (6 + (idimMax*3))
  282. /* a union of all possible info in the AUX universe */
  283. typedef union {
  284. TIR ti; /* type information record */
  285. RNDXR rndx; /* relative index into symbol table */
  286. long dnLow; /* low dimension */
  287. long dnHigh; /* high dimension */
  288. long isym; /* symbol table index (end of proc) */
  289. long iss; /* index into string space (not used) */
  290. long width; /* width for non-default sized struc fields */
  291. long count; /* count of ranges for variant arm */
  292. } AUXU, *pAUXU;
  293. #define cbAUXU sizeof(AUXU)
  294. #define auxNil ((pAUXU)0)
  295. #define iauxNil -1
  296. /*
  297. * Optimization symbols
  298. *
  299. * Optimization symbols contain some overlap information with the normal
  300. * symbol table. In particular, the proc information
  301. * is somewhat redundant but necessary to easily find the other information
  302. * present.
  303. *
  304. * All of the offsets are relative to the beginning of the last otProc
  305. */
  306. typedef struct {
  307. unsigned ot: 8; /* optimization type */
  308. unsigned value: 24; /* address where we are moving it to */
  309. RNDXR rndx; /* points to a symbol or opt entry */
  310. unsigned long offset; /* relative offset this occured */
  311. } OPTR, *pOPTR;
  312. #define optNil ((pOPTR) 0)
  313. #define cbOPTR sizeof(OPTR)
  314. #define ioptNil -1
  315. /*
  316. * File Indirect
  317. *
  318. * When a symbol is referenced across files the following procedure is used:
  319. * 1) use the file index to get the File indirect entry.
  320. * 2) use the file indirect entry to get the File descriptor.
  321. * 3) add the sym index to the base of that file's sym table
  322. *
  323. */
  324. typedef long RFDT, *pRFDT;
  325. #define cbRFDT sizeof(RFDT)
  326. #define rfdNil -1
  327. /*
  328. * The file indirect table in the mips loader is known as an array of FITs.
  329. * This is done to keep the code in the loader readable in the area where
  330. * these tables are merged. Note this is only a name change.
  331. */
  332. typedef long FIT, *pFIT;
  333. #define cbFIT sizeof(FIT)
  334. #define ifiNil -1
  335. #define fiNil ((pFIT) 0)
  336. #endif /* LANGUAGE_C */
  337. #ifdef LANGUAGE_PASCAL
  338. #define ifdNil -1
  339. #define ilnNil -1
  340. #define ipdNil -1
  341. #define ilineNil -1
  342. #define isymNil -1
  343. #define indexNil 16#fffff
  344. #define issNil -1
  345. #define issNull 0
  346. #define itqMax 6
  347. #define iauxNil -1
  348. #define ioptNil -1
  349. #define rfdNil -1
  350. #define ifiNil -1
  351. #endif /* LANGUAGE_PASCAL */
  352. /* Dense numbers
  353. *
  354. * Rather than use file index, symbol index pairs to represent symbols
  355. * and globals, we use dense number so that they can be easily embeded
  356. * in intermediate code and the programs that process them can
  357. * use direct access tabls instead of hash table (which would be
  358. * necesary otherwise because of the sparse name space caused by
  359. * file index, symbol index pairs. Dense number are represented
  360. * by RNDXRs.
  361. */
  362. /*
  363. * The following table defines the meaning of each SYM field as
  364. * a function of the "st". (scD/B == scData OR scBss)
  365. *
  366. * Note: the value "isymMac" is used by symbols that have the concept
  367. * of enclosing a block of related information. This value is the
  368. * isym of the first symbol AFTER the end associated with the primary
  369. * symbol. For example if a procedure was at isym==90 and had an
  370. * isymMac==155, the associated end would be at isym==154, and the
  371. * symbol at 155 would probably (although not necessarily) be the
  372. * symbol for the next procedure. This allows rapid skipping over
  373. * internal information of various sorts. "stEnd"s ALWAYS have the
  374. * isym of the primary symbol that started the block.
  375. *
  376. ST SC VALUE INDEX
  377. -------- ------ -------- ------
  378. stFile scText address isymMac
  379. stLabel scText address ---
  380. stGlobal scD/B address iaux
  381. stStatic scD/B address iaux
  382. stParam scAbs offset iaux
  383. stLocal scAbs offset iaux
  384. stProc scText address iaux (isymMac is first AUX)
  385. stStaticProc scText address iaux (isymMac is first AUX)
  386. stMember scNil ordinal --- (if member of enum)
  387. stMember scNil byte offset iaux (if member of struct/union)
  388. stMember scBits bit offset iaux (bit field spec)
  389. stBlock scText address isymMac (text block)
  390. stBlock scNil cb isymMac (struct/union member define)
  391. stBlock scNil cMembers isymMac (enum member define)
  392. stEnd scText address isymStart
  393. stEnd scNil ------- isymStart (struct/union/enum)
  394. stTypedef scNil ------- iaux
  395. stRegReloc sc??? value old register number
  396. stForward sc??? new address isym to original symbol
  397. stConstant scInfo value --- (scalar)
  398. stConstant scInfo iss --- (complex, e.g. string)
  399. *
  400. */
  401. /* $Log: sym.h,v $
  402. * Revision 2020.2.2.1 91/02/25 17:49:34 jalal
  403. * update copyright
  404. *
  405. * Revision 2020.2.1.1 90/10/30 12:31:15 shin
  406. * copy from 2.21 for weakext flag
  407. *
  408. * Revision 2021.2 90/10/19 10:55:23 shin
  409. * added weakext flag in EXTR structure
  410. *
  411. * Revision 2021.1 90/06/07 23:09:19 bettina
  412. * 2.21 - branching off 2.20 for ansi C
  413. *
  414. * Revision 2020.2 90/05/17 18:17:57 chan
  415. * *** empty log message ***
  416. *
  417. * Revision 2010.7.1.6 90/02/22 19:53:48 bettina
  418. * 2.10 F1
  419. *
  420. * Revision 2010.7.1.5 89/11/29 22:41:00 bettina
  421. * 2.10 BETA2
  422. *
  423. * Revision 2010.3 89/10/05 10:44:44 lai
  424. * added lint wrapper
  425. *
  426. * Revision 2010.2 89/09/26 23:40:45 lai
  427. * added #include exception.h
  428. *
  429. * Revision 2010.1 89/09/26 20:47:45 lai
  430. * updated to 2.10
  431. *
  432. * Revision 1.3 89/09/26 20:08:54 lai
  433. * added wrapper and $LOG
  434. * updated for 2.10
  435. *
  436. */
  437. #endif