subsegs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* subsegs.h -> subsegs.c
  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. /*
  17. * For every sub-segment the user mentions in the ASsembler program,
  18. * we make one struct frchain. Each sub-segment has exactly one struct frchain
  19. * and vice versa.
  20. *
  21. * Struct frchain's are forward chained (in ascending order of sub-segment
  22. * code number). The chain runs through frch_next of each subsegment.
  23. * This makes it hard to find a subsegment's frags
  24. * if programmer uses a lot of them. Most programs only use text0 and
  25. * data0, so they don't suffer. At least this way:
  26. * (1) There are no "arbitrary" restrictions on how many subsegments
  27. * can be programmed;
  28. * (2) Subsegments' frchain-s are (later) chained together in the order in
  29. * which they are emitted for object file viz text then data.
  30. *
  31. * From each struct frchain dangles a chain of struct frags. The frags
  32. * represent code fragments, for that sub-segment, forward chained.
  33. */
  34. #include "obstack.h"
  35. struct frch_cfi_data;
  36. struct frchain /* control building of a frag chain */
  37. { /* FRCH = FRagment CHain control */
  38. struct frag *frch_root; /* 1st struct frag in chain, or NULL */
  39. struct frag *frch_last; /* last struct frag in chain, or NULL */
  40. struct frchain *frch_next; /* next in chain of struct frchain-s */
  41. subsegT frch_subseg; /* subsegment number of this chain */
  42. fixS *fix_root; /* Root of fixups for this subsegment. */
  43. fixS *fix_tail; /* Last fixup for this subsegment. */
  44. struct obstack frch_obstack; /* for objects in this frag chain */
  45. fragS *frch_frag_now; /* frag_now for this subsegment */
  46. struct frch_cfi_data *frch_cfi_data;
  47. };
  48. typedef struct frchain frchainS;
  49. /* Frchain we are assembling into now. That is, the current segment's
  50. frag chain, even if it contains no (complete) frags. */
  51. extern frchainS *frchain_now;
  52. typedef struct segment_info_struct {
  53. frchainS *frchainP;
  54. unsigned int hadone : 1;
  55. /* This field is set if this is a .bss section which does not really
  56. have any contents. Once upon a time a .bss section did not have
  57. any frags, but that is no longer true. This field prevent the
  58. SEC_HAS_CONTENTS flag from being set for the section even if
  59. there are frags. */
  60. unsigned int bss : 1;
  61. int user_stuff;
  62. /* Fixups for this segment. This is only valid after the frchains
  63. are run together. */
  64. fixS *fix_root;
  65. fixS *fix_tail;
  66. symbolS *dot;
  67. struct lineno_list *lineno_list_head;
  68. struct lineno_list *lineno_list_tail;
  69. /* Which BFD section does this gas segment correspond to? */
  70. asection *bfd_section;
  71. /* NULL, or pointer to the gas symbol that is the section symbol for
  72. this section. sym->bsym and bfd_section->symbol should be the same. */
  73. symbolS *sym;
  74. /* Used by dwarf2dbg.c for this section's line table entries. */
  75. void *dwarf2_line_seg;
  76. union {
  77. /* Current size of section holding stabs strings. */
  78. unsigned long stab_string_size;
  79. /* Initial frag for ELF. */
  80. char *p;
  81. }
  82. stabu;
  83. #ifdef NEED_LITERAL_POOL
  84. unsigned long literal_pool_size;
  85. #endif
  86. #ifdef TC_SEGMENT_INFO_TYPE
  87. TC_SEGMENT_INFO_TYPE tc_segment_info_data;
  88. #endif
  89. } segment_info_type;
  90. #define seg_info(sec) \
  91. ((segment_info_type *) bfd_section_userdata (sec))
  92. extern symbolS *section_symbol (segT);
  93. extern void subsegs_print_statistics (FILE *);