📄 mips-tfile.c
字号:
thash_t thash [ PAGE_SIZE / sizeof (thash_t) ]; tag_t tag [ PAGE_SIZE / sizeof (tag_t) ]; forward_t forward [ PAGE_SIZE / sizeof (forward_t) ]; thead_t thead [ PAGE_SIZE / sizeof (thead_t) ];} page_t;/* Structure holding allocation information for small sized structures. */typedef struct alloc_info { char *alloc_name; /* name of this allocation type (must be first) */ page_t *cur_page; /* current page being allocated from */ small_free_t free_list; /* current free list if any */ int unallocated; /* number of elements unallocated on page */ int total_alloc; /* total number of allocations */ int total_free; /* total number of frees */ int total_pages; /* total number of pages allocated */} alloc_info_t;/* Type information collected together. */typedef struct type_info { bt_t basic_type; /* basic type */ coff_type_t orig_type; /* original COFF-based type */ int num_tq; /* # type qualifiers */ int num_dims; /* # dimensions */ int num_sizes; /* # sizes */ int extra_sizes; /* # extra sizes not tied with dims */ tag_t * tag_ptr; /* tag pointer */ int bitfield; /* symbol is a bitfield */ int unknown_tag; /* this is an unknown tag */ tq_t type_qualifiers[N_TQ]; /* type qualifiers (ptr, func, array)*/ symint_t dimensions [N_TQ]; /* dimensions for each array */ symint_t sizes [N_TQ+2]; /* sizes of each array slice + size of struct/union/enum + bitfield size */} type_info_t;/* Pre-initialized type_info struct. */static type_info_t type_info_init = { bt_Nil, /* basic type */ T_NULL, /* original COFF-based type */ 0, /* # type qualifiers */ 0, /* # dimensions */ 0, /* # sizes */ 0, /* sizes not tied with dims */ NULL, /* ptr to tag */ 0, /* bitfield */ 0, /* unknown tag */ { /* type qualifiers */ tq_Nil, tq_Nil, tq_Nil, tq_Nil, tq_Nil, tq_Nil, }, { /* dimensions */ 0, 0, 0, 0, 0, 0 }, { /* sizes */ 0, 0, 0, 0, 0, 0, 0, 0, },};/* Global virtual arrays & hash table for external strings as well as for the tags table and global tables for file descriptors, and dense numbers. */static varray_t file_desc = INIT_VARRAY (efdr_t);static varray_t dense_num = INIT_VARRAY (DNR);static varray_t tag_strings = INIT_VARRAY (char);static varray_t ext_strings = INIT_VARRAY (char);static varray_t ext_symbols = INIT_VARRAY (EXTR);static shash_t *orig_str_hash[SHASH_SIZE];static shash_t *ext_str_hash [SHASH_SIZE];static shash_t *tag_hash [SHASH_SIZE];/* Static types for int and void. Also, remember the last function's type (which is set up when we encounter the declaration for the function, and used when the end block for the function is emitted. */static type_info_t int_type_info;static type_info_t void_type_info;static type_info_t last_func_type_info;static EXTR *last_func_eptr;/* Convert COFF basic type to ECOFF basic type. The T_NULL type really should use bt_Void, but this causes the current ecoff GDB to issue unsupported type messages, and the Ultrix 4.00 dbx (aka MIPS 2.0) doesn't understand it, even though the compiler generates it. Maybe this will be fixed in 2.10 or 2.20 of the MIPS compiler suite, but for now go with what works. */static bt_t map_coff_types[ (int)T_MAX ] = { bt_Nil, /* T_NULL */ bt_Nil, /* T_ARG */ bt_Char, /* T_CHAR */ bt_Short, /* T_SHORT */ bt_Int, /* T_INT */ bt_Long, /* T_LONG */ bt_Float, /* T_FLOAT */ bt_Double, /* T_DOUBLE */ bt_Struct, /* T_STRUCT */ bt_Union, /* T_UNION */ bt_Enum, /* T_ENUM */ bt_Enum, /* T_MOE */ bt_UChar, /* T_UCHAR */ bt_UShort, /* T_USHORT */ bt_UInt, /* T_UINT */ bt_ULong /* T_ULONG */};/* Convert COFF storage class to ECOFF storage class. */static sc_t map_coff_storage[ (int)C_MAX ] = { sc_Nil, /* 0: C_NULL */ sc_Abs, /* 1: C_AUTO auto var */ sc_Undefined, /* 2: C_EXT external */ sc_Data, /* 3: C_STAT static */ sc_Register, /* 4: C_REG register */ sc_Undefined, /* 5: C_EXTDEF ??? */ sc_Text, /* 6: C_LABEL label */ sc_Text, /* 7: C_ULABEL user label */ sc_Info, /* 8: C_MOS member of struct */ sc_Abs, /* 9: C_ARG argument */ sc_Info, /* 10: C_STRTAG struct tag */ sc_Info, /* 11: C_MOU member of union */ sc_Info, /* 12: C_UNTAG union tag */ sc_Info, /* 13: C_TPDEF typedef */ sc_Data, /* 14: C_USTATIC ??? */ sc_Info, /* 15: C_ENTAG enum tag */ sc_Info, /* 16: C_MOE member of enum */ sc_Register, /* 17: C_REGPARM register parameter */ sc_Bits, /* 18; C_FIELD bitfield */ sc_Nil, /* 19 */ sc_Nil, /* 20 */ sc_Nil, /* 21 */ sc_Nil, /* 22 */ sc_Nil, /* 23 */ sc_Nil, /* 24 */ sc_Nil, /* 25 */ sc_Nil, /* 26 */ sc_Nil, /* 27 */ sc_Nil, /* 28 */ sc_Nil, /* 29 */ sc_Nil, /* 30 */ sc_Nil, /* 31 */ sc_Nil, /* 32 */ sc_Nil, /* 33 */ sc_Nil, /* 34 */ sc_Nil, /* 35 */ sc_Nil, /* 36 */ sc_Nil, /* 37 */ sc_Nil, /* 38 */ sc_Nil, /* 39 */ sc_Nil, /* 40 */ sc_Nil, /* 41 */ sc_Nil, /* 42 */ sc_Nil, /* 43 */ sc_Nil, /* 44 */ sc_Nil, /* 45 */ sc_Nil, /* 46 */ sc_Nil, /* 47 */ sc_Nil, /* 48 */ sc_Nil, /* 49 */ sc_Nil, /* 50 */ sc_Nil, /* 51 */ sc_Nil, /* 52 */ sc_Nil, /* 53 */ sc_Nil, /* 54 */ sc_Nil, /* 55 */ sc_Nil, /* 56 */ sc_Nil, /* 57 */ sc_Nil, /* 58 */ sc_Nil, /* 59 */ sc_Nil, /* 60 */ sc_Nil, /* 61 */ sc_Nil, /* 62 */ sc_Nil, /* 63 */ sc_Nil, /* 64 */ sc_Nil, /* 65 */ sc_Nil, /* 66 */ sc_Nil, /* 67 */ sc_Nil, /* 68 */ sc_Nil, /* 69 */ sc_Nil, /* 70 */ sc_Nil, /* 71 */ sc_Nil, /* 72 */ sc_Nil, /* 73 */ sc_Nil, /* 74 */ sc_Nil, /* 75 */ sc_Nil, /* 76 */ sc_Nil, /* 77 */ sc_Nil, /* 78 */ sc_Nil, /* 79 */ sc_Nil, /* 80 */ sc_Nil, /* 81 */ sc_Nil, /* 82 */ sc_Nil, /* 83 */ sc_Nil, /* 84 */ sc_Nil, /* 85 */ sc_Nil, /* 86 */ sc_Nil, /* 87 */ sc_Nil, /* 88 */ sc_Nil, /* 89 */ sc_Nil, /* 90 */ sc_Nil, /* 91 */ sc_Nil, /* 92 */ sc_Nil, /* 93 */ sc_Nil, /* 94 */ sc_Nil, /* 95 */ sc_Nil, /* 96 */ sc_Nil, /* 97 */ sc_Nil, /* 98 */ sc_Nil, /* 99 */ sc_Text, /* 100: C_BLOCK block start/end */ sc_Text, /* 101: C_FCN function start/end */ sc_Info, /* 102: C_EOS end of struct/union/enum */ sc_Nil, /* 103: C_FILE file start */ sc_Nil, /* 104: C_LINE line number */ sc_Nil, /* 105: C_ALIAS combined type info */ sc_Nil, /* 106: C_HIDDEN ??? */};/* Convert COFF storage class to ECOFF symbol type. */static st_t map_coff_sym_type[ (int)C_MAX ] = { st_Nil, /* 0: C_NULL */ st_Local, /* 1: C_AUTO auto var */ st_Global, /* 2: C_EXT external */ st_Static, /* 3: C_STAT static */ st_Local, /* 4: C_REG register */ st_Global, /* 5: C_EXTDEF ??? */ st_Label, /* 6: C_LABEL label */ st_Label, /* 7: C_ULABEL user label */ st_Member, /* 8: C_MOS member of struct */ st_Param, /* 9: C_ARG argument */ st_Block, /* 10: C_STRTAG struct tag */ st_Member, /* 11: C_MOU member of union */ st_Block, /* 12: C_UNTAG union tag */ st_Typedef, /* 13: C_TPDEF typedef */ st_Static, /* 14: C_USTATIC ??? */ st_Block, /* 15: C_ENTAG enum tag */ st_Member, /* 16: C_MOE member of enum */ st_Param, /* 17: C_REGPARM register parameter */ st_Member, /* 18; C_FIELD bitfield */ st_Nil, /* 19 */ st_Nil, /* 20 */ st_Nil, /* 21 */ st_Nil, /* 22 */ st_Nil, /* 23 */ st_Nil, /* 24 */ st_Nil, /* 25 */ st_Nil, /* 26 */ st_Nil, /* 27 */ st_Nil, /* 28 */ st_Nil, /* 29 */ st_Nil, /* 30 */ st_Nil, /* 31 */ st_Nil, /* 32 */ st_Nil, /* 33 */ st_Nil, /* 34 */ st_Nil, /* 35 */ st_Nil, /* 36 */ st_Nil, /* 37 */ st_Nil, /* 38 */ st_Nil, /* 39 */ st_Nil, /* 40 */ st_Nil, /* 41 */ st_Nil, /* 42 */ st_Nil, /* 43 */ st_Nil, /* 44 */ st_Nil, /* 45 */ st_Nil, /* 46 */ st_Nil, /* 47 */ st_Nil, /* 48 */ st_Nil, /* 49 */ st_Nil, /* 50 */ st_Nil, /* 51 */ st_Nil, /* 52 */ st_Nil, /* 53 */ st_Nil, /* 54 */ st_Nil, /* 55 */ st_Nil, /* 56 */ st_Nil, /* 57 */ st_Nil, /* 58 */ st_Nil, /* 59 */ st_Nil, /* 60 */ st_Nil, /* 61 */ st_Nil, /* 62 */ st_Nil, /* 63 */ st_Nil, /* 64 */ st_Nil, /* 65 */ st_Nil, /* 66 */ st_Nil, /* 67 */ st_Nil, /* 68 */ st_Nil, /* 69 */ st_Nil, /* 70 */ st_Nil, /* 71 */ st_Nil, /* 72 */ st_Nil, /* 73 */ st_Nil, /* 74 */ st_Nil, /* 75 */ st_Nil, /* 76 */ st_Nil, /* 77 */ st_Nil, /* 78 */ st_Nil, /* 79 */ st_Nil, /* 80 */ st_Nil, /* 81 */ st_Nil, /* 82 */ st_Nil, /* 83 */ st_Nil, /* 84 */ st_Nil, /* 85 */ st_Nil, /* 86 */ st_Nil, /* 87 */ st_Nil, /* 88 */ st_Nil, /* 89 */ st_Nil, /* 90 */ st_Nil, /* 91 */ st_Nil, /* 92 */ st_Nil, /* 93 */ st_Nil, /* 94 */ st_Nil, /* 95 */ st_Nil, /* 96 */ st_Nil, /* 97 */ st_Nil, /* 98 */ st_Nil, /* 99 */ st_Block, /* 100: C_BLOCK block start/end */ st_Proc, /* 101: C_FCN function start/end */ st_End, /* 102: C_EOS end of struct/union/enum */ st_File, /* 103: C_FILE file start */ st_Nil, /* 104: C_LINE line number */ st_Nil, /* 105: C_ALIAS combined type info */ st_Nil, /* 106: C_HIDDEN ??? */};/* Map COFF derived types to ECOFF type qualifiers. */static tq_t map_coff_derived_type[ (int)DT_MAX ] = { tq_Nil, /* 0: DT_NON no more qualifiers */ tq_Ptr, /* 1: DT_PTR pointer */ tq_Proc, /* 2: DT_FCN function */ tq_Array, /* 3: DT_ARY array */};/* Keep track of different sized allocation requests. */static alloc_info_t alloc_counts[ (int)alloc_type_last ];/* Pointers and such to the original symbol table that is read in. */static struct filehdr orig_file_header; /* global object file header */static HDRR orig_sym_hdr; /* symbolic header on input */static char *orig_linenum; /* line numbers */static DNR *orig_dense; /* dense numbers */static PDR *orig_procs; /* procedures */static SYMR *orig_local_syms; /* local symbols */static OPTR *orig_opt_syms; /* optimization symbols */static AUXU *orig_aux_syms; /* auxiliary symbols */static char *orig_local_strs; /* local strings */static char *orig_ext_strs; /* external strings */static FDR *orig_files; /* file descriptors */static symint_t *orig_rfds; /* relative file desc's */static EXTR *orig_ext_syms; /* external symbols *//* Macros to convert an index into a given object within the original symbol table. */#define CHECK(num,max,str) \ (((unsigned long)num > (unsigned long)max) ? out_of_bounds (num, max, str, __LINE__) : 0)#define ORIG_LINENUM(indx) (CHECK ((indx), orig_sym_hdr.cbLine, "line#"), (indx) + orig_linenum)#define ORIG_DENSE(indx) (CHECK ((indx), orig_sym_hdr.idnMax, "dense"), (indx) + orig_dense)#define ORIG_PROCS(indx) (CHECK ((indx), orig_sym_hdr.ipdMax, "procs"), (indx) + orig_procs)#define ORIG_FILES(indx) (CHECK ((indx), orig_sym_hdr.ifdMax, "funcs"), (indx) + orig_files)#define ORIG_LSYMS(indx) (CHECK ((indx), orig_sym_hdr.isymMax, "lsyms"), (indx) + orig_local_syms)#define ORIG_LSTRS(indx) (CHECK ((indx), orig_sym_hdr.issMax, "lstrs"), (indx) + orig_local_strs)#define ORIG_ESYMS(indx) (CHECK ((indx), orig_sym_hdr.iextMax, "esyms"), (indx) + orig_ext_syms)#define ORIG_ESTRS(indx) (CHECK ((indx), orig_sym_hdr.issExtMax, "estrs"), (indx) + orig_ext_strs)#define ORIG_OPT(indx) (CHECK ((indx), orig_sym_hdr.ioptMax, "opt"), (indx) + orig_opt_syms)#define ORIG_AUX(indx) (CHECK ((indx), orig_sym_hdr.iauxMax, "aux"), (indx) + orig_aux_syms)#define ORIG_RFDS(indx) (CHECK ((indx), orig_sym_hdr.crfd, "rfds"), (indx) + orig_rfds)/* Various other statics. */static HDRR symbolic_header; /* symbolic header */static efdr_t *cur_file_ptr = (efdr_t *) 0; /* current file desc. header */static PDR *cur_proc_ptr = (PDR *) 0; /* current procedure header */static SYMR *cur_oproc_begin = (SYMR *) 0; /* original proc. sym begin info */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -