home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gcc-2.3.3-src.lha
/
GNU
/
src
/
amiga
/
gcc-2.3.3
/
mips-tdump.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-06
|
41KB
|
1,551 lines
/* Read and manage MIPS symbol tables from object modules.
Source originally from hartzell@boulder.colorado.edu
Rewritten by: meissner@osf.org
Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <fcntl.h>
#include <errno.h>
#include "config.h"
#ifdef index
#undef index
#undef rindex
#endif
#ifndef CROSS_COMPILE
#include <a.out.h>
#else
#include "symconst.h"
#define LANGUAGE_C
#include "sym.h"
#include "filehdr.h"
#define ST_RFDESCAPE 0xfff
#endif
#ifdef __STDC__
typedef void *PTR_T;
typedef const void *CPTR_T;
#define __proto(x) x
#else
#if defined(_STDIO_H_) || defined(__STDIO_H__) /* Ultrix 4.0, SGI */
typedef void *PTR_T;
typedef void *CPTR_T;
#else
typedef char *PTR_T; /* Ultrix 3.1 */
typedef char *CPTR_T;
#endif
#define __proto(x) ()
#define const
#endif
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
/* Do to size_t being defined in sys/types.h and different
in stddef.h, we have to do this by hand..... Note, these
types are correct for MIPS based systems, and may not be
correct for other systems. */
#define size_t uint
#define ptrdiff_t int
/* Redefinition of of storage classes as an enumeration for better
debugging. */
#ifndef stStaParam
#define stStaParam 16 /* Fortran static parameters */
#endif
#ifndef btVoid
#define btVoid 26 /* void basic type */
#endif
typedef enum sc {
sc_Nil = scNil, /* no storage class */
sc_Text = scText, /* text symbol */
sc_Data = scData, /* initialized data symbol */
sc_Bss = scBss, /* un-initialized data symbol */
sc_Register = scRegister, /* value of symbol is register number */
sc_Abs = scAbs, /* value of symbol is absolute */
sc_Undefined = scUndefined, /* who knows? */
sc_CdbLocal = scCdbLocal, /* variable's value is IN se->va.?? */
sc_Bits = scBits, /* this is a bit field */
sc_CdbSystem = scCdbSystem, /* var's value is IN CDB's address space */
sc_RegImage = scRegImage, /* register value saved on stack */
sc_Info = scInfo, /* symbol contains debugger information */
sc_UserStruct = scUserStruct, /* addr in struct user for current process */
sc_SData = scSData, /* load time only small data */
sc_SBss = scSBss, /* load time only small common */
sc_RData = scRData, /* load time only read only data */
sc_Var = scVar, /* Var parameter (fortran,pascal) */
sc_Common = scCommon, /* common variable */
sc_SCommon = scSCommon, /* small common */
sc_VarRegister = scVarRegister, /* Var parameter in a register */
sc_Variant = scVariant, /* Variant record */
sc_SUndefined = scSUndefined, /* small undefined(external) data */
sc_Init = scInit, /* .init section symbol */
sc_Max = scMax /* Max storage class+1 */
} sc_t;
/* Redefinition of symbol type. */
typedef enum st {
st_Nil = stNil, /* Nuthin' special */
st_Global = stGlobal, /* external symbol */
st_Static = stStatic, /* static */
st_Param = stParam, /* procedure argument */
st_Local = stLocal, /* local variable */
st_Label = stLabel, /* label */
st_Proc = stProc, /* " " Procedure */
st_Block = stBlock, /* beginning of block */
st_End = stEnd, /* end (of anything) */
st_Member = stMember, /* member (of anything - struct/union/enum */
st_Typedef = stTypedef, /* type definition */
st_File = stFile, /* file name */
st_RegReloc = stRegReloc, /* register relocation */
st_Forward = stForward, /* forwarding address */
st_StaticProc = stStaticProc, /* load time only static procs */
st_StaParam = stStaParam, /* Fortran static parameters */
st_Constant = stConstant, /* const */
st_Str = stStr, /* string */
st_Number = stNumber, /* pure number (ie. 4 NOR 2+2) */
st_Expr = stExpr, /* 2+2 vs. 4 */
st_Type = stType, /* post-coercion SER */
st_Max = stMax /* max type+1 */
} st_t;
/* Redefinition of type qualifiers. */
typedef enum tq {
tq_Nil = tqNil, /* bt is what you see */
tq_Ptr = tqPtr, /* pointer */
tq_Proc = tqProc, /* procedure */
tq_Array = tqArray, /* duh */
tq_Far = tqFar, /* longer addressing - 8086/8 land */
tq_Vol = tqVol, /* volatile */
tq_Max = tqMax /* Max type qualifier+1 */
} tq_t;
/* Redefinition of basic types. */
typedef enum bt {
bt_Nil = btNil, /* undefined */
bt_Adr = btAdr, /* address - integer same size as pointer */
bt_Char = btChar, /* character */
bt_UChar = btUChar, /* unsigned character */
bt_Short = btShort, /* short */
bt_UShort = btUShort, /* unsigned short */
bt_Int = btInt, /* int */
bt_UInt = btUInt, /* unsigned int */
bt_Long = btLong, /* long */
bt_ULong = btULong, /* unsigned long */
bt_Float = btFloat, /* float (real) */
bt_Double = btDouble, /* Double (real) */
bt_Struct = btStruct, /* Structure (Record) */
bt_Union = btUnion, /* Union (variant) */
bt_Enum = btEnum, /* Enumerated */
bt_Typedef = btTypedef, /* defined via a typedef, isymRef points */
bt_Range = btRange, /* subrange of int */
bt_Set = btSet, /* pascal sets */
bt_Complex = btComplex, /* fortran complex */
bt_DComplex = btDComplex, /* fortran double complex */
bt_Indirect = btIndirect, /* forward or unnamed typedef */
bt_FixedDec = btFixedDec, /* Fixed Decimal */
bt_FloatDec = btFloatDec, /* Float Decimal */
bt_String = btString, /* Varying Length Character String */
bt_Bit = btBit, /* Aligned Bit String */
bt_Picture = btPicture, /* Picture */
bt_Void = btVoid, /* void */
bt_Max = btMax /* Max basic type+1 */
} bt_t;
/* Redefinition of the language codes. */
typedef enum lang {
lang_C = langC,
lang_Pascal = langPascal,
lang_Fortran = langFortran,
lang_Assembler = langAssembler,
lang_Machine = langMachine,
lang_Nil = langNil,
lang_Ada = langAda,
lang_Pl1 = langPl1,
lang_Cobol = langCobol
} lang_t;
/* Redefinition of the debug level codes. */
typedef enum glevel {
glevel_0 = GLEVEL_0,
glevel_1 = GLEVEL_1,
glevel_2 = GLEVEL_2,
glevel_3 = GLEVEL_3
} glevel_t;
/* Keep track of the active scopes. */
typedef struct scope {
struct scope *prev; /* previous scope */
ulong open_sym; /* symbol opening scope */
sc_t sc; /* storage class */
st_t st; /* symbol type */
} scope_t;
struct filehdr global_hdr; /* a.out header */
int errors = 0; /* # of errors */
int want_aux = 0; /* print aux table */
int want_line = 0; /* print line numbers */
int want_rfd = 0; /* print relative file desc's */
int want_scope = 0; /* print scopes for every symbol */
int tfile_fd; /* file descriptor of .T file */
off_t tfile_offset; /* current offset in .T file */
scope_t *cur_scope = 0; /* list of active scopes */
scope_t *free_scope = 0; /* list of freed scopes */
HDRR sym_hdr; /* symbolic header */
char *l_strings; /* local strings */
char *e_strings; /* external strings */
SYMR *l_symbols; /* local symbols */
EXTR *e_symbols; /* external symbols */
LINER *lines; /* line numbers */
DNR *dense_nums; /* dense numbers */
OPTR *opt_symbols; /* optimization symbols */
AUXU *aux_symbols; /* Auxiliary symbols */
char *aux_used; /* map of which aux syms are used */
FDR *file_desc; /* file tables */
ulong *rfile_desc; /* relative file tables */
PDR *proc_desc; /* procedure tables */
/* Forward reference for functions. */
PTR_T read_seek __proto((PTR_T, size_t, off_t, const char *));
void read_tfile __proto((void));
void print_