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