2 * |-----------------------------------------------------------|
3 * | Copyright (c) 1992, 1991, 1990 MIPS Computer Systems, Inc.|
4 * | MIPS Computer Systems, Inc. grants reproduction and use |
5 * | rights to all parties, PROVIDED that this comment is |
6 * | maintained in the copy. |
7 * |-----------------------------------------------------------|
13 /* (C) Copyright 1984 by Third Eye Software, Inc.
15 * Third Eye Software, Inc. grants reproduction and use rights to
16 * all parties, PROVIDED that this comment is maintained in the copy.
18 * Third Eye makes no claims about the applicability of this
19 * symbol table to a particular use.
23 * This file contains the definition of the Third Eye Symbol Table.
25 * Symbols are assumed to be in 'encounter order' - i.e. the order that
26 * the things they represent were encountered by the compiler/assembler/loader.
27 * EXCEPT for globals! These are assumed to be bunched together,
28 * probably right after the last 'normal' symbol. Globals ARE sorted
31 * -----------------------------------------------------------------------
32 * A brief word about Third Eye naming/use conventions:
34 * All arrays and index's are 0 based.
35 * All "ifooMax" values are the highest legal value PLUS ONE. This makes
36 * them good for allocating arrays, etc. All checks are "ifoo < ifooMax".
38 * "isym" Index into the SYMbol table.
39 * "ipd" Index into the Procedure Descriptor array.
40 * "ifd" Index into the File Descriptor array.
41 * "iss" Index into String Space.
42 * "cb" Count of Bytes.
43 * "rgPd" array whose domain is "0..ipdMax-1" and RanGe is PDR.
44 * "rgFd" array whose domain is "0..ifdMax-1" and RanGe is FDR.
49 * Symbolic Header (HDR) structure.
50 * As long as all the pointers are set correctly,
51 * we don't care WHAT order the various sections come out in!
53 * A file produced solely for the use of CDB will probably NOT have
54 * any instructions or data areas in it, as these are available
61 #include <exception.h> /* defines struct exception_info */
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 */
92 #define cbHDRR sizeof(HDRR)
93 #define hdrNil ((pHDRR)0)
96 * The FDR and PDR structures speed mapping of address <-> name.
97 * They are sorted in ascending memory order and are kept in
98 * memory by CDB at runtime.
104 * There is one of these for EVERY FILE, whether compiled with
105 * full debugging symbols or not. The name of a file should be
106 * the path name given to the compiler. This allows the user
107 * to simply specify the names of the directories where the COMPILES
108 * were done, and we will be able to find their files.
109 * A field whose comment starts with "R - " indicates that it will be
113 unsigned long adr
; /* memory address of beginning of file */
114 long rss
; /* file name (of source, if known) */
115 long issBase
; /* file's string space */
116 long cbSs
; /* number of bytes in the ss */
117 long isymBase
; /* beginning of symbols */
118 long csym
; /* count file's of symbols */
119 long ilineBase
; /* file's line symbols */
120 long cline
; /* count of file's line symbols */
121 long ioptBase
; /* file's optimization entries */
122 long copt
; /* count of file's optimization entries */
123 unsigned short ipdFirst
;/* start of procedures for this file */
124 short cpd
; /* count of procedures for this file */
125 long iauxBase
; /* file's auxiliary entries */
126 long caux
; /* count of file's auxiliary entries */
127 long rfdBase
; /* index into the file indirect table */
128 long crfd
; /* count file indirect entries */
129 unsigned lang
: 5; /* language for this file */
130 unsigned fMerge
: 1; /* whether this file can be merged */
131 unsigned fReadin
: 1; /* true if it was read in (not just created) */
132 unsigned fBigendian
: 1;/* if set, was compiled on big endian machine */
133 /* aux's will be in compile host's sex */
134 unsigned glevel
: 2; /* level this file was compiled with */
135 unsigned reserved
: 22; /* reserved for future use */
136 long cbLineOffset
; /* byte offset from header for this file ln's */
137 long cbLine
; /* size of lines for this file */
139 #define cbFDR sizeof(FDR)
140 #define fdNil ((pFDR)0)
147 * Procedure Descriptor
149 * There is one of these for EVERY TEXT LABEL.
150 * If a procedure is in a file with full symbols, then isym
151 * will point to the PROC symbols, else it will point to the
152 * global symbol for the label.
156 unsigned long adr
; /* memory address of start of procedure */
157 long isym
; /* start of local symbol entries */
158 long iline
; /* start of line number entries*/
159 long regmask
; /* save register mask */
160 long regoffset
; /* save register offset */
161 long iopt
; /* start of optimization symbol entries*/
162 long fregmask
; /* save floating point register mask */
163 long fregoffset
; /* save floating point register offset */
164 long frameoffset
; /* frame size */
165 short framereg
; /* frame pointer register */
166 short pcreg
; /* offset or reg of return pc */
167 long lnLow
; /* lowest line in the procedure */
168 long lnHigh
; /* highest line in the procedure */
169 long cbLineOffset
; /* byte offset for this procedure from the fd base */
171 #define cbPDR sizeof(PDR)
172 #define pdNil ((pPDR) 0)
176 * The structure of the runtime procedure descriptor created by the loader
177 * for use by the static exception system.
179 typedef struct runtime_pdr
{
180 unsigned long adr
; /* memory address of start of procedure */
181 long regmask
; /* save register mask */
182 long regoffset
; /* save register offset */
183 long fregmask
; /* save floating point register mask */
184 long fregoffset
; /* save floating point register offset */
185 long frameoffset
; /* frame size */
186 short framereg
; /* frame pointer register */
187 short pcreg
; /* offset or reg of return pc */
188 long irpss
; /* index into the runtime string table */
190 struct exception_info
*exception_info
;/* pointer to exception array */
192 #define cbRPDR sizeof(RPDR)
193 #define rpdNil ((pRPDR) 0)
198 * Line Numbers are segregated from the normal symbols because they
199 * are [1] smaller , [2] are of no interest to your
200 * average loader, and [3] are never needed in the middle of normal
201 * scanning and therefore slow things down.
203 * By definition, the first LINER for any given procedure will have
204 * the first line of a procedure and represent the first address.
207 typedef long LINER
, *pLINER
;
208 #define lineNil ((pLINER)0)
209 #define cbLINER sizeof(LINER)
215 * The Symbol Structure (GFW, to those who Know!)
219 long iss
; /* index into String Space of name */
220 long value
; /* value of symbol */
221 unsigned st
: 6; /* symbol type */
222 unsigned sc
: 5; /* storage class - text, data, etc */
223 unsigned reserved
: 1; /* reserved */
224 unsigned index
: 20; /* index into sym/aux table */
226 #define symNil ((pSYMR)0)
227 #define cbSYMR sizeof(SYMR)
229 #define indexNil 0xfffff
234 /* The following converts a memory resident string to an iss.
235 * This hack is recognized in SbFIss, in sym.c of the debugger.
237 #define IssFSb(sb) (0x80000000 | ((unsigned long)(sb)))
239 /* E X T E R N A L S Y M B O L R E C O R D
241 * Same as the SYMR except it contains file context to determine where
245 unsigned jmptbl
:1; /* symbol is a jump table entry for shlibs */
246 unsigned cobol_main
:1; /* symbol is a cobol main procedure */
247 unsigned weakext
:1; /* symbol is weak external */
248 unsigned reserved
:13; /* reserved for future use */
249 short ifd
; /* where the iss and index fields point into */
250 SYMR asym
; /* symbol for the external */
252 #define extNil ((pEXTR)0)
253 #define cbEXTR sizeof(EXTR)
256 /* A U X I L L A R Y T Y P E I N F O R M A T I O N */
259 * Type Information Record
262 unsigned fBitfield
: 1; /* set if bit width is specified */
263 unsigned continued
: 1; /* indicates additional TQ info in next AUX */
264 unsigned bt
: 6; /* basic type */
267 /* ---- 16 bit boundary ---- */
269 unsigned tq1
: 4; /* 6 type qualifiers - tqPtr, etc. */
273 #define cbTIR sizeof(TIR)
274 #define tiNil ((pTIR)0)
278 * Relative symbol record
280 * If the rfd field is 4095, the index field indexes into the global symbol
285 unsigned rfd
: 12; /* index into the file indirect table */
286 unsigned index
: 20; /* index int sym/aux/iss tables */
288 #define cbRNDXR sizeof(RNDXR)
289 #define rndxNil ((pRNDXR)0)
291 /* dense numbers or sometimes called block numbers are stored in this type,
292 * a rfd of 0xffffffff is an index into the global table.
295 unsigned long rfd
; /* index into the file table */
296 unsigned long index
; /* index int sym/aux/iss tables */
298 #define cbDNR sizeof(DNR)
299 #define dnNil ((pDNR)0)
304 * Auxillary information occurs only if needed.
305 * It ALWAYS occurs in this order when present.
307 isymMac used by stProc only
309 TIR additional TQ info (if first TIR was not enough)
310 rndx if (bt == btStruct,btUnion,btEnum,btSet,btRange,
312 rsym.index == iaux for btSet or btRange
313 else rsym.index == isym
314 dimLow btRange, btSet
315 dimMac btRange, btSet
316 rndx0 As many as there are tq arrays
323 width in bits if (bit field), width in bits.
325 #define cAuxMax (6 + (idimMax*3))
327 /* a union of all possible info in the AUX universe */
329 TIR ti
; /* type information record */
330 RNDXR rndx
; /* relative index into symbol table */
331 long dnLow
; /* low dimension */
332 long dnHigh
; /* high dimension */
333 long isym
; /* symbol table index (end of proc) */
334 long iss
; /* index into string space (not used) */
335 long width
; /* width for non-default sized struc fields */
336 long count
; /* count of ranges for variant arm */
338 #define cbAUXU sizeof(AUXU)
339 #define auxNil ((pAUXU)0)
344 * Optimization symbols
346 * Optimization symbols contain some overlap information with the normal
347 * symbol table. In particular, the proc information
348 * is somewhat redundant but necessary to easily find the other information
351 * All of the offsets are relative to the beginning of the last otProc
355 unsigned ot
: 8; /* optimization type */
356 unsigned value
: 24; /* address where we are moving it to */
357 RNDXR rndx
; /* points to a symbol or opt entry */
358 unsigned long offset
; /* relative offset this occured */
360 #define optNil ((pOPTR) 0)
361 #define cbOPTR sizeof(OPTR)
367 * When a symbol is referenced across files the following procedure is used:
368 * 1) use the file index to get the File indirect entry.
369 * 2) use the file indirect entry to get the File descriptor.
370 * 3) add the sym index to the base of that file's sym table
374 typedef long RFDT
, *pRFDT
;
375 #define cbRFDT sizeof(RFDT)
379 * The file indirect table in the mips loader is known as an array of FITs.
380 * This is done to keep the code in the loader readable in the area where
381 * these tables are merged. Note this is only a name change.
383 typedef long FIT
, *pFIT
;
384 #define cbFIT sizeof(FIT)
386 #define fiNil ((pFIT) 0)
388 #endif /* _LANGUAGE_C */
390 #ifdef _LANGUAGE_PASCAL
396 #define indexNil 16#fffff
404 #endif /* _LANGUAGE_PASCAL */
409 * Rather than use file index, symbol index pairs to represent symbols
410 * and globals, we use dense number so that they can be easily embeded
411 * in intermediate code and the programs that process them can
412 * use direct access tabls instead of hash table (which would be
413 * necesary otherwise because of the sparse name space caused by
414 * file index, symbol index pairs. Dense number are represented
419 * The following table defines the meaning of each SYM field as
420 * a function of the "st". (scD/B == scData OR scBss)
422 * Note: the value "isymMac" is used by symbols that have the concept
423 * of enclosing a block of related information. This value is the
424 * isym of the first symbol AFTER the end associated with the primary
425 * symbol. For example if a procedure was at isym==90 and had an
426 * isymMac==155, the associated end would be at isym==154, and the
427 * symbol at 155 would probably (although not necessarily) be the
428 * symbol for the next procedure. This allows rapid skipping over
429 * internal information of various sorts. "stEnd"s ALWAYS have the
430 * isym of the primary symbol that started the block.
434 -------- ------ -------- ------
435 stFile scText address isymMac
436 stLabel scText address ---
437 stGlobal scD/B address iaux
438 stStatic scD/B address iaux
439 stParam scAbs offset iaux
440 stLocal scAbs offset iaux
441 stProc scText address iaux (isymMac is first AUX)
442 stStaticProc scText address iaux (isymMac is first AUX)
444 stMember scNil ordinal --- (if member of enum)
445 stMember scNil byte offset iaux (if member of struct/union)
446 stMember scBits bit offset iaux (bit field spec)
448 stBlock scText address isymMac (text block)
449 stBlock scNil cb isymMac (struct/union member define)
450 stBlock scNil cMembers isymMac (enum member define)
452 stEnd scText address isymStart
453 stEnd scNil ------- isymStart (struct/union/enum)
455 stTypedef scNil ------- iaux
456 stRegReloc sc??? value old register number
457 stForward sc??? new address isym to original symbol
459 stConstant scInfo value --- (scalar)
460 stConstant scInfo iss --- (complex, e.g. string)
465 /* Revision 1.1 1992/04/03 04:01:32 gnu
466 /* Date: Thu, 2 Apr 92 15:48:13 -0800
467 /* From: wu@mips.com (Alex Wu)
468 /* Message-Id: <9204022348.AA20058@goofy.mips.com>
469 /* To: gnu@cygnus.com
470 /* Subject: sym.h & symconst.h
473 /* I finally get our lawyer's approval. Here is the symconst.h and
474 /* the sym.h. Please let me know if there is anything else I can help.
476 * Revision 3000.5.1.2 91/05/31 18:27:22 bettina
477 * fix DFARS in copyright
479 * Revision 3000.5.1.1 91/04/15 20:51:26 bettina
482 * Revision 3000.5 91/04/09 13:39:51 keithm
483 * Added DEC specific changes.
485 * Revision 3000.3 91/03/13 18:55:54 karen
486 * changed __SYM_H to _SYM_H
488 * Revision 3000.2 90/12/10 13:53:26 zaineb
491 * Revision 2020.2.1.1 90/10/30 12:31:15 shin
492 * copy from 2.21 for weakext flag
494 * Revision 2021.2 90/10/19 10:55:23 shin
495 * added weakext flag in EXTR structure
497 * Revision 2021.1 90/06/07 23:09:19 bettina
498 * 2.21 - branching off 2.20 for ansi C
500 * Revision 2020.2 90/05/17 18:17:57 chan
501 * *** empty log message ***
503 * Revision 2010.7.1.6 90/02/22 19:53:48 bettina
506 * Revision 2010.7.1.5 89/11/29 22:41:00 bettina
509 * Revision 2010.3 89/10/05 10:44:44 lai
512 * Revision 2010.2 89/09/26 23:40:45 lai
513 * added #include exception.h
515 * Revision 2010.1 89/09/26 20:47:45 lai
518 * Revision 1.3 89/09/26 20:08:54 lai
519 * added wrapper and $LOG