]>
Commit | Line | Data |
---|---|---|
fcf276c4 ILT |
1 | /* ldlang.h - linker command language support |
2 | Copyright 1991, 1992, 1993 Free Software Foundation, Inc. | |
c611e285 | 3 | |
2fa0b342 | 4 | This file is part of GLD, the Gnu Linker. |
c611e285 | 5 | |
2fa0b342 DHW |
6 | GLD 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 1, or (at your option) | |
9 | any later version. | |
c611e285 | 10 | |
2fa0b342 DHW |
11 | GLD 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. | |
c611e285 | 15 | |
2fa0b342 DHW |
16 | You should have received a copy of the GNU General Public License |
17 | along with GLD; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
fcf276c4 ILT |
20 | #ifndef LDLANG_H |
21 | #define LDLANG_H | |
2fa0b342 | 22 | |
fcf276c4 ILT |
23 | typedef enum |
24 | { | |
2fa0b342 DHW |
25 | lang_input_file_is_l_enum, |
26 | lang_input_file_is_symbols_only_enum, | |
27 | lang_input_file_is_marker_enum, | |
28 | lang_input_file_is_fake_enum, | |
c611e285 | 29 | lang_input_file_is_search_file_enum, |
fcf276c4 ILT |
30 | lang_input_file_is_file_enum |
31 | } lang_input_file_enum_type; | |
2fa0b342 | 32 | |
755f42fe | 33 | typedef unsigned int fill_type; |
fcf276c4 ILT |
34 | typedef struct statement_list |
35 | { | |
2fa0b342 DHW |
36 | union lang_statement_union *head; |
37 | union lang_statement_union **tail; | |
38 | } lang_statement_list_type; | |
39 | ||
40 | ||
fcf276c4 ILT |
41 | typedef struct memory_region_struct |
42 | { | |
2fa0b342 DHW |
43 | char *name; |
44 | struct memory_region_struct *next; | |
45 | bfd_vma origin; | |
fcf276c4 | 46 | bfd_size_type length; |
2fa0b342 | 47 | bfd_vma current; |
fcf276c4 | 48 | bfd_size_type old_length; |
c611e285 | 49 | int flags; |
1bd1fa2d | 50 | boolean had_full_message; |
2fa0b342 DHW |
51 | } lang_memory_region_type ; |
52 | ||
53 | typedef struct lang_statement_header_struct | |
fcf276c4 ILT |
54 | { |
55 | union lang_statement_union *next; | |
56 | enum statement_enum | |
57 | { | |
c611e285 SC |
58 | lang_output_section_statement_enum, |
59 | lang_assignment_statement_enum, | |
60 | lang_input_statement_enum, | |
61 | lang_address_statement_enum, | |
62 | lang_wild_statement_enum, | |
63 | lang_input_section_enum, | |
64 | lang_object_symbols_statement_enum, | |
65 | lang_fill_statement_enum, | |
66 | lang_data_statement_enum, | |
60e8a534 | 67 | lang_reloc_statement_enum, |
c611e285 SC |
68 | lang_target_statement_enum, |
69 | lang_output_statement_enum, | |
70 | lang_padding_statement_enum, | |
71 | ||
72 | lang_afile_asection_pair_statement_enum, | |
fcf276c4 ILT |
73 | lang_constructors_statement_enum |
74 | } type; | |
75 | } lang_statement_header_type; | |
2fa0b342 DHW |
76 | |
77 | ||
78 | typedef struct | |
fcf276c4 ILT |
79 | { |
80 | lang_statement_header_type header; | |
81 | union etree_union *exp; | |
82 | } lang_assignment_statement_type; | |
2fa0b342 DHW |
83 | |
84 | ||
fcf276c4 ILT |
85 | typedef struct lang_target_statement_struct |
86 | { | |
2fa0b342 | 87 | lang_statement_header_type header; |
fcf276c4 | 88 | const char *target; |
2fa0b342 DHW |
89 | } lang_target_statement_type; |
90 | ||
91 | ||
fcf276c4 ILT |
92 | typedef struct lang_output_statement_struct |
93 | { | |
2fa0b342 | 94 | lang_statement_header_type header; |
fcf276c4 | 95 | const char *name; |
2fa0b342 DHW |
96 | } lang_output_statement_type; |
97 | ||
98 | ||
99 | typedef struct lang_output_section_statement_struct | |
fcf276c4 ILT |
100 | { |
101 | lang_statement_header_type header; | |
102 | union etree_union *addr_tree; | |
103 | lang_statement_list_type children; | |
104 | const char *memspec; | |
105 | union lang_statement_union *next; | |
106 | const char *name; | |
107 | ||
108 | boolean processed; | |
c611e285 | 109 | |
fcf276c4 ILT |
110 | asection *bfd_section; |
111 | int flags; /* Or together of all input sections */ | |
112 | int loadable; /* set from NOLOAD flag in script */ | |
113 | struct memory_region_struct *region; | |
114 | size_t block_value; | |
115 | fill_type fill; | |
116 | ||
117 | int subsection_alignment; /* alignment of components */ | |
118 | int section_alignment; /* alignment of start of section */ | |
119 | ||
120 | union etree_union *load_base; | |
121 | } lang_output_section_statement_type; | |
2fa0b342 DHW |
122 | |
123 | ||
fcf276c4 ILT |
124 | typedef struct |
125 | { | |
2fa0b342 DHW |
126 | lang_statement_header_type header; |
127 | } lang_common_statement_type; | |
128 | ||
fcf276c4 ILT |
129 | typedef struct |
130 | { | |
2fa0b342 DHW |
131 | lang_statement_header_type header; |
132 | } lang_object_symbols_statement_type; | |
133 | ||
fcf276c4 ILT |
134 | typedef struct |
135 | { | |
2fa0b342 | 136 | lang_statement_header_type header; |
1418c83b | 137 | fill_type fill; |
bfbdc80f SC |
138 | int size; |
139 | asection *output_section; | |
2fa0b342 DHW |
140 | } lang_fill_statement_type; |
141 | ||
fcf276c4 ILT |
142 | typedef struct |
143 | { | |
2fa0b342 DHW |
144 | lang_statement_header_type header; |
145 | unsigned int type; | |
146 | union etree_union *exp; | |
147 | bfd_vma value; | |
148 | asection *output_section; | |
149 | bfd_vma output_vma; | |
150 | } lang_data_statement_type; | |
151 | ||
60e8a534 | 152 | /* Generate a reloc in the output file. */ |
2fa0b342 | 153 | |
60e8a534 ILT |
154 | typedef struct |
155 | { | |
156 | lang_statement_header_type header; | |
157 | ||
158 | /* Reloc to generate. */ | |
159 | bfd_reloc_code_real_type reloc; | |
2fa0b342 | 160 | |
60e8a534 ILT |
161 | /* Reloc howto structure. */ |
162 | const reloc_howto_type *howto; | |
163 | ||
164 | /* Section to generate reloc against. Exactly one of section and | |
165 | name must be NULL. */ | |
166 | asection *section; | |
167 | ||
168 | /* Name of symbol to generate reloc against. Exactly one of section | |
169 | and name must be NULL. */ | |
170 | const char *name; | |
171 | ||
172 | /* Expression for addend. */ | |
173 | union etree_union *addend_exp; | |
174 | ||
175 | /* Resolved addend. */ | |
176 | bfd_vma addend_value; | |
177 | ||
178 | /* Output section where reloc should be performed. */ | |
179 | asection *output_section; | |
180 | ||
181 | /* VMA within output section. */ | |
182 | bfd_vma output_vma; | |
183 | } lang_reloc_statement_type; | |
2fa0b342 DHW |
184 | |
185 | typedef struct lang_input_statement_struct | |
fcf276c4 ILT |
186 | { |
187 | lang_statement_header_type header; | |
188 | /* Name of this file. */ | |
189 | const char *filename; | |
190 | /* Name to use for the symbol giving address of text start */ | |
191 | /* Usually the same as filename, but for a file spec'd with -l | |
192 | this is the -l switch itself rather than the filename. */ | |
193 | const char *local_sym_name; | |
c611e285 | 194 | |
fcf276c4 | 195 | bfd *the_bfd; |
c611e285 | 196 | |
fcf276c4 ILT |
197 | boolean closed; |
198 | file_ptr passive_position; | |
c611e285 | 199 | |
fcf276c4 ILT |
200 | /* Symbol table of the file. */ |
201 | asymbol **asymbols; | |
202 | unsigned int symbol_count; | |
c611e285 | 203 | |
fcf276c4 ILT |
204 | /* Point to the next file - whatever it is, wanders up and down |
205 | archives */ | |
c611e285 | 206 | |
fcf276c4 ILT |
207 | union lang_statement_union *next; |
208 | /* Point to the next file, but skips archive contents */ | |
209 | union lang_statement_union *next_real_file; | |
c611e285 | 210 | |
fcf276c4 | 211 | boolean is_archive; |
c611e285 | 212 | |
fcf276c4 ILT |
213 | /* 1 means search a set of directories for this file. */ |
214 | boolean search_dirs_flag; | |
c611e285 | 215 | |
fcf276c4 ILT |
216 | /* 1 means this is base file of incremental load. |
217 | Do not load this file's text or data. | |
218 | Also default text_start to after this file's bss. */ | |
c611e285 | 219 | |
fcf276c4 | 220 | boolean just_syms_flag; |
c611e285 | 221 | |
fcf276c4 | 222 | boolean loaded; |
c611e285 | 223 | |
c611e285 | 224 | |
fcf276c4 ILT |
225 | /* unsigned int globals_in_this_file;*/ |
226 | const char *target; | |
227 | boolean real; | |
228 | asection *common_section; | |
229 | asection *common_output_section; | |
230 | boolean complained; | |
231 | } lang_input_statement_type; | |
232 | ||
233 | typedef struct | |
234 | { | |
2fa0b342 DHW |
235 | lang_statement_header_type header; |
236 | asection *section; | |
237 | lang_input_statement_type *ifile; | |
c611e285 | 238 | |
2fa0b342 DHW |
239 | } lang_input_section_type; |
240 | ||
241 | ||
fcf276c4 ILT |
242 | typedef struct |
243 | { | |
2fa0b342 DHW |
244 | lang_statement_header_type header; |
245 | asection *section; | |
246 | union lang_statement_union *file; | |
247 | } lang_afile_asection_pair_statement_type; | |
248 | ||
fcf276c4 ILT |
249 | typedef struct lang_wild_statement_struct |
250 | { | |
2fa0b342 | 251 | lang_statement_header_type header; |
fcf276c4 ILT |
252 | const char *section_name; |
253 | const char *filename; | |
2fa0b342 DHW |
254 | lang_statement_list_type children; |
255 | } lang_wild_statement_type; | |
256 | ||
fcf276c4 ILT |
257 | typedef struct lang_address_statement_struct |
258 | { | |
2fa0b342 | 259 | lang_statement_header_type header; |
fcf276c4 | 260 | const char *section_name; |
2fa0b342 DHW |
261 | union etree_union *address; |
262 | } lang_address_statement_type; | |
263 | ||
fcf276c4 ILT |
264 | typedef struct |
265 | { | |
2fa0b342 DHW |
266 | lang_statement_header_type header; |
267 | bfd_vma output_offset; | |
268 | size_t size; | |
269 | asection *output_section; | |
270 | fill_type fill; | |
271 | } lang_padding_statement_type; | |
272 | ||
273 | typedef union lang_statement_union | |
fcf276c4 ILT |
274 | { |
275 | lang_statement_header_type header; | |
276 | union lang_statement_union *next; | |
277 | lang_wild_statement_type wild_statement; | |
278 | lang_data_statement_type data_statement; | |
60e8a534 | 279 | lang_reloc_statement_type reloc_statement; |
fcf276c4 ILT |
280 | lang_address_statement_type address_statement; |
281 | lang_output_section_statement_type output_section_statement; | |
282 | lang_afile_asection_pair_statement_type afile_asection_pair_statement; | |
283 | lang_assignment_statement_type assignment_statement; | |
284 | lang_input_statement_type input_statement; | |
285 | lang_target_statement_type target_statement; | |
286 | lang_output_statement_type output_statement; | |
287 | lang_input_section_type input_section; | |
288 | lang_common_statement_type common_statement; | |
289 | lang_object_symbols_statement_type object_symbols_statement; | |
290 | lang_fill_statement_type fill_statement; | |
291 | lang_padding_statement_type padding_statement; | |
292 | } lang_statement_union_type; | |
293 | ||
fcf276c4 | 294 | extern lang_output_section_statement_type *abs_output_section; |
fcf276c4 | 295 | extern boolean lang_has_input_file; |
fcf276c4 ILT |
296 | extern etree_type *base; |
297 | extern lang_statement_list_type *stat_ptr; | |
298 | extern boolean delete_output_file_on_failure; | |
fcf276c4 ILT |
299 | |
300 | extern void lang_init PARAMS ((void)); | |
301 | extern struct memory_region_struct *lang_memory_region_lookup | |
302 | PARAMS ((const char *const)); | |
303 | extern void lang_map PARAMS ((void)); | |
304 | extern void lang_set_flags PARAMS ((int *, const char *)); | |
305 | extern void lang_add_output PARAMS ((const char *, int from_script)); | |
306 | extern void lang_enter_output_section_statement | |
307 | PARAMS ((const char *output_section_statement_name, | |
308 | etree_type * address_exp, | |
309 | int flags, | |
310 | bfd_vma block_value, | |
311 | etree_type *align, | |
312 | etree_type *subalign, | |
755f42fe | 313 | etree_type *)); |
fcf276c4 | 314 | extern void lang_final PARAMS ((void)); |
fcf276c4 ILT |
315 | extern void lang_process PARAMS ((void)); |
316 | extern void lang_section_start PARAMS ((const char *, union etree_union *)); | |
60e8a534 | 317 | extern void lang_add_entry PARAMS ((const char *, int)); |
fcf276c4 ILT |
318 | extern void lang_add_target PARAMS ((const char *)); |
319 | extern void lang_add_wild PARAMS ((const char *const , const char *const)); | |
320 | extern void lang_add_map PARAMS ((const char *)); | |
321 | extern void lang_add_fill PARAMS ((int)); | |
322 | extern void lang_add_assignment PARAMS ((union etree_union *)); | |
323 | extern void lang_add_attribute PARAMS ((enum statement_enum)); | |
324 | extern void lang_startup PARAMS ((const char *)); | |
325 | extern void lang_float PARAMS ((enum bfd_boolean)); | |
326 | extern void lang_leave_output_section_statement PARAMS ((bfd_vma, | |
327 | const char *)); | |
328 | extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *)); | |
329 | extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *, | |
330 | const char *)); | |
331 | extern void lang_statement_append PARAMS ((struct statement_list *, | |
332 | union lang_statement_union *, | |
333 | union lang_statement_union **)); | |
334 | extern void lang_for_each_file | |
335 | PARAMS ((void (*dothis) (lang_input_statement_type *))); | |
336 | ||
337 | #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ | |
2fa0b342 DHW |
338 | extern lang_statement_list_type file_chain; \ |
339 | lang_input_statement_type *statement; \ | |
340 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
341 | statement != (lang_input_statement_type *)NULL; \ | |
342 | statement = (lang_input_statement_type *)statement->next)\ | |
c611e285 | 343 | |
fcf276c4 ILT |
344 | extern void lang_process PARAMS ((void)); |
345 | extern void ldlang_add_file PARAMS ((lang_input_statement_type *)); | |
346 | extern lang_output_section_statement_type *lang_output_section_find | |
347 | PARAMS ((const char * const)); | |
348 | extern lang_input_statement_type *lang_add_input_file | |
349 | PARAMS ((const char *name, lang_input_file_enum_type file_type, | |
350 | const char *target)); | |
351 | extern void lang_add_keepsyms_file PARAMS ((const char *filename)); | |
352 | extern lang_output_section_statement_type * | |
353 | lang_output_section_statement_lookup PARAMS ((const char * const name)); | |
354 | extern void ldlang_add_undef PARAMS ((const char *const name)); | |
355 | extern void lang_add_output_format PARAMS ((const char *, int from_script)); | |
356 | extern void lang_list_init PARAMS ((lang_statement_list_type*)); | |
357 | extern void lang_add_data PARAMS ((int type, union etree_union *)); | |
60e8a534 ILT |
358 | extern void lang_add_reloc |
359 | PARAMS ((bfd_reloc_code_real_type reloc, const reloc_howto_type *howto, | |
360 | asection *section, const char *name, union etree_union *addend)); | |
755f42fe ILT |
361 | extern void lang_for_each_statement |
362 | PARAMS ((void (*func) (lang_statement_union_type *))); | |
fcf276c4 | 363 | extern PTR stat_alloc PARAMS ((size_t size)); |
60e8a534 ILT |
364 | extern bfd_vma lang_size_sections |
365 | PARAMS ((lang_statement_union_type *s, | |
366 | lang_output_section_statement_type *output_section_statement, | |
367 | lang_statement_union_type **prev, fill_type fill, | |
368 | bfd_vma dot, boolean relax)); | |
fcf276c4 ILT |
369 | |
370 | #endif |