symbols.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* symbols.h -
  2. Copyright (C) 1987-2022 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS 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, or (at your option)
  7. any later version.
  8. GAS 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 GAS; see the file COPYING. If not, write to the Free
  14. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  15. 02110-1301, USA. */
  16. extern struct obstack notes; /* eg FixS live here. */
  17. extern struct obstack cond_obstack; /* this is where we track .ifdef/.endif
  18. (if we do that at all). */
  19. extern symbolS *symbol_rootP; /* all the symbol nodes */
  20. extern symbolS *symbol_lastP; /* last struct symbol we made, or NULL */
  21. extern symbolS abs_symbol;
  22. extern symbolS dot_symbol;
  23. extern int symbol_table_frozen;
  24. /* This is non-zero if symbols are case sensitive, which is the
  25. default. */
  26. extern int symbols_case_sensitive;
  27. char * symbol_relc_make_expr (expressionS *);
  28. char * symbol_relc_make_sym (symbolS *);
  29. char * symbol_relc_make_value (offsetT);
  30. char *decode_local_label_name (char *s);
  31. symbolS *symbol_find (const char *name);
  32. symbolS *symbol_find_noref (const char *name, int noref);
  33. symbolS *symbol_find_exact (const char *name);
  34. symbolS *symbol_find_exact_noref (const char *name, int noref);
  35. symbolS *symbol_find_or_make (const char *name);
  36. symbolS *symbol_make (const char *name);
  37. symbolS *symbol_new (const char *, segT, fragS *, valueT);
  38. symbolS *symbol_create (const char *, segT, fragS *, valueT);
  39. struct local_symbol *local_symbol_make (const char *, segT, fragS *, valueT);
  40. symbolS *symbol_clone (symbolS *, int);
  41. #undef symbol_clone_if_forward_ref
  42. symbolS *symbol_clone_if_forward_ref (symbolS *, int);
  43. #define symbol_clone_if_forward_ref(s) symbol_clone_if_forward_ref (s, 0)
  44. symbolS *symbol_temp_new (segT, fragS *, valueT);
  45. symbolS *symbol_temp_new_now (void);
  46. symbolS *symbol_temp_new_now_octets (void);
  47. symbolS *symbol_temp_make (void);
  48. symbolS *colon (const char *sym_name);
  49. void local_colon (int n);
  50. void symbol_begin (void);
  51. void dot_symbol_init (void);
  52. void symbol_print_statistics (FILE *);
  53. void symbol_table_insert (symbolS * symbolP);
  54. valueT resolve_symbol_value (symbolS *);
  55. void resolve_local_symbol_values (void);
  56. int snapshot_symbol (symbolS **, valueT *, segT *, fragS **);
  57. void print_symbol_value (symbolS *);
  58. void print_expr (expressionS *);
  59. void print_expr_1 (FILE *, expressionS *);
  60. void print_symbol_value_1 (FILE *, symbolS *);
  61. int dollar_label_defined (unsigned int);
  62. void dollar_label_clear (void);
  63. void define_dollar_label (unsigned int);
  64. char *dollar_label_name (unsigned int, unsigned int);
  65. void fb_label_instance_inc (unsigned int);
  66. char *fb_label_name (unsigned int, unsigned int);
  67. extern void copy_symbol_attributes (symbolS *, symbolS *);
  68. /* Get and set the values of symbols. These used to be macros. */
  69. extern valueT S_GET_VALUE (symbolS *);
  70. extern void S_SET_VALUE (symbolS *, valueT);
  71. extern int S_IS_FUNCTION (symbolS *);
  72. extern int S_IS_EXTERNAL (symbolS *);
  73. extern int S_IS_WEAK (symbolS *);
  74. extern int S_IS_WEAKREFR (symbolS *);
  75. extern int S_IS_WEAKREFD (symbolS *);
  76. extern int S_IS_COMMON (symbolS *);
  77. extern int S_IS_DEFINED (symbolS *);
  78. extern int S_FORCE_RELOC (symbolS *, int);
  79. extern int S_IS_DEBUG (symbolS *);
  80. extern int S_IS_LOCAL (symbolS *);
  81. extern int S_IS_STABD (symbolS *);
  82. extern int S_CAN_BE_REDEFINED (const symbolS *);
  83. extern int S_IS_VOLATILE (const symbolS *);
  84. extern int S_IS_FORWARD_REF (const symbolS *);
  85. extern const char *S_GET_NAME (symbolS *);
  86. extern segT S_GET_SEGMENT (symbolS *);
  87. extern void S_SET_SEGMENT (symbolS *, segT);
  88. extern void S_SET_EXTERNAL (symbolS *);
  89. extern void S_SET_NAME (symbolS *, const char *);
  90. extern void S_CLEAR_EXTERNAL (symbolS *);
  91. extern void S_SET_WEAK (symbolS *);
  92. extern void S_SET_WEAKREFR (symbolS *);
  93. extern void S_CLEAR_WEAKREFR (symbolS *);
  94. extern void S_SET_WEAKREFD (symbolS *);
  95. extern void S_CLEAR_WEAKREFD (symbolS *);
  96. extern void S_SET_THREAD_LOCAL (symbolS *);
  97. extern void S_SET_VOLATILE (symbolS *);
  98. extern void S_CLEAR_VOLATILE (symbolS *);
  99. extern void S_SET_FORWARD_REF (symbolS *);
  100. #ifndef WORKING_DOT_WORD
  101. struct broken_word
  102. {
  103. /* Linked list -- one of these structures per ".word x-y+C"
  104. expression. */
  105. struct broken_word *next_broken_word;
  106. /* Segment and subsegment for broken word. */
  107. segT seg;
  108. subsegT subseg;
  109. /* Which frag is this broken word in? */
  110. fragS *frag;
  111. /* Where in the frag is it? */
  112. char *word_goes_here;
  113. /* Where to add the break. */
  114. fragS *dispfrag; /* where to add the break */
  115. /* Operands of expression. */
  116. symbolS *add;
  117. symbolS *sub;
  118. offsetT addnum;
  119. int added; /* nasty thing happened yet? */
  120. /* 1: added and has a long-jump */
  121. /* 2: added but uses someone elses long-jump */
  122. /* Pointer to broken_word with a similar long-jump. */
  123. struct broken_word *use_jump;
  124. };
  125. extern struct broken_word *broken_words;
  126. #endif /* ifdef WORKING_DOT_WORD */
  127. /*
  128. * Current means for getting from symbols to segments and vice verse.
  129. * This will change for infinite-segments support (e.g. COFF).
  130. */
  131. extern const segT N_TYPE_seg[]; /* subseg.c */
  132. #define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] )
  133. extern const short seg_N_TYPE[];/* subseg.c */
  134. #define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */
  135. void symbol_clear_list_pointers (symbolS * symbolP);
  136. void symbol_insert (symbolS * addme, symbolS * target,
  137. symbolS ** rootP, symbolS ** lastP);
  138. void symbol_remove (symbolS * symbolP, symbolS ** rootP,
  139. symbolS ** lastP);
  140. extern symbolS *symbol_previous (symbolS *);
  141. extern int symbol_on_chain (symbolS *s, symbolS *rootPP, symbolS *lastPP);
  142. void verify_symbol_chain (symbolS * rootP, symbolS * lastP);
  143. void symbol_append (symbolS * addme, symbolS * target,
  144. symbolS ** rootP, symbolS ** lastP);
  145. extern symbolS *symbol_next (symbolS *);
  146. extern expressionS *symbol_get_value_expression (symbolS *);
  147. extern void symbol_set_value_expression (symbolS *, const expressionS *);
  148. extern offsetT *symbol_X_add_number (symbolS *);
  149. extern void symbol_set_value_now (symbolS *);
  150. extern void symbol_set_frag (symbolS *, fragS *);
  151. extern fragS *symbol_get_frag (symbolS *);
  152. extern void symbol_mark_used (symbolS *);
  153. extern void symbol_clear_used (symbolS *);
  154. extern int symbol_used_p (symbolS *);
  155. extern void symbol_mark_used_in_reloc (symbolS *);
  156. extern void symbol_clear_used_in_reloc (symbolS *);
  157. extern int symbol_used_in_reloc_p (symbolS *);
  158. extern void symbol_mark_mri_common (symbolS *);
  159. extern void symbol_clear_mri_common (symbolS *);
  160. extern int symbol_mri_common_p (symbolS *);
  161. extern void symbol_mark_written (symbolS *);
  162. extern void symbol_clear_written (symbolS *);
  163. extern int symbol_written_p (symbolS *);
  164. extern void symbol_mark_removed (symbolS *);
  165. extern int symbol_removed_p (symbolS *);
  166. extern void symbol_mark_resolved (symbolS *);
  167. extern int symbol_resolved_p (symbolS *);
  168. extern int symbol_section_p (symbolS *);
  169. extern int symbol_equated_p (symbolS *);
  170. extern int symbol_equated_reloc_p (symbolS *);
  171. extern int symbol_constant_p (symbolS *);
  172. extern int symbol_shadow_p (symbolS *);
  173. extern symbolS *symbol_symbolS (symbolS *);
  174. extern asymbol *symbol_get_bfdsym (symbolS *);
  175. extern void symbol_set_bfdsym (symbolS *, asymbol *);
  176. extern int symbol_same_p (symbolS *, symbolS *);
  177. #ifdef OBJ_SYMFIELD_TYPE
  178. OBJ_SYMFIELD_TYPE *symbol_get_obj (symbolS *);
  179. void symbol_set_obj (symbolS *, OBJ_SYMFIELD_TYPE *);
  180. #endif
  181. #ifdef TC_SYMFIELD_TYPE
  182. TC_SYMFIELD_TYPE *symbol_get_tc (symbolS *);
  183. void symbol_set_tc (symbolS *, TC_SYMFIELD_TYPE *);
  184. #endif