]>
Commit | Line | Data |
---|---|---|
fcf276c4 | 1 | /* ldlang.h - linker command language support |
943fbd5b | 2 | Copyright 1991, 1992, 1993, 1994, 1995 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 | |
943fbd5b | 18 | the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
2fa0b342 | 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, | |
943fbd5b KR |
71 | lang_group_statement_enum, |
72 | ||
c611e285 | 73 | lang_afile_asection_pair_statement_enum, |
fcf276c4 ILT |
74 | lang_constructors_statement_enum |
75 | } type; | |
76 | } lang_statement_header_type; | |
2fa0b342 DHW |
77 | |
78 | ||
79 | typedef struct | |
fcf276c4 ILT |
80 | { |
81 | lang_statement_header_type header; | |
82 | union etree_union *exp; | |
83 | } lang_assignment_statement_type; | |
2fa0b342 DHW |
84 | |
85 | ||
fcf276c4 ILT |
86 | typedef struct lang_target_statement_struct |
87 | { | |
2fa0b342 | 88 | lang_statement_header_type header; |
fcf276c4 | 89 | const char *target; |
2fa0b342 DHW |
90 | } lang_target_statement_type; |
91 | ||
92 | ||
fcf276c4 ILT |
93 | typedef struct lang_output_statement_struct |
94 | { | |
2fa0b342 | 95 | lang_statement_header_type header; |
fcf276c4 | 96 | const char *name; |
2fa0b342 DHW |
97 | } lang_output_statement_type; |
98 | ||
99 | ||
3c8deccc ILT |
100 | /* This structure holds a list of program headers describing segments |
101 | in which this section should be placed. */ | |
102 | ||
103 | struct lang_output_section_phdr_list | |
104 | { | |
105 | struct lang_output_section_phdr_list *next; | |
106 | const char *name; | |
107 | boolean used; | |
108 | }; | |
109 | ||
2fa0b342 | 110 | typedef struct lang_output_section_statement_struct |
fcf276c4 ILT |
111 | { |
112 | lang_statement_header_type header; | |
113 | union etree_union *addr_tree; | |
114 | lang_statement_list_type children; | |
115 | const char *memspec; | |
116 | union lang_statement_union *next; | |
117 | const char *name; | |
118 | ||
119 | boolean processed; | |
c611e285 | 120 | |
fcf276c4 ILT |
121 | asection *bfd_section; |
122 | int flags; /* Or together of all input sections */ | |
123 | int loadable; /* set from NOLOAD flag in script */ | |
124 | struct memory_region_struct *region; | |
125 | size_t block_value; | |
126 | fill_type fill; | |
127 | ||
128 | int subsection_alignment; /* alignment of components */ | |
129 | int section_alignment; /* alignment of start of section */ | |
130 | ||
3c8deccc ILT |
131 | union etree_union *load_base; |
132 | ||
133 | struct lang_output_section_phdr_list *phdrs; | |
fcf276c4 | 134 | } lang_output_section_statement_type; |
2fa0b342 DHW |
135 | |
136 | ||
fcf276c4 ILT |
137 | typedef struct |
138 | { | |
2fa0b342 DHW |
139 | lang_statement_header_type header; |
140 | } lang_common_statement_type; | |
141 | ||
fcf276c4 ILT |
142 | typedef struct |
143 | { | |
2fa0b342 DHW |
144 | lang_statement_header_type header; |
145 | } lang_object_symbols_statement_type; | |
146 | ||
fcf276c4 ILT |
147 | typedef struct |
148 | { | |
2fa0b342 | 149 | lang_statement_header_type header; |
1418c83b | 150 | fill_type fill; |
bfbdc80f SC |
151 | int size; |
152 | asection *output_section; | |
2fa0b342 DHW |
153 | } lang_fill_statement_type; |
154 | ||
fcf276c4 ILT |
155 | typedef struct |
156 | { | |
2fa0b342 DHW |
157 | lang_statement_header_type header; |
158 | unsigned int type; | |
159 | union etree_union *exp; | |
160 | bfd_vma value; | |
161 | asection *output_section; | |
162 | bfd_vma output_vma; | |
163 | } lang_data_statement_type; | |
164 | ||
60e8a534 | 165 | /* Generate a reloc in the output file. */ |
2fa0b342 | 166 | |
60e8a534 ILT |
167 | typedef struct |
168 | { | |
169 | lang_statement_header_type header; | |
170 | ||
171 | /* Reloc to generate. */ | |
172 | bfd_reloc_code_real_type reloc; | |
2fa0b342 | 173 | |
60e8a534 | 174 | /* Reloc howto structure. */ |
943fbd5b | 175 | reloc_howto_type *howto; |
60e8a534 ILT |
176 | |
177 | /* Section to generate reloc against. Exactly one of section and | |
178 | name must be NULL. */ | |
179 | asection *section; | |
180 | ||
181 | /* Name of symbol to generate reloc against. Exactly one of section | |
182 | and name must be NULL. */ | |
183 | const char *name; | |
184 | ||
185 | /* Expression for addend. */ | |
186 | union etree_union *addend_exp; | |
187 | ||
188 | /* Resolved addend. */ | |
189 | bfd_vma addend_value; | |
190 | ||
191 | /* Output section where reloc should be performed. */ | |
192 | asection *output_section; | |
193 | ||
194 | /* VMA within output section. */ | |
195 | bfd_vma output_vma; | |
196 | } lang_reloc_statement_type; | |
2fa0b342 DHW |
197 | |
198 | typedef struct lang_input_statement_struct | |
fcf276c4 ILT |
199 | { |
200 | lang_statement_header_type header; | |
201 | /* Name of this file. */ | |
202 | const char *filename; | |
203 | /* Name to use for the symbol giving address of text start */ | |
204 | /* Usually the same as filename, but for a file spec'd with -l | |
205 | this is the -l switch itself rather than the filename. */ | |
206 | const char *local_sym_name; | |
c611e285 | 207 | |
fcf276c4 | 208 | bfd *the_bfd; |
c611e285 | 209 | |
fcf276c4 ILT |
210 | boolean closed; |
211 | file_ptr passive_position; | |
c611e285 | 212 | |
fcf276c4 ILT |
213 | /* Symbol table of the file. */ |
214 | asymbol **asymbols; | |
215 | unsigned int symbol_count; | |
c611e285 | 216 | |
fcf276c4 ILT |
217 | /* Point to the next file - whatever it is, wanders up and down |
218 | archives */ | |
c611e285 | 219 | |
fcf276c4 ILT |
220 | union lang_statement_union *next; |
221 | /* Point to the next file, but skips archive contents */ | |
222 | union lang_statement_union *next_real_file; | |
c611e285 | 223 | |
fcf276c4 | 224 | boolean is_archive; |
c611e285 | 225 | |
fcf276c4 ILT |
226 | /* 1 means search a set of directories for this file. */ |
227 | boolean search_dirs_flag; | |
c611e285 | 228 | |
fcf276c4 ILT |
229 | /* 1 means this is base file of incremental load. |
230 | Do not load this file's text or data. | |
231 | Also default text_start to after this file's bss. */ | |
c611e285 | 232 | |
fcf276c4 | 233 | boolean just_syms_flag; |
3c8deccc ILT |
234 | |
235 | /* Whether to search for this entry as a dynamic archive. */ | |
236 | boolean dynamic; | |
237 | ||
238 | /* Whether to include the entire contents of an archive. */ | |
239 | boolean whole_archive; | |
240 | ||
fcf276c4 | 241 | boolean loaded; |
c611e285 | 242 | |
fcf276c4 ILT |
243 | /* unsigned int globals_in_this_file;*/ |
244 | const char *target; | |
245 | boolean real; | |
246 | asection *common_section; | |
247 | asection *common_output_section; | |
248 | boolean complained; | |
249 | } lang_input_statement_type; | |
250 | ||
251 | typedef struct | |
252 | { | |
2fa0b342 DHW |
253 | lang_statement_header_type header; |
254 | asection *section; | |
255 | lang_input_statement_type *ifile; | |
c611e285 | 256 | |
2fa0b342 DHW |
257 | } lang_input_section_type; |
258 | ||
259 | ||
fcf276c4 ILT |
260 | typedef struct |
261 | { | |
2fa0b342 DHW |
262 | lang_statement_header_type header; |
263 | asection *section; | |
264 | union lang_statement_union *file; | |
265 | } lang_afile_asection_pair_statement_type; | |
266 | ||
fcf276c4 ILT |
267 | typedef struct lang_wild_statement_struct |
268 | { | |
2fa0b342 | 269 | lang_statement_header_type header; |
fcf276c4 ILT |
270 | const char *section_name; |
271 | const char *filename; | |
2fa0b342 DHW |
272 | lang_statement_list_type children; |
273 | } lang_wild_statement_type; | |
274 | ||
fcf276c4 ILT |
275 | typedef struct lang_address_statement_struct |
276 | { | |
2fa0b342 | 277 | lang_statement_header_type header; |
fcf276c4 | 278 | const char *section_name; |
2fa0b342 DHW |
279 | union etree_union *address; |
280 | } lang_address_statement_type; | |
281 | ||
fcf276c4 ILT |
282 | typedef struct |
283 | { | |
2fa0b342 DHW |
284 | lang_statement_header_type header; |
285 | bfd_vma output_offset; | |
286 | size_t size; | |
287 | asection *output_section; | |
288 | fill_type fill; | |
289 | } lang_padding_statement_type; | |
290 | ||
943fbd5b KR |
291 | /* A group statement collects a set of libraries together. The |
292 | libraries are searched multiple times, until no new undefined | |
293 | symbols are found. The effect is to search a group of libraries as | |
294 | though they were a single library. */ | |
295 | ||
296 | typedef struct | |
297 | { | |
298 | lang_statement_header_type header; | |
299 | lang_statement_list_type children; | |
300 | } lang_group_statement_type; | |
301 | ||
2fa0b342 | 302 | typedef union lang_statement_union |
fcf276c4 ILT |
303 | { |
304 | lang_statement_header_type header; | |
305 | union lang_statement_union *next; | |
306 | lang_wild_statement_type wild_statement; | |
307 | lang_data_statement_type data_statement; | |
60e8a534 | 308 | lang_reloc_statement_type reloc_statement; |
fcf276c4 ILT |
309 | lang_address_statement_type address_statement; |
310 | lang_output_section_statement_type output_section_statement; | |
311 | lang_afile_asection_pair_statement_type afile_asection_pair_statement; | |
312 | lang_assignment_statement_type assignment_statement; | |
313 | lang_input_statement_type input_statement; | |
314 | lang_target_statement_type target_statement; | |
315 | lang_output_statement_type output_statement; | |
316 | lang_input_section_type input_section; | |
317 | lang_common_statement_type common_statement; | |
318 | lang_object_symbols_statement_type object_symbols_statement; | |
319 | lang_fill_statement_type fill_statement; | |
320 | lang_padding_statement_type padding_statement; | |
943fbd5b | 321 | lang_group_statement_type group_statement; |
fcf276c4 ILT |
322 | } lang_statement_union_type; |
323 | ||
3c8deccc ILT |
324 | /* This structure holds information about a program header, from the |
325 | PHDRS command in the linker script. */ | |
326 | ||
327 | struct lang_phdr | |
328 | { | |
329 | struct lang_phdr *next; | |
330 | const char *name; | |
331 | unsigned long type; | |
332 | boolean filehdr; | |
333 | boolean phdrs; | |
334 | etree_type *at; | |
335 | etree_type *flags; | |
336 | }; | |
337 | ||
fcf276c4 | 338 | extern lang_output_section_statement_type *abs_output_section; |
fcf276c4 | 339 | extern boolean lang_has_input_file; |
fcf276c4 ILT |
340 | extern etree_type *base; |
341 | extern lang_statement_list_type *stat_ptr; | |
342 | extern boolean delete_output_file_on_failure; | |
fcf276c4 | 343 | |
3c8deccc ILT |
344 | extern const char *entry_symbol; |
345 | extern boolean entry_from_cmdline; | |
346 | ||
fcf276c4 ILT |
347 | extern void lang_init PARAMS ((void)); |
348 | extern struct memory_region_struct *lang_memory_region_lookup | |
349 | PARAMS ((const char *const)); | |
350 | extern void lang_map PARAMS ((void)); | |
351 | extern void lang_set_flags PARAMS ((int *, const char *)); | |
352 | extern void lang_add_output PARAMS ((const char *, int from_script)); | |
353 | extern void lang_enter_output_section_statement | |
354 | PARAMS ((const char *output_section_statement_name, | |
355 | etree_type * address_exp, | |
356 | int flags, | |
357 | bfd_vma block_value, | |
358 | etree_type *align, | |
359 | etree_type *subalign, | |
755f42fe | 360 | etree_type *)); |
fcf276c4 | 361 | extern void lang_final PARAMS ((void)); |
fcf276c4 ILT |
362 | extern void lang_process PARAMS ((void)); |
363 | extern void lang_section_start PARAMS ((const char *, union etree_union *)); | |
3c8deccc | 364 | extern void lang_add_entry PARAMS ((const char *, boolean)); |
fcf276c4 ILT |
365 | extern void lang_add_target PARAMS ((const char *)); |
366 | extern void lang_add_wild PARAMS ((const char *const , const char *const)); | |
367 | extern void lang_add_map PARAMS ((const char *)); | |
368 | extern void lang_add_fill PARAMS ((int)); | |
369 | extern void lang_add_assignment PARAMS ((union etree_union *)); | |
370 | extern void lang_add_attribute PARAMS ((enum statement_enum)); | |
371 | extern void lang_startup PARAMS ((const char *)); | |
372 | extern void lang_float PARAMS ((enum bfd_boolean)); | |
373 | extern void lang_leave_output_section_statement PARAMS ((bfd_vma, | |
374 | const char *)); | |
375 | extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *)); | |
376 | extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *, | |
377 | const char *)); | |
378 | extern void lang_statement_append PARAMS ((struct statement_list *, | |
379 | union lang_statement_union *, | |
380 | union lang_statement_union **)); | |
943fbd5b KR |
381 | extern void lang_for_each_input_file |
382 | PARAMS ((void (*dothis) (lang_input_statement_type *))); | |
fcf276c4 ILT |
383 | extern void lang_for_each_file |
384 | PARAMS ((void (*dothis) (lang_input_statement_type *))); | |
943fbd5b KR |
385 | extern bfd_vma lang_do_assignments |
386 | PARAMS ((lang_statement_union_type * s, | |
387 | lang_output_section_statement_type *output_section_statement, | |
388 | fill_type fill, | |
389 | bfd_vma dot)); | |
fcf276c4 ILT |
390 | |
391 | #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ | |
2fa0b342 DHW |
392 | extern lang_statement_list_type file_chain; \ |
393 | lang_input_statement_type *statement; \ | |
394 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
395 | statement != (lang_input_statement_type *)NULL; \ | |
396 | statement = (lang_input_statement_type *)statement->next)\ | |
c611e285 | 397 | |
fcf276c4 ILT |
398 | extern void lang_process PARAMS ((void)); |
399 | extern void ldlang_add_file PARAMS ((lang_input_statement_type *)); | |
400 | extern lang_output_section_statement_type *lang_output_section_find | |
401 | PARAMS ((const char * const)); | |
402 | extern lang_input_statement_type *lang_add_input_file | |
403 | PARAMS ((const char *name, lang_input_file_enum_type file_type, | |
404 | const char *target)); | |
405 | extern void lang_add_keepsyms_file PARAMS ((const char *filename)); | |
406 | extern lang_output_section_statement_type * | |
407 | lang_output_section_statement_lookup PARAMS ((const char * const name)); | |
408 | extern void ldlang_add_undef PARAMS ((const char *const name)); | |
943fbd5b KR |
409 | extern void lang_add_output_format PARAMS ((const char *, const char *, |
410 | const char *, int from_script)); | |
fcf276c4 ILT |
411 | extern void lang_list_init PARAMS ((lang_statement_list_type*)); |
412 | extern void lang_add_data PARAMS ((int type, union etree_union *)); | |
60e8a534 | 413 | extern void lang_add_reloc |
943fbd5b | 414 | PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto, |
60e8a534 | 415 | asection *section, const char *name, union etree_union *addend)); |
755f42fe ILT |
416 | extern void lang_for_each_statement |
417 | PARAMS ((void (*func) (lang_statement_union_type *))); | |
fcf276c4 | 418 | extern PTR stat_alloc PARAMS ((size_t size)); |
60e8a534 ILT |
419 | extern bfd_vma lang_size_sections |
420 | PARAMS ((lang_statement_union_type *s, | |
421 | lang_output_section_statement_type *output_section_statement, | |
422 | lang_statement_union_type **prev, fill_type fill, | |
423 | bfd_vma dot, boolean relax)); | |
943fbd5b KR |
424 | extern void lang_enter_group PARAMS ((void)); |
425 | extern void lang_leave_group PARAMS ((void)); | |
426 | extern void wild_doit | |
427 | PARAMS ((lang_statement_list_type *ptr, asection *section, | |
428 | lang_output_section_statement_type *output, | |
429 | lang_input_statement_type *file)); | |
3c8deccc ILT |
430 | extern void lang_new_phdr |
431 | PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *, | |
432 | etree_type *)); | |
433 | extern void lang_section_in_phdr PARAMS ((const char *)); | |
fcf276c4 ILT |
434 | |
435 | #endif |