coffgrok.h 4.8 KB

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