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