subsegs.h revision 33965
1/* subsegs.h -> subsegs.c 2 Copyright (C) 1987, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. 3 4 This file is part of GAS, the GNU Assembler. 5 6 GAS is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 GAS is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GAS; see the file COPYING. If not, write to 18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 20/* 21 * For every sub-segment the user mentions in the ASsembler program, 22 * we make one struct frchain. Each sub-segment has exactly one struct frchain 23 * and vice versa. 24 * 25 * Struct frchain's are forward chained (in ascending order of sub-segment 26 * code number). The chain runs through frch_next of each subsegment. 27 * This makes it hard to find a subsegment's frags 28 * if programmer uses a lot of them. Most programs only use text0 and 29 * data0, so they don't suffer. At least this way: 30 * (1) There are no "arbitrary" restrictions on how many subsegments 31 * can be programmed; 32 * (2) Subsegments' frchain-s are (later) chained together in the order in 33 * which they are emitted for object file viz text then data. 34 * 35 * From each struct frchain dangles a chain of struct frags. The frags 36 * represent code fragments, for that sub-segment, forward chained. 37 */ 38 39#include "obstack.h" 40 41struct frchain /* control building of a frag chain */ 42{ /* FRCH = FRagment CHain control */ 43 struct frag *frch_root; /* 1st struct frag in chain, or NULL */ 44 struct frag *frch_last; /* last struct frag in chain, or NULL */ 45 struct frchain *frch_next; /* next in chain of struct frchain-s */ 46 segT frch_seg; /* SEG_TEXT or SEG_DATA. */ 47 subsegT frch_subseg; /* subsegment number of this chain */ 48#ifdef BFD_ASSEMBLER 49 fixS *fix_root; /* Root of fixups for this subsegment. */ 50 fixS *fix_tail; /* Last fixup for this subsegment. */ 51#endif 52 struct obstack frch_obstack; /* for objects in this frag chain */ 53 fragS *frch_frag_now; /* frag_now for this subsegment */ 54}; 55 56typedef struct frchain frchainS; 57 58/* All subsegments' chains hang off here. NULL means no frchains yet. */ 59extern frchainS *frchain_root; 60 61/* Frchain we are assembling into now. That is, the current segment's 62 frag chain, even if it contains no (complete) frags. */ 63extern frchainS *frchain_now; 64 65 66typedef struct 67{ 68 frchainS *frchainP; 69 unsigned int hadone : 1; 70 71 /* This field is set if this is a .bss section which does not really 72 have any contents. Once upon a time a .bss section did not have 73 any frags, but that is no longer true. This field prevent the 74 SEC_HAS_CONTENTS flag from being set for the section even if 75 there are frags. */ 76 unsigned int bss : 1; 77 78 int user_stuff; 79 80 /* Fixups for this segment. If BFD_ASSEMBLER, this is only valid 81 after the frchains are run together. */ 82 fixS *fix_root; 83 fixS *fix_tail; 84 85#if defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER) 86 struct internal_scnhdr scnhdr; 87 enum linkonce_type linkonce; 88 const char *name; 89#endif 90 91 symbolS *dot; 92 93 struct lineno_list *lineno_list_head; 94 struct lineno_list *lineno_list_tail; 95 96#ifdef BFD_ASSEMBLER 97 /* Which BFD section does this gas segment correspond to? */ 98 asection *bfd_section; 99 100 /* NULL, or pointer to the gas symbol that is the section symbol for 101 this section. sym->bsym and bfd_section->symbol should be the same. */ 102 symbolS *sym; 103#endif 104 105 union 106 { 107 /* Current size of section holding stabs strings. */ 108 unsigned long stab_string_size; 109 /* Initial frag for ELF. */ 110 char *p; 111 } 112 stabu; 113 114#ifdef NEED_LITERAL_POOL 115 unsigned long literal_pool_size; 116#endif 117 118#ifdef TC_SEGMENT_INFO_TYPE 119 TC_SEGMENT_INFO_TYPE tc_segment_info_data; 120#endif 121} segment_info_type; 122 123#ifdef BFD_ASSEMBLER 124 125extern segment_info_type *seg_info PARAMS ((segT)); 126extern symbolS *section_symbol PARAMS ((segT)); 127 128#else /* ! BFD_ASSEMBLER */ 129 130#ifdef MANY_SEGMENTS 131 132extern segment_info_type segment_info[]; 133 134#define seg_info(SEC) (&segment_info[SEC]) 135 136#else 137 138/* Sentinel for frchain crawling. Points to the 1st data-segment 139 frchain. (Which is pointed to by the last text-segment frchain.) */ 140extern frchainS *data0_frchainP; 141extern frchainS *bss0_frchainP; 142 143/* Dummy so stuff can compile. Should never be used. */ 144struct seg_info_trash { 145 struct { 146 unsigned stab_string_size : 1; 147 } stabu; 148 unsigned hadone : 1; 149}; 150#define seg_info(S) (abort (), (struct seg_info_trash *) 0) 151 152#endif 153 154#endif /* ! BFD_ASSEMBLER */ 155 156extern void subsegs_print_statistics PARAMS ((FILE *)); 157 158/* end of subsegs.h */ 159