1104834Sobrien/* coffgrok.h
2218822Sdim   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
378828Sobrien
478828SobrienThis file is part of GNU Binutils.
578828Sobrien
678828SobrienThis program is free software; you can redistribute it and/or modify
778828Sobrienit under the terms of the GNU General Public License as published by
878828Sobrienthe Free Software Foundation; either version 2 of the License, or
978828Sobrien(at your option) any later version.
1078828Sobrien
1178828SobrienThis program is distributed in the hope that it will be useful,
1278828Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1378828SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1478828SobrienGNU General Public License for more details.
1578828Sobrien
1678828SobrienYou should have received a copy of the GNU General Public License
1778828Sobrienalong with this program; if not, write to the Free Software
18218822SdimFoundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
1978828Sobrien
2033965Sjdp#define T_NULL		0
2133965Sjdp#define T_VOID		1	/* function argument (only used by compiler) */
2233965Sjdp#define T_CHAR		2	/* character		*/
2333965Sjdp#define T_SHORT		3	/* short integer	*/
2433965Sjdp#define T_INT		4	/* integer		*/
2533965Sjdp#define T_LONG		5	/* long integer		*/
2633965Sjdp#define T_FLOAT		6	/* floating point	*/
2733965Sjdp#define T_DOUBLE	7	/* double word		*/
2833965Sjdp#define T_STRUCT	8	/* structure 		*/
2933965Sjdp#define T_UNION		9	/* union 		*/
3033965Sjdp#define T_ENUM		10	/* enumeration 		*/
3133965Sjdp#define T_MOE		11	/* member of enumeration*/
3233965Sjdp#define T_UCHAR		12	/* unsigned character	*/
3333965Sjdp#define T_USHORT	13	/* unsigned short	*/
3433965Sjdp#define T_UINT		14	/* unsigned integer	*/
3533965Sjdp#define T_ULONG		15	/* unsigned long	*/
3633965Sjdp#define T_LNGDBL	16	/* long double		*/
3733965Sjdp
3833965Sjdp
3933965Sjdp struct coff_reloc
4033965Sjdp {
4133965Sjdp   int offset;
4233965Sjdp   struct coff_symbol *symbol;
4333965Sjdp   int addend;
4433965Sjdp };
4533965Sjdp
46104834Sobrien struct coff_section
4733965Sjdp {
4833965Sjdp   char *name;
4933965Sjdp   int code;
5033965Sjdp   int data;
5133965Sjdp   int address;
5233965Sjdp   int number;  /* 0..n, .text = 0 */
5333965Sjdp   int nrelocs;
5433965Sjdp   int size;
5533965Sjdp   struct coff_reloc *relocs;
56130561Sobrien   struct bfd_section *bfd_section;
5733965Sjdp };
5833965Sjdp
5933965Sjdpstruct coff_ofile
6033965Sjdp{
6133965Sjdp  int nsources;
6233965Sjdp  struct coff_sfile *source_head;
6333965Sjdp  struct coff_sfile *source_tail;
6433965Sjdp  int nsections;
6533965Sjdp  struct coff_section *sections;
6633965Sjdp  struct coff_symbol *symbol_list_head;
6733965Sjdp  struct coff_symbol *symbol_list_tail;
6833965Sjdp};
6933965Sjdp
7033965Sjdpstruct coff_isection {
7133965Sjdp  int low;
7233965Sjdp  int high;
7333965Sjdp  int init;
7433965Sjdp  struct coff_section *parent;
7533965Sjdp};
7633965Sjdp
7733965Sjdpstruct coff_sfile
7833965Sjdp{
7933965Sjdp  char *name;
8033965Sjdp  struct coff_scope *scope;
8133965Sjdp  struct coff_sfile *next;
8233965Sjdp
8333965Sjdp  /* Vector which maps where in each output section
8433965Sjdp     the input file has it's data */
85104834Sobrien  struct coff_isection *section;
8633965Sjdp
8733965Sjdp};
8833965Sjdp
8933965Sjdp
9033965Sjdp struct coff_type
9133965Sjdp{
9233965Sjdp  int size;
9333965Sjdp  enum
9433965Sjdp    {
9533965Sjdp      coff_pointer_type, coff_function_type, coff_array_type, coff_structdef_type, coff_basic_type,
9633965Sjdp      coff_structref_type, coff_enumref_type, coff_enumdef_type, coff_secdef_type
9733965Sjdp      } type;
9833965Sjdp  union
9933965Sjdp    {
100104834Sobrien      struct
10133965Sjdp	{
10233965Sjdp	int address;
10333965Sjdp	int size;
10433965Sjdp      } asecdef;
10533965Sjdp
10633965Sjdp      struct
10733965Sjdp	{
10833965Sjdp	  int isstruct;
10933965Sjdp	  struct coff_scope *elements;
11033965Sjdp	  int idx;
11133965Sjdp	}
11233965Sjdp      astructdef;
11333965Sjdp      struct
11433965Sjdp	{
11533965Sjdp	  struct coff_symbol *ref;
11633965Sjdp	} astructref;
11733965Sjdp
11833965Sjdp      struct
11933965Sjdp	{
12033965Sjdp	  struct coff_scope *elements;
12133965Sjdp	  int idx;
12233965Sjdp	} aenumdef;
12333965Sjdp      struct
12433965Sjdp	{
12533965Sjdp	  struct coff_symbol *ref;
12633965Sjdp	} aenumref;
12733965Sjdp
12833965Sjdp      struct
12933965Sjdp	{
13033965Sjdp	  struct coff_type *points_to;
13133965Sjdp	} pointer;
13233965Sjdp      struct
13333965Sjdp	{
13433965Sjdp	  int dim;
13533965Sjdp	  struct coff_type *array_of;
13633965Sjdp	} array;
13733965Sjdp
13833965Sjdp      struct
13933965Sjdp	{
14033965Sjdp	  struct coff_type *function_returns;
14133965Sjdp	  struct coff_scope *parameters;
14233965Sjdp	  struct coff_scope *code;
14333965Sjdp	  struct coff_line *lines;
14433965Sjdp	} function;
14533965Sjdp      int basic;		/* One of T_VOID.. T_UINT */
14633965Sjdp    }  u;
14733965Sjdp};
14833965Sjdp
14933965Sjdp
150104834Sobrien struct coff_line
15133965Sjdp {
15233965Sjdp   int nlines;
15333965Sjdp   int *lines;
15433965Sjdp   int *addresses;
15533965Sjdp };
15633965Sjdp
15733965Sjdp
15833965Sjdp struct coff_scope
15933965Sjdp   {
16033965Sjdp     struct coff_section *sec; /* What section */
16133965Sjdp     int offset; /* where */
16233965Sjdp     int size; /* How big */
16333965Sjdp     struct coff_scope *parent;	/* one up */
16433965Sjdp
16533965Sjdp     struct coff_scope *next;	/*next along */
16633965Sjdp
16733965Sjdp     int nvars;
16833965Sjdp
16933965Sjdp     struct coff_symbol *vars_head;	/* symbols */
17033965Sjdp     struct coff_symbol *vars_tail;
17133965Sjdp
17233965Sjdp     struct coff_scope *list_head;	/* children */
17333965Sjdp     struct coff_scope *list_tail;
17433965Sjdp
17533965Sjdp   };
17633965Sjdp
17733965Sjdp
17833965Sjdp struct coff_visible
17933965Sjdp   {
18033965Sjdp     enum coff_vis_type
18133965Sjdp       {
18233965Sjdp	 coff_vis_ext_def,
18333965Sjdp	 coff_vis_ext_ref,
18433965Sjdp	 coff_vis_int_def,
18533965Sjdp	 coff_vis_common,
18633965Sjdp	 coff_vis_auto,
18733965Sjdp	 coff_vis_register,
18833965Sjdp	 coff_vis_tag,
18933965Sjdp	 coff_vis_member_of_struct,
19033965Sjdp	 coff_vis_member_of_enum,
191104834Sobrien	 coff_vis_autoparam,
19233965Sjdp	 coff_vis_regparam,
19333965Sjdp       } type;
19433965Sjdp   };
19533965Sjdp
19633965Sjdp struct coff_where
19733965Sjdp   {
19833965Sjdp     enum
19933965Sjdp       {
20033965Sjdp	 coff_where_stack, coff_where_memory, coff_where_register, coff_where_unknown,
20133965Sjdp	 coff_where_strtag, coff_where_member_of_struct,
20233965Sjdp	 coff_where_member_of_enum, coff_where_entag, coff_where_typedef
20333965Sjdp
20433965Sjdp       } where;
20533965Sjdp     int offset;
20633965Sjdp     int bitoffset;
20733965Sjdp     int bitsize;
20833965Sjdp     struct coff_section *section;
20933965Sjdp   };
21033965Sjdp
21133965Sjdp struct coff_symbol
21233965Sjdp   {
21333965Sjdp     char *name;
21433965Sjdp     int tag;
21533965Sjdp     struct coff_type *type;
21633965Sjdp     struct coff_where *where;
21733965Sjdp     struct coff_visible *visible;
21833965Sjdp     struct coff_symbol *next;
21933965Sjdp     struct coff_symbol *next_in_ofile_list; /* For the ofile list */
22033965Sjdp     int number;
22133965Sjdp     int er_number;
22233965Sjdp     struct coff_sfile *sfile;
22333965Sjdp  };
22433965Sjdp
22589857Sobrienstruct coff_ofile *coff_grok PARAMS ((bfd *));
226