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