1*fae548d3Szrj /* subsegs.h -> subsegs.c 2*fae548d3Szrj Copyright (C) 1987-2020 Free Software Foundation, Inc. 3*fae548d3Szrj 4*fae548d3Szrj This file is part of GAS, the GNU Assembler. 5*fae548d3Szrj 6*fae548d3Szrj GAS is free software; you can redistribute it and/or modify 7*fae548d3Szrj it under the terms of the GNU General Public License as published by 8*fae548d3Szrj the Free Software Foundation; either version 3, or (at your option) 9*fae548d3Szrj any later version. 10*fae548d3Szrj 11*fae548d3Szrj GAS is distributed in the hope that it will be useful, 12*fae548d3Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 13*fae548d3Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*fae548d3Szrj GNU General Public License for more details. 15*fae548d3Szrj 16*fae548d3Szrj You should have received a copy of the GNU General Public License 17*fae548d3Szrj along with GAS; see the file COPYING. If not, write to the Free 18*fae548d3Szrj Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 19*fae548d3Szrj 02110-1301, USA. */ 20*fae548d3Szrj 21*fae548d3Szrj /* 22*fae548d3Szrj * For every sub-segment the user mentions in the ASsembler program, 23*fae548d3Szrj * we make one struct frchain. Each sub-segment has exactly one struct frchain 24*fae548d3Szrj * and vice versa. 25*fae548d3Szrj * 26*fae548d3Szrj * Struct frchain's are forward chained (in ascending order of sub-segment 27*fae548d3Szrj * code number). The chain runs through frch_next of each subsegment. 28*fae548d3Szrj * This makes it hard to find a subsegment's frags 29*fae548d3Szrj * if programmer uses a lot of them. Most programs only use text0 and 30*fae548d3Szrj * data0, so they don't suffer. At least this way: 31*fae548d3Szrj * (1) There are no "arbitrary" restrictions on how many subsegments 32*fae548d3Szrj * can be programmed; 33*fae548d3Szrj * (2) Subsegments' frchain-s are (later) chained together in the order in 34*fae548d3Szrj * which they are emitted for object file viz text then data. 35*fae548d3Szrj * 36*fae548d3Szrj * From each struct frchain dangles a chain of struct frags. The frags 37*fae548d3Szrj * represent code fragments, for that sub-segment, forward chained. 38*fae548d3Szrj */ 39*fae548d3Szrj 40*fae548d3Szrj #include "obstack.h" 41*fae548d3Szrj 42*fae548d3Szrj struct frch_cfi_data; 43*fae548d3Szrj 44*fae548d3Szrj struct frchain /* control building of a frag chain */ 45*fae548d3Szrj { /* FRCH = FRagment CHain control */ 46*fae548d3Szrj struct frag *frch_root; /* 1st struct frag in chain, or NULL */ 47*fae548d3Szrj struct frag *frch_last; /* last struct frag in chain, or NULL */ 48*fae548d3Szrj struct frchain *frch_next; /* next in chain of struct frchain-s */ 49*fae548d3Szrj subsegT frch_subseg; /* subsegment number of this chain */ 50*fae548d3Szrj fixS *fix_root; /* Root of fixups for this subsegment. */ 51*fae548d3Szrj fixS *fix_tail; /* Last fixup for this subsegment. */ 52*fae548d3Szrj struct obstack frch_obstack; /* for objects in this frag chain */ 53*fae548d3Szrj fragS *frch_frag_now; /* frag_now for this subsegment */ 54*fae548d3Szrj struct frch_cfi_data *frch_cfi_data; 55*fae548d3Szrj }; 56*fae548d3Szrj 57*fae548d3Szrj typedef struct frchain frchainS; 58*fae548d3Szrj 59*fae548d3Szrj /* Frchain we are assembling into now. That is, the current segment's 60*fae548d3Szrj frag chain, even if it contains no (complete) frags. */ 61*fae548d3Szrj extern frchainS *frchain_now; 62*fae548d3Szrj 63*fae548d3Szrj typedef struct segment_info_struct { 64*fae548d3Szrj frchainS *frchainP; 65*fae548d3Szrj unsigned int hadone : 1; 66*fae548d3Szrj 67*fae548d3Szrj /* This field is set if this is a .bss section which does not really 68*fae548d3Szrj have any contents. Once upon a time a .bss section did not have 69*fae548d3Szrj any frags, but that is no longer true. This field prevent the 70*fae548d3Szrj SEC_HAS_CONTENTS flag from being set for the section even if 71*fae548d3Szrj there are frags. */ 72*fae548d3Szrj unsigned int bss : 1; 73*fae548d3Szrj 74*fae548d3Szrj int user_stuff; 75*fae548d3Szrj 76*fae548d3Szrj /* Fixups for this segment. This is only valid after the frchains 77*fae548d3Szrj are run together. */ 78*fae548d3Szrj fixS *fix_root; 79*fae548d3Szrj fixS *fix_tail; 80*fae548d3Szrj 81*fae548d3Szrj symbolS *dot; 82*fae548d3Szrj 83*fae548d3Szrj struct lineno_list *lineno_list_head; 84*fae548d3Szrj struct lineno_list *lineno_list_tail; 85*fae548d3Szrj 86*fae548d3Szrj /* Which BFD section does this gas segment correspond to? */ 87*fae548d3Szrj asection *bfd_section; 88*fae548d3Szrj 89*fae548d3Szrj /* NULL, or pointer to the gas symbol that is the section symbol for 90*fae548d3Szrj this section. sym->bsym and bfd_section->symbol should be the same. */ 91*fae548d3Szrj symbolS *sym; 92*fae548d3Szrj 93*fae548d3Szrj /* Used by dwarf2dbg.c for this section's line table entries. */ 94*fae548d3Szrj void *dwarf2_line_seg; 95*fae548d3Szrj 96*fae548d3Szrj union { 97*fae548d3Szrj /* Current size of section holding stabs strings. */ 98*fae548d3Szrj unsigned long stab_string_size; 99*fae548d3Szrj /* Initial frag for ELF. */ 100*fae548d3Szrj char *p; 101*fae548d3Szrj } 102*fae548d3Szrj stabu; 103*fae548d3Szrj 104*fae548d3Szrj #ifdef NEED_LITERAL_POOL 105*fae548d3Szrj unsigned long literal_pool_size; 106*fae548d3Szrj #endif 107*fae548d3Szrj 108*fae548d3Szrj #ifdef TC_SEGMENT_INFO_TYPE 109*fae548d3Szrj TC_SEGMENT_INFO_TYPE tc_segment_info_data; 110*fae548d3Szrj #endif 111*fae548d3Szrj } segment_info_type; 112*fae548d3Szrj 113*fae548d3Szrj 114*fae548d3Szrj #define seg_info(sec) \ 115*fae548d3Szrj ((segment_info_type *) bfd_section_userdata (sec)) 116*fae548d3Szrj 117*fae548d3Szrj extern symbolS *section_symbol (segT); 118*fae548d3Szrj 119*fae548d3Szrj extern void subsegs_print_statistics (FILE *); 120