Back to index

cell-binutils  2.17cvs20070401
sym.h
Go to the documentation of this file.
00001 /* Declarations of internal format of MIPS ECOFF symbols.
00002    Originally contributed by MIPS Computer Systems and Third Eye Software.
00003    Changes contributed by Cygnus Support are in the public domain.  
00004 
00005    This file is just aggregated with the files that make up the GNU
00006    release; it is not considered part of GAS, GDB, or other GNU
00007    programs.  */
00008 
00009 /*
00010  * |-----------------------------------------------------------|
00011  * | Copyright (c) 1992, 1991, 1990 MIPS Computer Systems, Inc.|
00012  * | MIPS Computer Systems, Inc. grants reproduction and use   |
00013  * | rights to all parties, PROVIDED that this comment is      |
00014  * | maintained in the copy.                                   |
00015  * |-----------------------------------------------------------|
00016  */
00017 #ifndef _SYM_H
00018 #define _SYM_H
00019 
00020 /* (C) Copyright 1984 by Third Eye Software, Inc.
00021  *
00022  * Third Eye Software, Inc. grants reproduction and use rights to
00023  * all parties, PROVIDED that this comment is maintained in the copy.
00024  *
00025  * Third Eye makes no claims about the applicability of this
00026  * symbol table to a particular use.
00027  */
00028 
00029 /* 
00030  * This file contains the definition of the Third Eye Symbol Table.
00031  *
00032  * Symbols are assumed to be in 'encounter order' - i.e. the order that
00033  * the things they represent were encountered by the compiler/assembler/loader.
00034  * EXCEPT for globals!      These are assumed to be bunched together,
00035  * probably right after the last 'normal' symbol.  Globals ARE sorted
00036  * in ascending order.
00037  *
00038  * -----------------------------------------------------------------------
00039  * A brief word about Third Eye naming/use conventions:
00040  *
00041  * All arrays and index's are 0 based.
00042  * All "ifooMax" values are the highest legal value PLUS ONE. This makes
00043  * them good for allocating arrays, etc. All checks are "ifoo < ifooMax".
00044  *
00045  * "isym"     Index into the SYMbol table.
00046  * "ipd"      Index into the Procedure Descriptor array.
00047  * "ifd"      Index into the File Descriptor array.
00048  * "iss"      Index into String Space.
00049  * "cb"              Count of Bytes.
00050  * "rgPd"     array whose domain is "0..ipdMax-1" and RanGe is PDR.
00051  * "rgFd"     array whose domain is "0..ifdMax-1" and RanGe is FDR.
00052  */
00053 
00054 
00055 /* 
00056  * Symbolic Header (HDR) structure.
00057  * As long as all the pointers are set correctly,
00058  * we don't care WHAT order the various sections come out in!
00059  *
00060  * A file produced solely for the use of CDB will probably NOT have
00061  * any instructions or data areas in it, as these are available
00062  * in the original.
00063  */
00064 
00065 typedef struct {
00066        short  magic;        /* to verify validity of the table */
00067        short  vstamp;              /* version stamp */
00068        long   ilineMax;     /* number of line number entries */
00069        bfd_vma       cbLine;              /* number of bytes for line number entries */
00070        bfd_vma       cbLineOffset; /* offset to start of line number entries*/
00071        long   idnMax;              /* max index into dense number table */
00072        bfd_vma       cbDnOffset;   /* offset to start dense number table */
00073        long   ipdMax;              /* number of procedures */
00074        bfd_vma       cbPdOffset;   /* offset to procedure descriptor table */
00075        long   isymMax;      /* number of local symbols */
00076        bfd_vma       cbSymOffset;  /* offset to start of local symbols*/
00077        long   ioptMax;      /* max index into optimization symbol entries */
00078        bfd_vma       cbOptOffset;  /* offset to optimization symbol entries */
00079        long   iauxMax;      /* number of auxillary symbol entries */
00080        bfd_vma       cbAuxOffset;  /* offset to start of auxillary symbol entries*/
00081        long   issMax;              /* max index into local strings */
00082        bfd_vma       cbSsOffset;   /* offset to start of local strings */
00083        long   issExtMax;    /* max index into external strings */
00084        bfd_vma       cbSsExtOffset;       /* offset to start of external strings */
00085        long   ifdMax;              /* number of file descriptor entries */
00086        bfd_vma       cbFdOffset;   /* offset to file descriptor table */
00087        long   crfd;         /* number of relative file descriptor entries */
00088        bfd_vma       cbRfdOffset;  /* offset to relative file descriptor table */
00089        long   iextMax;      /* max index into external symbols */
00090        bfd_vma       cbExtOffset;  /* offset to start of external symbol entries*/
00091        /* If you add machine dependent fields, add them here */
00092        } HDRR, *pHDRR; 
00093 #define cbHDRR sizeof(HDRR)
00094 #define hdrNil ((pHDRR)0)
00095 
00096 /*
00097  * The FDR and PDR structures speed mapping of address <-> name.
00098  * They are sorted in ascending memory order and are kept in
00099  * memory by CDB at runtime.
00100  */
00101 
00102 /* 
00103  * File Descriptor
00104  *
00105  * There is one of these for EVERY FILE, whether compiled with
00106  * full debugging symbols or not.  The name of a file should be
00107  * the path name given to the compiler.    This allows the user
00108  * to simply specify the names of the directories where the COMPILES
00109  * were done, and we will be able to find their files.
00110  * A field whose comment starts with "R - " indicates that it will be
00111  * setup at runtime.
00112  */
00113 typedef struct fdr {
00114        bfd_vma       adr;          /* memory address of beginning of file */
00115        long   rss;          /* file name (of source, if known) */
00116        long   issBase;      /* file's string space */
00117        bfd_vma       cbSs;         /* number of bytes in the ss */
00118        long   isymBase;     /* beginning of symbols */
00119        long   csym;         /* count file's of symbols */
00120        long   ilineBase;    /* file's line symbols */
00121        long   cline;        /* count of file's line symbols */
00122        long   ioptBase;     /* file's optimization entries */
00123        long   copt;         /* count of file's optimization entries */
00124        unsigned short ipdFirst;/* start of procedures for this file */
00125        short  cpd;          /* count of procedures for this file */
00126        long   iauxBase;     /* file's auxiliary entries */
00127        long   caux;         /* count of file's auxiliary entries */
00128        long   rfdBase;      /* index into the file indirect table */
00129        long   crfd;         /* count file indirect entries */
00130        unsigned lang: 5;    /* language for this file */
00131        unsigned fMerge : 1; /* whether this file can be merged */
00132        unsigned fReadin : 1;       /* true if it was read in (not just created) */
00133        unsigned fBigendian : 1;/* if set, was compiled on big endian machine */
00134                             /*     aux's will be in compile host's sex */
00135        unsigned glevel : 2; /* level this file was compiled with */
00136        unsigned reserved : 22;  /* reserved for future use */
00137        bfd_vma       cbLineOffset; /* byte offset from header for this file ln's */
00138        bfd_vma       cbLine;              /* size of lines for this file */
00139        } FDR, *pFDR;
00140 #define cbFDR sizeof(FDR)
00141 #define fdNil ((pFDR)0)
00142 #define ifdNil -1
00143 #define ifdTemp 0
00144 #define ilnNil -1
00145 
00146 
00147 /* 
00148  * Procedure Descriptor
00149  *
00150  * There is one of these for EVERY TEXT LABEL.
00151  * If a procedure is in a file with full symbols, then isym
00152  * will point to the PROC symbols, else it will point to the
00153  * global symbol for the label.
00154  */
00155 
00156 typedef struct pdr {
00157        bfd_vma       adr;          /* memory address of start of procedure */
00158        long   isym;         /* start of local symbol entries */
00159        long   iline;        /* start of line number entries*/
00160        long   regmask;      /* save register mask */
00161        long   regoffset;    /* save register offset */
00162        long   iopt;         /* start of optimization symbol entries*/
00163        long   fregmask;     /* save floating point register mask */
00164        long   fregoffset;   /* save floating point register offset */
00165        long   frameoffset;  /* frame size */
00166        short  framereg;     /* frame pointer register */
00167        short  pcreg;        /* offset or reg of return pc */
00168        long   lnLow;        /* lowest line in the procedure */
00169        long   lnHigh;              /* highest line in the procedure */
00170        bfd_vma       cbLineOffset; /* byte offset for this procedure from the fd base */
00171        /* These fields are new for 64 bit ECOFF.  */
00172        unsigned gp_prologue : 8; /* byte size of GP prologue */
00173        unsigned gp_used : 1;       /* true if the procedure uses GP */
00174        unsigned reg_frame : 1;     /* true if register frame procedure */
00175        unsigned prof : 1;   /* true if compiled with -pg */
00176        unsigned reserved : 13;     /* reserved: must be zero */
00177        unsigned localoff : 8;      /* offset of local variables from vfp */
00178        } PDR, *pPDR;
00179 #define cbPDR sizeof(PDR)
00180 #define pdNil ((pPDR) 0)
00181 #define ipdNil       -1
00182 
00183 /*
00184  * The structure of the runtime procedure descriptor created by the loader
00185  * for use by the static exception system.
00186  */
00187 /*
00188  * If 0'd out because exception_info chokes Visual C++ and because there
00189  * don't seem to be any references to this structure elsewhere in gdb.
00190  */
00191 #if 0
00192 typedef struct runtime_pdr {
00193        bfd_vma       adr;          /* memory address of start of procedure */
00194        long   regmask;      /* save register mask */
00195        long   regoffset;    /* save register offset */
00196        long   fregmask;     /* save floating point register mask */
00197        long   fregoffset;   /* save floating point register offset */
00198        long   frameoffset;  /* frame size */
00199        short  framereg;     /* frame pointer register */
00200        short  pcreg;        /* offset or reg of return pc */
00201        long   irpss;        /* index into the runtime string table */
00202        long   reserved;
00203        struct exception_info *exception_info;/* pointer to exception array */
00204 } RPDR, *pRPDR;
00205 #define cbRPDR sizeof(RPDR)
00206 #define rpdNil ((pRPDR) 0)
00207 #endif
00208 
00209 /*
00210  * Line Numbers
00211  *
00212  * Line Numbers are segregated from the normal symbols because they
00213  * are [1] smaller , [2] are of no interest to your
00214  * average loader, and [3] are never needed in the middle of normal
00215  * scanning and therefore slow things down.
00216  *
00217  * By definition, the first LINER for any given procedure will have
00218  * the first line of a procedure and represent the first address.
00219  */
00220 
00221 typedef       long LINER, *pLINER;
00222 #define lineNil ((pLINER)0)
00223 #define cbLINER sizeof(LINER)
00224 #define ilineNil     -1
00225 
00226 
00227 
00228 /*
00229  * The Symbol Structure            (GFW, to those who Know!)
00230  */
00231 
00232 typedef struct {
00233        long   iss;          /* index into String Space of name */
00234        bfd_vma       value;        /* value of symbol */
00235        unsigned st : 6;     /* symbol type */
00236        unsigned sc  : 5;    /* storage class - text, data, etc */
00237        unsigned reserved : 1;      /* reserved */
00238        unsigned index : 20; /* index into sym/aux table */
00239        } SYMR, *pSYMR;
00240 #define symNil ((pSYMR)0)
00241 #define cbSYMR sizeof(SYMR)
00242 #define isymNil -1
00243 #define indexNil 0xfffff
00244 #define issNil -1
00245 #define issNull 0
00246 
00247 
00248 /* The following converts a memory resident string to an iss.
00249  * This hack is recognized in SbFIss, in sym.c of the debugger.
00250  */
00251 #define IssFSb(sb) (0x80000000 | ((unsigned long)(sb)))
00252 
00253 /* E X T E R N A L   S Y M B O L  R E C O R D
00254  *
00255  *     Same as the SYMR except it contains file context to determine where
00256  *     the index is.
00257  */
00258 typedef struct ecoff_extr {
00259        unsigned jmptbl:1;   /* symbol is a jump table entry for shlibs */
00260        unsigned cobol_main:1;      /* symbol is a cobol main procedure */
00261        unsigned weakext:1;  /* symbol is weak external */
00262        unsigned reserved:13;       /* reserved for future use */
00263        int    ifd;          /* where the iss and index fields point into */
00264        SYMR   asym;         /* symbol for the external */
00265        } EXTR, *pEXTR;
00266 #define extNil ((pEXTR)0)
00267 #define cbEXTR sizeof(EXTR)
00268 
00269 
00270 /* A U X I L L A R Y   T Y P E      I N F O R M A T I O N */
00271 
00272 /*
00273  * Type Information Record
00274  */
00275 typedef struct {
00276        unsigned fBitfield : 1; /* set if bit width is specified */
00277        unsigned continued : 1; /* indicates additional TQ info in next AUX */
00278        unsigned bt  : 6;    /* basic type */
00279        unsigned tq4 : 4;
00280        unsigned tq5 : 4;
00281        /* ---- 16 bit boundary ---- */
00282        unsigned tq0 : 4;
00283        unsigned tq1 : 4;    /* 6 type qualifiers - tqPtr, etc. */
00284        unsigned tq2 : 4;
00285        unsigned tq3 : 4;
00286        } TIR, *pTIR;
00287 #define cbTIR sizeof(TIR)
00288 #define tiNil ((pTIR)0)
00289 #define itqMax 6
00290 
00291 /*
00292  * Relative symbol record
00293  *
00294  * If the rfd field is 4095, the index field indexes into the global symbol
00295  *     table.
00296  */
00297 
00298 typedef struct {
00299        unsigned      rfd : 12;    /* index into the file indirect table */
00300        unsigned      index : 20; /* index int sym/aux/iss tables */
00301        } RNDXR, *pRNDXR;
00302 #define cbRNDXR sizeof(RNDXR)
00303 #define rndxNil ((pRNDXR)0)
00304 
00305 /* dense numbers or sometimes called block numbers are stored in this type,
00306  *     a rfd of 0xffffffff is an index into the global table.
00307  */
00308 typedef struct {
00309        unsigned long rfd;    /* index into the file table */
00310        unsigned long index;        /* index int sym/aux/iss tables */
00311        } DNR, *pDNR;
00312 #define cbDNR sizeof(DNR)
00313 #define dnNil ((pDNR)0)
00314 
00315 
00316 
00317 /*
00318  * Auxillary information occurs only if needed.
00319  * It ALWAYS occurs in this order when present.
00320 
00321            isymMac          used by stProc only
00322            TIR                     type info
00323            TIR                     additional TQ info (if first TIR was not enough)
00324            rndx             if (bt == btStruct,btUnion,btEnum,btSet,btRange,
00325                                 btTypedef):
00326                                 rsym.index == iaux for btSet or btRange
00327                                 else rsym.index == isym
00328            dimLow           btRange, btSet
00329            dimMac           btRange, btSet
00330            rndx0            As many as there are tq arrays
00331            dimLow0
00332            dimHigh0
00333            ...
00334            rndxMax-1
00335            dimLowMax-1
00336            dimHighMax-1
00337            width in bits    if (bit field), width in bits.
00338  */
00339 #define cAuxMax (6 + (idimMax*3))
00340 
00341 /* a union of all possible info in the AUX universe */
00342 typedef union {
00343        TIR    ti;           /* type information record */
00344        RNDXR  rndx;         /* relative index into symbol table */
00345        long   dnLow;        /* low dimension */
00346        long   dnHigh;              /* high dimension */
00347        long   isym;         /* symbol table index (end of proc) */
00348        long   iss;          /* index into string space (not used) */
00349        long   width;        /* width for non-default sized struc fields */
00350        long   count;        /* count of ranges for variant arm */
00351        } AUXU, *pAUXU;
00352 #define cbAUXU sizeof(AUXU)
00353 #define auxNil ((pAUXU)0)
00354 #define iauxNil -1
00355 
00356 
00357 /*
00358  * Optimization symbols
00359  *
00360  * Optimization symbols contain some overlap information with the normal
00361  * symbol table. In particular, the proc information
00362  * is somewhat redundant but necessary to easily find the other information
00363  * present. 
00364  *
00365  * All of the offsets are relative to the beginning of the last otProc
00366  */
00367 
00368 typedef struct {
00369        unsigned ot: 8;             /* optimization type */
00370        unsigned value: 24;  /* address where we are moving it to */
00371        RNDXR  rndx;         /* points to a symbol or opt entry */
00372        unsigned long offset;       /* relative offset this occured */
00373        } OPTR, *pOPTR;
00374 #define optNil       ((pOPTR) 0)
00375 #define cbOPTR sizeof(OPTR)
00376 #define ioptNil -1
00377 
00378 /*
00379  * File Indirect
00380  *
00381  * When a symbol is referenced across files the following procedure is used:
00382  *     1) use the file index to get the File indirect entry.
00383  *     2) use the file indirect entry to get the File descriptor.
00384  *     3) add the sym index to the base of that file's sym table
00385  *
00386  */
00387 
00388 typedef long RFDT, *pRFDT;
00389 #define cbRFDT sizeof(RFDT)
00390 #define rfdNil       -1
00391 
00392 /*
00393  * The file indirect table in the mips loader is known as an array of FITs.
00394  * This is done to keep the code in the loader readable in the area where
00395  * these tables are merged.  Note this is only a name change.
00396  */
00397 typedef long FIT, *pFIT;
00398 #define cbFIT sizeof(FIT)
00399 #define ifiNil       -1
00400 #define fiNil ((pFIT) 0)
00401 
00402 #ifdef _LANGUAGE_PASCAL
00403 #define ifdNil -1
00404 #define ilnNil -1
00405 #define ipdNil -1
00406 #define ilineNil -1
00407 #define isymNil -1
00408 #define indexNil 16#fffff
00409 #define issNil -1
00410 #define issNull 0
00411 #define itqMax 6
00412 #define iauxNil -1
00413 #define ioptNil -1
00414 #define rfdNil -1
00415 #define ifiNil -1
00416 #endif /* _LANGUAGE_PASCAL */
00417 
00418 
00419 /* Dense numbers
00420  *
00421  * Rather than use file index, symbol index pairs to represent symbols
00422  *     and globals, we use dense number so that they can be easily embeded
00423  *     in intermediate code and the programs that process them can
00424  *     use direct access tabls instead of hash table (which would be
00425  *     necesary otherwise because of the sparse name space caused by
00426  *     file index, symbol index pairs. Dense number are represented
00427  *     by RNDXRs.
00428  */
00429 
00430 /*
00431  * The following table defines the meaning of each SYM field as
00432  * a function of the "st". (scD/B == scData OR scBss)
00433  *
00434  * Note: the value "isymMac" is used by symbols that have the concept
00435  * of enclosing a block of related information.   This value is the
00436  * isym of the first symbol AFTER the end associated with the primary
00437  * symbol. For example if a procedure was at isym==90 and had an
00438  * isymMac==155, the associated end would be at isym==154, and the
00439  * symbol at 155 would probably (although not necessarily) be the
00440  * symbol for the next procedure.  This allows rapid skipping over
00441  * internal information of various sorts. "stEnd"s ALWAYS have the
00442  * isym of the primary symbol that started the block.
00443  * 
00444 
00445 ST            SC     VALUE         INDEX
00446 --------      ------ --------      ------
00447 stFile        scText address              isymMac
00448 stLabel              scText address              ---
00449 stGlobal      scD/B  address              iaux
00450 stStatic      scD/B  address              iaux
00451 stParam              scAbs  offset        iaux
00452 stLocal              scAbs  offset        iaux
00453 stProc        scText address              iaux   (isymMac is first AUX)
00454 stStaticProc  scText address              iaux   (isymMac is first AUX)
00455 
00456 stMember      scNil  ordinal              ---    (if member of enum)
00457        (mipsread thinks the case below has a bit, not byte, offset.)
00458 stMember      scNil  byte offset   iaux   (if member of struct/union)
00459 stMember      scBits bit offset    iaux   (bit field spec)
00460 
00461 stBlock              scText address              isymMac (text block)
00462        (the code seems to think that rather than scNil, we see scInfo for
00463         the two cases below.)
00464 stBlock              scNil  cb            isymMac (struct/union member define)
00465 stBlock              scNil  cMembers      isymMac (enum member define)
00466 
00467        (New types added by SGI to simplify things:)
00468 stStruct      scInfo cb            isymMac (struct type define)
00469 stUnion              scInfo cb            isymMac (union  type define)
00470 stEnum        scInfo cMembers      isymMac (enum   type define)
00471 
00472 stEnd         scText address              isymStart
00473 stEnd         scNil  -------              isymStart (struct/union/enum)
00474 
00475 stTypedef     scNil  -------              iaux
00476 stRegReloc    sc???  value         old register number
00477 stForward     sc???  new address   isym to original symbol
00478 
00479 stConstant    scInfo value         --- (scalar)
00480 stConstant    scInfo iss           --- (complex, e.g. string)
00481 
00482  *
00483  */
00484 #endif