struc-symbol.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* struct_symbol.h - Internal symbol structure
  2. Copyright (C) 1987-2015 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. #ifndef __struc_symbol_h__
  17. #define __struc_symbol_h__
  18. struct symbol_flags
  19. {
  20. /* Wether the symbol is a local_symbol. */
  21. unsigned int sy_local_symbol : 1;
  22. /* Wether symbol has been written. */
  23. unsigned int sy_written : 1;
  24. /* Whether symbol value has been completely resolved (used during
  25. final pass over symbol table). */
  26. unsigned int sy_resolved : 1;
  27. /* Whether the symbol value is currently being resolved (used to
  28. detect loops in symbol dependencies). */
  29. unsigned int sy_resolving : 1;
  30. /* Whether the symbol value is used in a reloc. This is used to
  31. ensure that symbols used in relocs are written out, even if they
  32. are local and would otherwise not be. */
  33. unsigned int sy_used_in_reloc : 1;
  34. /* Whether the symbol is used as an operand or in an expression.
  35. NOTE: Not all the backends keep this information accurate;
  36. backends which use this bit are responsible for setting it when
  37. a symbol is used in backend routines. */
  38. unsigned int sy_used : 1;
  39. /* Whether the symbol can be re-defined. */
  40. unsigned int sy_volatile : 1;
  41. /* Whether the symbol is a forward reference. */
  42. unsigned int sy_forward_ref : 1;
  43. /* This is set if the symbol is defined in an MRI common section.
  44. We handle such sections as single common symbols, so symbols
  45. defined within them must be treated specially by the relocation
  46. routines. */
  47. unsigned int sy_mri_common : 1;
  48. /* This is set if the symbol is set with a .weakref directive. */
  49. unsigned int sy_weakrefr : 1;
  50. /* This is set when the symbol is referenced as part of a .weakref
  51. directive, but only if the symbol was not in the symbol table
  52. before. It is cleared as soon as any direct reference to the
  53. symbol is present. */
  54. unsigned int sy_weakrefd : 1;
  55. };
  56. /* The information we keep for a symbol. Note that the symbol table
  57. holds pointers both to this and to local_symbol structures. See
  58. below. */
  59. struct symbol
  60. {
  61. /* Symbol flags. */
  62. struct symbol_flags sy_flags;
  63. /* BFD symbol */
  64. asymbol *bsym;
  65. /* The value of the symbol. */
  66. expressionS sy_value;
  67. /* Forwards and (optionally) backwards chain pointers. */
  68. struct symbol *sy_next;
  69. struct symbol *sy_previous;
  70. /* Pointer to the frag this symbol is attached to, if any.
  71. Otherwise, NULL. */
  72. struct frag *sy_frag;
  73. #ifdef OBJ_SYMFIELD_TYPE
  74. OBJ_SYMFIELD_TYPE sy_obj;
  75. #endif
  76. #ifdef TC_SYMFIELD_TYPE
  77. TC_SYMFIELD_TYPE sy_tc;
  78. #endif
  79. #ifdef TARGET_SYMBOL_FIELDS
  80. TARGET_SYMBOL_FIELDS
  81. #endif
  82. };
  83. /* A pointer in the symbol may point to either a complete symbol
  84. (struct symbol above) or to a local symbol (struct local_symbol
  85. defined here). The symbol code can detect the case by examining
  86. the first field. It is always NULL for a local symbol.
  87. We do this because we ordinarily only need a small amount of
  88. information for a local symbol. The symbol table takes up a lot of
  89. space, and storing less information for a local symbol can make a
  90. big difference in assembler memory usage when assembling a large
  91. file. */
  92. struct local_symbol
  93. {
  94. /* Symbol flags. Only sy_local_symbol and sy_resolved are relevant. */
  95. struct symbol_flags lsy_flags;
  96. /* The symbol section. This also serves as a flag. If this is
  97. reg_section, then this symbol has been converted into a regular
  98. symbol, and lsy_sym points to it. */
  99. segT lsy_section;
  100. /* The symbol name. */
  101. const char *lsy_name;
  102. /* The symbol frag or the real symbol, depending upon the value in
  103. lsy_section. */
  104. union
  105. {
  106. fragS *lsy_frag;
  107. symbolS *lsy_sym;
  108. } u;
  109. /* The value of the symbol. */
  110. valueT lsy_value;
  111. #ifdef TC_LOCAL_SYMFIELD_TYPE
  112. TC_LOCAL_SYMFIELD_TYPE lsy_tc;
  113. #endif
  114. };
  115. #define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
  116. #define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
  117. #define local_symbol_resolved_p(l) ((l)->lsy_flags.sy_resolved)
  118. #define local_symbol_mark_resolved(l) ((l)->lsy_flags.sy_resolved = 1)
  119. #define local_symbol_get_frag(l) ((l)->u.lsy_frag)
  120. #define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
  121. #define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
  122. #define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
  123. #endif /* __struc_symbol_h__ */