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