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