Commit | Line | Data |
---|---|---|
2fa0b342 | 1 | /* ldlang.h - |
c611e285 | 2 | |
2fa0b342 | 3 | Copyright (C) 1991 Free Software Foundation, Inc. |
c611e285 | 4 | |
2fa0b342 | 5 | This file is part of GLD, the Gnu Linker. |
c611e285 | 6 | |
2fa0b342 DHW |
7 | GLD 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 1, or (at your option) | |
10 | any later version. | |
c611e285 | 11 | |
2fa0b342 DHW |
12 | GLD 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. | |
c611e285 | 16 | |
2fa0b342 DHW |
17 | You should have received a copy of the GNU General Public License |
18 | along with GLD; see the file COPYING. If not, write to | |
19 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | ||
22 | typedef enum { | |
23 | lang_input_file_is_l_enum, | |
24 | lang_input_file_is_symbols_only_enum, | |
25 | lang_input_file_is_marker_enum, | |
26 | lang_input_file_is_fake_enum, | |
c611e285 | 27 | lang_input_file_is_search_file_enum, |
2fa0b342 DHW |
28 | lang_input_file_is_file_enum } lang_input_file_enum_type; |
29 | ||
30 | typedef unsigned short fill_type; | |
31 | typedef struct statement_list { | |
32 | union lang_statement_union *head; | |
33 | union lang_statement_union **tail; | |
34 | } lang_statement_list_type; | |
35 | ||
36 | ||
c611e285 | 37 | |
2fa0b342 DHW |
38 | |
39 | typedef struct memory_region_struct { | |
40 | char *name; | |
41 | struct memory_region_struct *next; | |
42 | bfd_vma origin; | |
43 | bfd_offset length; | |
44 | bfd_vma current; | |
c611e285 | 45 | int flags; |
2fa0b342 DHW |
46 | } lang_memory_region_type ; |
47 | ||
48 | typedef struct lang_statement_header_struct | |
c611e285 SC |
49 | { |
50 | union lang_statement_union *next; | |
51 | enum statement_enum { | |
52 | lang_output_section_statement_enum, | |
53 | lang_assignment_statement_enum, | |
54 | lang_input_statement_enum, | |
55 | lang_address_statement_enum, | |
56 | lang_wild_statement_enum, | |
57 | lang_input_section_enum, | |
58 | lang_object_symbols_statement_enum, | |
59 | lang_fill_statement_enum, | |
60 | lang_data_statement_enum, | |
61 | lang_target_statement_enum, | |
62 | lang_output_statement_enum, | |
63 | lang_padding_statement_enum, | |
64 | ||
65 | lang_afile_asection_pair_statement_enum, | |
66 | lang_constructors_statement_enum | |
67 | } type; | |
68 | ||
69 | } lang_statement_header_type; | |
2fa0b342 DHW |
70 | |
71 | ||
72 | typedef struct | |
c611e285 SC |
73 | { |
74 | lang_statement_header_type header; | |
75 | union etree_union *exp; | |
76 | } lang_assignment_statement_type; | |
2fa0b342 DHW |
77 | |
78 | ||
79 | typedef struct lang_target_statement_struct { | |
80 | lang_statement_header_type header; | |
1418c83b | 81 | CONST char *target; |
2fa0b342 DHW |
82 | } lang_target_statement_type; |
83 | ||
84 | ||
85 | typedef struct lang_output_statement_struct { | |
86 | lang_statement_header_type header; | |
1418c83b | 87 | CONST char *name; |
2fa0b342 DHW |
88 | } lang_output_statement_type; |
89 | ||
90 | ||
91 | typedef struct lang_output_section_statement_struct | |
c611e285 SC |
92 | { |
93 | lang_statement_header_type header; | |
94 | union etree_union *addr_tree; | |
95 | lang_statement_list_type children; | |
96 | CONST char *memspec; | |
97 | union lang_statement_union *next; | |
98 | CONST char *name; | |
99 | unsigned long subsection_alignment; | |
100 | boolean processed; | |
101 | ||
102 | asection *bfd_section; | |
103 | int flags; | |
104 | struct memory_region_struct *region; | |
105 | size_t block_value; | |
106 | fill_type fill; | |
107 | } lang_output_section_statement_type; | |
2fa0b342 DHW |
108 | |
109 | ||
110 | typedef struct { | |
111 | lang_statement_header_type header; | |
112 | } lang_common_statement_type; | |
113 | ||
114 | typedef struct { | |
115 | lang_statement_header_type header; | |
116 | } lang_object_symbols_statement_type; | |
117 | ||
118 | typedef struct { | |
119 | lang_statement_header_type header; | |
1418c83b | 120 | fill_type fill; |
2fa0b342 DHW |
121 | } lang_fill_statement_type; |
122 | ||
123 | typedef struct { | |
124 | lang_statement_header_type header; | |
125 | unsigned int type; | |
126 | union etree_union *exp; | |
127 | bfd_vma value; | |
128 | asection *output_section; | |
129 | bfd_vma output_vma; | |
130 | } lang_data_statement_type; | |
131 | ||
132 | ||
133 | ||
134 | ||
135 | typedef struct lang_input_statement_struct | |
136 | { | |
137 | lang_statement_header_type header; | |
138 | /* Name of this file. */ | |
1418c83b | 139 | CONST char *filename; |
2fa0b342 DHW |
140 | /* Name to use for the symbol giving address of text start */ |
141 | /* Usually the same as filename, but for a file spec'd with -l | |
142 | this is the -l switch itself rather than the filename. */ | |
1418c83b | 143 | CONST char *local_sym_name; |
c611e285 | 144 | |
2fa0b342 | 145 | bfd *the_bfd; |
c611e285 | 146 | |
2fa0b342 DHW |
147 | boolean closed; |
148 | file_ptr passive_position; | |
c611e285 | 149 | |
2fa0b342 DHW |
150 | /* Symbol table of the file. */ |
151 | asymbol **asymbols; | |
152 | unsigned int symbol_count; | |
c611e285 | 153 | |
2fa0b342 | 154 | /* For library members only */ |
c611e285 | 155 | |
2fa0b342 DHW |
156 | /* For a library, points to chain of entries for the library members. */ |
157 | struct lang_input_statement_struct *subfiles; | |
158 | /* For a library member, offset of the member within the archive. | |
159 | Zero for files that are not library members. */ | |
160 | /* int starting_offset;*/ | |
161 | /* Size of contents of this file, if library member. */ | |
c611e285 | 162 | bfd_size_type total_size; |
2fa0b342 DHW |
163 | /* For library member, points to the library's own entry. */ |
164 | struct lang_input_statement_struct *superfile; | |
165 | /* For library member, points to next entry for next member. */ | |
166 | struct lang_input_statement_struct *chain; | |
1418c83b SC |
167 | /* Point to the next file - whatever it is, wanders up and down |
168 | archives */ | |
c611e285 | 169 | |
2fa0b342 DHW |
170 | union lang_statement_union *next; |
171 | /* Point to the next file, but skips archive contents */ | |
172 | union lang_statement_union *next_real_file; | |
c611e285 | 173 | |
2fa0b342 | 174 | boolean is_archive; |
c611e285 | 175 | |
2fa0b342 DHW |
176 | /* 1 means search a set of directories for this file. */ |
177 | boolean search_dirs_flag; | |
c611e285 | 178 | |
2fa0b342 DHW |
179 | /* 1 means this is base file of incremental load. |
180 | Do not load this file's text or data. | |
181 | Also default text_start to after this file's bss. */ | |
c611e285 | 182 | |
2fa0b342 | 183 | boolean just_syms_flag; |
c611e285 | 184 | |
2fa0b342 | 185 | boolean loaded; |
c611e285 SC |
186 | |
187 | ||
2fa0b342 | 188 | /* unsigned int globals_in_this_file;*/ |
1418c83b | 189 | CONST char *target; |
2fa0b342 | 190 | boolean real; |
c611e285 | 191 | |
2fa0b342 DHW |
192 | asection *common_section; |
193 | asection *common_output_section; | |
194 | } lang_input_statement_type; | |
195 | ||
196 | typedef struct { | |
197 | lang_statement_header_type header; | |
198 | asection *section; | |
199 | lang_input_statement_type *ifile; | |
c611e285 | 200 | |
2fa0b342 DHW |
201 | } lang_input_section_type; |
202 | ||
203 | ||
204 | typedef struct { | |
205 | lang_statement_header_type header; | |
206 | asection *section; | |
207 | union lang_statement_union *file; | |
208 | } lang_afile_asection_pair_statement_type; | |
209 | ||
210 | typedef struct lang_wild_statement_struct { | |
211 | lang_statement_header_type header; | |
c611e285 SC |
212 | CONST char *section_name; |
213 | CONST char *filename; | |
2fa0b342 DHW |
214 | lang_statement_list_type children; |
215 | } lang_wild_statement_type; | |
216 | ||
217 | typedef struct lang_address_statement_struct { | |
218 | lang_statement_header_type header; | |
1418c83b | 219 | CONST char *section_name; |
2fa0b342 DHW |
220 | union etree_union *address; |
221 | } lang_address_statement_type; | |
222 | ||
223 | typedef struct { | |
224 | lang_statement_header_type header; | |
225 | bfd_vma output_offset; | |
226 | size_t size; | |
227 | asection *output_section; | |
228 | fill_type fill; | |
229 | } lang_padding_statement_type; | |
230 | ||
231 | typedef union lang_statement_union | |
c611e285 SC |
232 | { |
233 | lang_statement_header_type header; | |
234 | union lang_statement_union *next; | |
235 | lang_wild_statement_type wild_statement; | |
236 | lang_data_statement_type data_statement; | |
237 | lang_address_statement_type address_statement; | |
238 | lang_output_section_statement_type output_section_statement; | |
239 | lang_afile_asection_pair_statement_type afile_asection_pair_statement; | |
240 | lang_assignment_statement_type assignment_statement; | |
241 | lang_input_statement_type input_statement; | |
242 | lang_target_statement_type target_statement; | |
243 | lang_output_statement_type output_statement; | |
244 | lang_input_section_type input_section; | |
245 | lang_common_statement_type common_statement; | |
246 | lang_object_symbols_statement_type object_symbols_statement; | |
247 | lang_fill_statement_type fill_statement; | |
248 | lang_padding_statement_type padding_statement; | |
249 | } lang_statement_union_type; | |
2fa0b342 DHW |
250 | |
251 | ||
252 | ||
253 | PROTO(void,lang_init,(void)); | |
1418c83b SC |
254 | PROTO(struct memory_region_struct , |
255 | *lang_memory_region_lookup,(CONST | |
256 | char *CONST)); | |
2fa0b342 | 257 | |
1418c83b SC |
258 | |
259 | PROTO(void ,lang_map,(FILE *)); | |
c611e285 | 260 | PROTO(void,lang_set_flags,(int *, CONST char *)); |
1418c83b | 261 | PROTO(void,lang_add_output,(CONST char *)); |
2fa0b342 DHW |
262 | |
263 | PROTO(void,lang_final,(void)); | |
b6316534 | 264 | PROTO(struct symbol_cache_entry *,create_symbol,(CONST char *, unsigned int, struct sec *)); |
2fa0b342 | 265 | PROTO(void ,lang_process,(void)); |
1418c83b SC |
266 | PROTO(void ,lang_section_start,(CONST char *, union etree_union *)); |
267 | PROTO(void,lang_add_entry,(CONST char *)); | |
268 | PROTO(void,lang_add_target,(CONST char *)); | |
269 | PROTO(void,lang_add_wild,(CONST char *CONST , CONST char *CONST)); | |
270 | PROTO(void,lang_add_map,(CONST char *)); | |
2fa0b342 DHW |
271 | PROTO(void,lang_add_fill,(int)); |
272 | PROTO(void,lang_add_assignment,(union etree_union *)); | |
273 | PROTO(void,lang_add_attribute,(enum statement_enum)); | |
1418c83b | 274 | PROTO(void,lang_startup,(CONST char *)); |
c611e285 | 275 | PROTO(void,lang_float,(enum bfd_boolean)); |
1418c83b SC |
276 | PROTO(void,lang_leave_output_section_statement,(bfd_vma, CONST char *)); |
277 | PROTO(void,lang_abs_symbol_at_end_of,(CONST char *, CONST char *)); | |
278 | PROTO(void,lang_abs_symbol_at_beginning_of,(CONST char *, CONST char *)); | |
2fa0b342 DHW |
279 | PROTO(void,lang_statement_append,(struct statement_list *, union lang_statement_union *, union lang_statement_union **)); |
280 | PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *))); | |
281 | ||
c611e285 | 282 | |
2fa0b342 DHW |
283 | #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ |
284 | extern lang_statement_list_type file_chain; \ | |
285 | lang_input_statement_type *statement; \ | |
286 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
287 | statement != (lang_input_statement_type *)NULL; \ | |
288 | statement = (lang_input_statement_type *)statement->next)\ | |
c611e285 | 289 | |
2fa0b342 | 290 | #define LANG_FOR_EACH_INPUT_SECTION(statement, abfd, section, x) \ |
c611e285 SC |
291 | { extern lang_statement_list_type file_chain; \ |
292 | lang_input_statement_type *statement; \ | |
293 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
294 | statement != (lang_input_statement_type *)NULL; \ | |
295 | statement = (lang_input_statement_type *)statement->next)\ | |
296 | { \ | |
297 | asection *section; \ | |
298 | bfd *abfd = statement->the_bfd; \ | |
2fa0b342 DHW |
299 | for (section = abfd->sections; \ |
300 | section != (asection *)NULL; \ | |
301 | section = section->next) { \ | |
c611e285 SC |
302 | x; \ |
303 | } \ | |
304 | } \ | |
2fa0b342 DHW |
305 | } |
306 | ||
307 | #define LANG_FOR_EACH_OUTPUT_SECTION(section, x) \ | |
c611e285 SC |
308 | { extern bfd *output_bfd; \ |
309 | asection *section; \ | |
310 | for (section = output_bfd->sections; \ | |
311 | section != (asection *)NULL; \ | |
312 | section = section->next) \ | |
313 | { x; } \ | |
314 | } | |
315 | ||
2fa0b342 DHW |
316 | |
317 | PROTO(void, lang_process,(void)); | |
318 | PROTO(void, ldlang_add_file,(lang_input_statement_type *)); | |
319 | ||
1418c83b SC |
320 | PROTO(lang_output_section_statement_type |
321 | *,lang_output_section_find,(CONST char * CONST)); | |
2fa0b342 DHW |
322 | |
323 | PROTO(lang_input_statement_type *, | |
c611e285 SC |
324 | lang_add_input_file,(char *name, |
325 | lang_input_file_enum_type file_type, | |
326 | char *target)); | |
2fa0b342 | 327 | PROTO(lang_output_section_statement_type *, |
c611e285 | 328 | lang_output_section_statement_lookup,(CONST char * CONST name)); |
1418c83b SC |
329 | |
330 | PROTO(void, ldlang_add_undef,(CONST char *CONST name)); | |
a37cc0c0 | 331 | PROTO(void, lang_add_output_format,(CONST char *)); |
c611e285 SC |
332 | |
333 | ||
334 | void EXFUN(lang_list_init,( lang_statement_list_type*)); | |
335 | ||
336 | void EXFUN(lang_add_data,(int type, union etree_union *)); |