]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* subsegs.h -> subsegs.c |
f17c130b | 2 | Copyright 1987, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2003, 2005 |
a01b9fa4 | 3 | Free Software Foundation, Inc. |
252b5132 RH |
4 | |
5 | This file is part of GAS, the GNU Assembler. | |
6 | ||
7 | GAS is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GAS is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GAS; see the file COPYING. If not, write to the Free | |
4b4da160 NC |
19 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
20 | 02110-1301, USA. */ | |
252b5132 RH |
21 | |
22 | /* | |
23 | * For every sub-segment the user mentions in the ASsembler program, | |
24 | * we make one struct frchain. Each sub-segment has exactly one struct frchain | |
25 | * and vice versa. | |
26 | * | |
27 | * Struct frchain's are forward chained (in ascending order of sub-segment | |
28 | * code number). The chain runs through frch_next of each subsegment. | |
29 | * This makes it hard to find a subsegment's frags | |
30 | * if programmer uses a lot of them. Most programs only use text0 and | |
31 | * data0, so they don't suffer. At least this way: | |
32 | * (1) There are no "arbitrary" restrictions on how many subsegments | |
33 | * can be programmed; | |
34 | * (2) Subsegments' frchain-s are (later) chained together in the order in | |
35 | * which they are emitted for object file viz text then data. | |
36 | * | |
37 | * From each struct frchain dangles a chain of struct frags. The frags | |
38 | * represent code fragments, for that sub-segment, forward chained. | |
39 | */ | |
40 | ||
41 | #include "obstack.h" | |
42 | ||
43 | struct frchain /* control building of a frag chain */ | |
44 | { /* FRCH = FRagment CHain control */ | |
45 | struct frag *frch_root; /* 1st struct frag in chain, or NULL */ | |
46 | struct frag *frch_last; /* last struct frag in chain, or NULL */ | |
47 | struct frchain *frch_next; /* next in chain of struct frchain-s */ | |
a01b9fa4 | 48 | segT frch_seg; /* SEG_TEXT or SEG_DATA. */ |
252b5132 RH |
49 | subsegT frch_subseg; /* subsegment number of this chain */ |
50 | #ifdef BFD_ASSEMBLER | |
51 | fixS *fix_root; /* Root of fixups for this subsegment. */ | |
52 | fixS *fix_tail; /* Last fixup for this subsegment. */ | |
53 | #endif | |
54 | struct obstack frch_obstack; /* for objects in this frag chain */ | |
55 | fragS *frch_frag_now; /* frag_now for this subsegment */ | |
56 | }; | |
57 | ||
58 | typedef struct frchain frchainS; | |
59 | ||
60 | /* All subsegments' chains hang off here. NULL means no frchains yet. */ | |
61 | extern frchainS *frchain_root; | |
62 | ||
63 | /* Frchain we are assembling into now. That is, the current segment's | |
a01b9fa4 | 64 | frag chain, even if it contains no (complete) frags. */ |
252b5132 RH |
65 | extern frchainS *frchain_now; |
66 | ||
ef99799a | 67 | typedef struct segment_info_struct { |
252b5132 RH |
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 | ||
ef99799a KH |
105 | union { |
106 | /* Current size of section holding stabs strings. */ | |
107 | unsigned long stab_string_size; | |
108 | /* Initial frag for ELF. */ | |
109 | char *p; | |
110 | } | |
252b5132 RH |
111 | stabu; |
112 | ||
113 | #ifdef NEED_LITERAL_POOL | |
114 | unsigned long literal_pool_size; | |
115 | #endif | |
116 | ||
117 | #ifdef TC_SEGMENT_INFO_TYPE | |
118 | TC_SEGMENT_INFO_TYPE tc_segment_info_data; | |
119 | #endif | |
120 | } segment_info_type; | |
121 | ||
122 | #ifdef BFD_ASSEMBLER | |
123 | ||
24361518 KH |
124 | extern segment_info_type *seg_info (segT); |
125 | extern symbolS *section_symbol (segT); | |
252b5132 RH |
126 | |
127 | #else /* ! BFD_ASSEMBLER */ | |
128 | ||
129 | #ifdef MANY_SEGMENTS | |
130 | ||
131 | extern segment_info_type segment_info[]; | |
132 | ||
133 | #define seg_info(SEC) (&segment_info[SEC]) | |
134 | ||
135 | #else | |
136 | ||
137 | /* Sentinel for frchain crawling. Points to the 1st data-segment | |
138 | frchain. (Which is pointed to by the last text-segment frchain.) */ | |
139 | extern frchainS *data0_frchainP; | |
140 | extern frchainS *bss0_frchainP; | |
141 | ||
f17c130b | 142 | #define seg_info(S) (abort (), (segment_info_type *) 0) |
252b5132 RH |
143 | |
144 | #endif | |
145 | ||
146 | #endif /* ! BFD_ASSEMBLER */ | |
147 | ||
24361518 | 148 | extern void subsegs_print_statistics (FILE *); |