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