1*3d8817e4Smiod /* coffgrok.h 2*3d8817e4Smiod Copyright 2001, 2002, 2003 Free Software Foundation, Inc. 3*3d8817e4Smiod 4*3d8817e4Smiod This file is part of GNU Binutils. 5*3d8817e4Smiod 6*3d8817e4Smiod This program is free software; you can redistribute it and/or modify 7*3d8817e4Smiod it under the terms of the GNU General Public License as published by 8*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or 9*3d8817e4Smiod (at your option) any later version. 10*3d8817e4Smiod 11*3d8817e4Smiod This program is distributed in the hope that it will be useful, 12*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of 13*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*3d8817e4Smiod GNU General Public License for more details. 15*3d8817e4Smiod 16*3d8817e4Smiod You should have received a copy of the GNU General Public License 17*3d8817e4Smiod along with this program; if not, write to the Free Software 18*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 19*3d8817e4Smiod 20*3d8817e4Smiod #define T_NULL 0 21*3d8817e4Smiod #define T_VOID 1 /* function argument (only used by compiler) */ 22*3d8817e4Smiod #define T_CHAR 2 /* character */ 23*3d8817e4Smiod #define T_SHORT 3 /* short integer */ 24*3d8817e4Smiod #define T_INT 4 /* integer */ 25*3d8817e4Smiod #define T_LONG 5 /* long integer */ 26*3d8817e4Smiod #define T_FLOAT 6 /* floating point */ 27*3d8817e4Smiod #define T_DOUBLE 7 /* double word */ 28*3d8817e4Smiod #define T_STRUCT 8 /* structure */ 29*3d8817e4Smiod #define T_UNION 9 /* union */ 30*3d8817e4Smiod #define T_ENUM 10 /* enumeration */ 31*3d8817e4Smiod #define T_MOE 11 /* member of enumeration*/ 32*3d8817e4Smiod #define T_UCHAR 12 /* unsigned character */ 33*3d8817e4Smiod #define T_USHORT 13 /* unsigned short */ 34*3d8817e4Smiod #define T_UINT 14 /* unsigned integer */ 35*3d8817e4Smiod #define T_ULONG 15 /* unsigned long */ 36*3d8817e4Smiod #define T_LNGDBL 16 /* long double */ 37*3d8817e4Smiod 38*3d8817e4Smiod 39*3d8817e4Smiod struct coff_reloc 40*3d8817e4Smiod { 41*3d8817e4Smiod int offset; 42*3d8817e4Smiod struct coff_symbol *symbol; 43*3d8817e4Smiod int addend; 44*3d8817e4Smiod }; 45*3d8817e4Smiod 46*3d8817e4Smiod struct coff_section 47*3d8817e4Smiod { 48*3d8817e4Smiod char *name; 49*3d8817e4Smiod int code; 50*3d8817e4Smiod int data; 51*3d8817e4Smiod int address; 52*3d8817e4Smiod int number; /* 0..n, .text = 0 */ 53*3d8817e4Smiod int nrelocs; 54*3d8817e4Smiod int size; 55*3d8817e4Smiod struct coff_reloc *relocs; 56*3d8817e4Smiod struct bfd_section *bfd_section; 57*3d8817e4Smiod }; 58*3d8817e4Smiod 59*3d8817e4Smiod struct coff_ofile 60*3d8817e4Smiod { 61*3d8817e4Smiod int nsources; 62*3d8817e4Smiod struct coff_sfile *source_head; 63*3d8817e4Smiod struct coff_sfile *source_tail; 64*3d8817e4Smiod int nsections; 65*3d8817e4Smiod struct coff_section *sections; 66*3d8817e4Smiod struct coff_symbol *symbol_list_head; 67*3d8817e4Smiod struct coff_symbol *symbol_list_tail; 68*3d8817e4Smiod }; 69*3d8817e4Smiod 70*3d8817e4Smiod struct coff_isection { 71*3d8817e4Smiod int low; 72*3d8817e4Smiod int high; 73*3d8817e4Smiod int init; 74*3d8817e4Smiod struct coff_section *parent; 75*3d8817e4Smiod }; 76*3d8817e4Smiod 77*3d8817e4Smiod struct coff_sfile 78*3d8817e4Smiod { 79*3d8817e4Smiod char *name; 80*3d8817e4Smiod struct coff_scope *scope; 81*3d8817e4Smiod struct coff_sfile *next; 82*3d8817e4Smiod 83*3d8817e4Smiod /* Vector which maps where in each output section 84*3d8817e4Smiod the input file has it's data */ 85*3d8817e4Smiod struct coff_isection *section; 86*3d8817e4Smiod 87*3d8817e4Smiod }; 88*3d8817e4Smiod 89*3d8817e4Smiod 90*3d8817e4Smiod struct coff_type 91*3d8817e4Smiod { 92*3d8817e4Smiod int size; 93*3d8817e4Smiod enum 94*3d8817e4Smiod { 95*3d8817e4Smiod coff_pointer_type, coff_function_type, coff_array_type, coff_structdef_type, coff_basic_type, 96*3d8817e4Smiod coff_structref_type, coff_enumref_type, coff_enumdef_type, coff_secdef_type 97*3d8817e4Smiod } type; 98*3d8817e4Smiod union 99*3d8817e4Smiod { 100*3d8817e4Smiod struct 101*3d8817e4Smiod { 102*3d8817e4Smiod int address; 103*3d8817e4Smiod int size; 104*3d8817e4Smiod } asecdef; 105*3d8817e4Smiod 106*3d8817e4Smiod struct 107*3d8817e4Smiod { 108*3d8817e4Smiod int isstruct; 109*3d8817e4Smiod struct coff_scope *elements; 110*3d8817e4Smiod int idx; 111*3d8817e4Smiod } 112*3d8817e4Smiod astructdef; 113*3d8817e4Smiod struct 114*3d8817e4Smiod { 115*3d8817e4Smiod struct coff_symbol *ref; 116*3d8817e4Smiod } astructref; 117*3d8817e4Smiod 118*3d8817e4Smiod struct 119*3d8817e4Smiod { 120*3d8817e4Smiod struct coff_scope *elements; 121*3d8817e4Smiod int idx; 122*3d8817e4Smiod } aenumdef; 123*3d8817e4Smiod struct 124*3d8817e4Smiod { 125*3d8817e4Smiod struct coff_symbol *ref; 126*3d8817e4Smiod } aenumref; 127*3d8817e4Smiod 128*3d8817e4Smiod struct 129*3d8817e4Smiod { 130*3d8817e4Smiod struct coff_type *points_to; 131*3d8817e4Smiod } pointer; 132*3d8817e4Smiod struct 133*3d8817e4Smiod { 134*3d8817e4Smiod int dim; 135*3d8817e4Smiod struct coff_type *array_of; 136*3d8817e4Smiod } array; 137*3d8817e4Smiod 138*3d8817e4Smiod struct 139*3d8817e4Smiod { 140*3d8817e4Smiod struct coff_type *function_returns; 141*3d8817e4Smiod struct coff_scope *parameters; 142*3d8817e4Smiod struct coff_scope *code; 143*3d8817e4Smiod struct coff_line *lines; 144*3d8817e4Smiod } function; 145*3d8817e4Smiod int basic; /* One of T_VOID.. T_UINT */ 146*3d8817e4Smiod } u; 147*3d8817e4Smiod }; 148*3d8817e4Smiod 149*3d8817e4Smiod 150*3d8817e4Smiod struct coff_line 151*3d8817e4Smiod { 152*3d8817e4Smiod int nlines; 153*3d8817e4Smiod int *lines; 154*3d8817e4Smiod int *addresses; 155*3d8817e4Smiod }; 156*3d8817e4Smiod 157*3d8817e4Smiod 158*3d8817e4Smiod struct coff_scope 159*3d8817e4Smiod { 160*3d8817e4Smiod struct coff_section *sec; /* What section */ 161*3d8817e4Smiod int offset; /* where */ 162*3d8817e4Smiod int size; /* How big */ 163*3d8817e4Smiod struct coff_scope *parent; /* one up */ 164*3d8817e4Smiod 165*3d8817e4Smiod struct coff_scope *next; /*next along */ 166*3d8817e4Smiod 167*3d8817e4Smiod int nvars; 168*3d8817e4Smiod 169*3d8817e4Smiod struct coff_symbol *vars_head; /* symbols */ 170*3d8817e4Smiod struct coff_symbol *vars_tail; 171*3d8817e4Smiod 172*3d8817e4Smiod struct coff_scope *list_head; /* children */ 173*3d8817e4Smiod struct coff_scope *list_tail; 174*3d8817e4Smiod 175*3d8817e4Smiod }; 176*3d8817e4Smiod 177*3d8817e4Smiod 178*3d8817e4Smiod struct coff_visible 179*3d8817e4Smiod { 180*3d8817e4Smiod enum coff_vis_type 181*3d8817e4Smiod { 182*3d8817e4Smiod coff_vis_ext_def, 183*3d8817e4Smiod coff_vis_ext_ref, 184*3d8817e4Smiod coff_vis_int_def, 185*3d8817e4Smiod coff_vis_common, 186*3d8817e4Smiod coff_vis_auto, 187*3d8817e4Smiod coff_vis_register, 188*3d8817e4Smiod coff_vis_tag, 189*3d8817e4Smiod coff_vis_member_of_struct, 190*3d8817e4Smiod coff_vis_member_of_enum, 191*3d8817e4Smiod coff_vis_autoparam, 192*3d8817e4Smiod coff_vis_regparam, 193*3d8817e4Smiod } type; 194*3d8817e4Smiod }; 195*3d8817e4Smiod 196*3d8817e4Smiod struct coff_where 197*3d8817e4Smiod { 198*3d8817e4Smiod enum 199*3d8817e4Smiod { 200*3d8817e4Smiod coff_where_stack, coff_where_memory, coff_where_register, coff_where_unknown, 201*3d8817e4Smiod coff_where_strtag, coff_where_member_of_struct, 202*3d8817e4Smiod coff_where_member_of_enum, coff_where_entag, coff_where_typedef 203*3d8817e4Smiod 204*3d8817e4Smiod } where; 205*3d8817e4Smiod int offset; 206*3d8817e4Smiod int bitoffset; 207*3d8817e4Smiod int bitsize; 208*3d8817e4Smiod struct coff_section *section; 209*3d8817e4Smiod }; 210*3d8817e4Smiod 211*3d8817e4Smiod struct coff_symbol 212*3d8817e4Smiod { 213*3d8817e4Smiod char *name; 214*3d8817e4Smiod int tag; 215*3d8817e4Smiod struct coff_type *type; 216*3d8817e4Smiod struct coff_where *where; 217*3d8817e4Smiod struct coff_visible *visible; 218*3d8817e4Smiod struct coff_symbol *next; 219*3d8817e4Smiod struct coff_symbol *next_in_ofile_list; /* For the ofile list */ 220*3d8817e4Smiod int number; 221*3d8817e4Smiod int er_number; 222*3d8817e4Smiod struct coff_sfile *sfile; 223*3d8817e4Smiod }; 224*3d8817e4Smiod 225*3d8817e4Smiod struct coff_ofile *coff_grok PARAMS ((bfd *)); 226