]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* ldlang.h - linker command language support |
a2b64bed NC |
2 | Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
3 | 2001 | |
aa8804e4 | 4 | Free Software Foundation, Inc. |
5cc18311 | 5 | |
252b5132 | 6 | This file is part of GLD, the Gnu Linker. |
5cc18311 | 7 | |
252b5132 RH |
8 | GLD is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 1, or (at your option) | |
11 | any later version. | |
5cc18311 | 12 | |
252b5132 RH |
13 | GLD is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
5cc18311 | 17 | |
252b5132 RH |
18 | You should have received a copy of the GNU General Public License |
19 | along with GLD; see the file COPYING. If not, write to the Free | |
20 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
21 | 02111-1307, USA. */ | |
22 | ||
23 | #ifndef LDLANG_H | |
24 | #define LDLANG_H | |
25 | ||
89cdebba | 26 | typedef enum { |
252b5132 RH |
27 | lang_input_file_is_l_enum, |
28 | lang_input_file_is_symbols_only_enum, | |
29 | lang_input_file_is_marker_enum, | |
30 | lang_input_file_is_fake_enum, | |
31 | lang_input_file_is_search_file_enum, | |
32 | lang_input_file_is_file_enum | |
33 | } lang_input_file_enum_type; | |
34 | ||
35 | typedef unsigned int fill_type; | |
89cdebba KH |
36 | |
37 | typedef struct statement_list { | |
252b5132 RH |
38 | union lang_statement_union *head; |
39 | union lang_statement_union **tail; | |
40 | } lang_statement_list_type; | |
41 | ||
89cdebba | 42 | typedef struct memory_region_struct { |
252b5132 RH |
43 | char *name; |
44 | struct memory_region_struct *next; | |
45 | bfd_vma origin; | |
46 | bfd_size_type length; | |
47 | bfd_vma current; | |
48 | bfd_size_type old_length; | |
49 | flagword flags; | |
50 | flagword not_flags; | |
51 | boolean had_full_message; | |
89cdebba KH |
52 | } lang_memory_region_type; |
53 | ||
54 | typedef struct lang_statement_header_struct { | |
55 | union lang_statement_union *next; | |
56 | enum statement_enum { | |
57 | lang_output_section_statement_enum, | |
58 | lang_assignment_statement_enum, | |
59 | lang_input_statement_enum, | |
60 | lang_address_statement_enum, | |
61 | lang_wild_statement_enum, | |
62 | lang_input_section_enum, | |
63 | lang_object_symbols_statement_enum, | |
64 | lang_fill_statement_enum, | |
65 | lang_data_statement_enum, | |
66 | lang_reloc_statement_enum, | |
67 | lang_target_statement_enum, | |
68 | lang_output_statement_enum, | |
69 | lang_padding_statement_enum, | |
70 | lang_group_statement_enum, | |
71 | ||
72 | lang_afile_asection_pair_statement_enum, | |
73 | lang_constructors_statement_enum | |
74 | } type; | |
252b5132 RH |
75 | } lang_statement_header_type; |
76 | ||
89cdebba | 77 | typedef struct { |
252b5132 RH |
78 | lang_statement_header_type header; |
79 | union etree_union *exp; | |
80 | } lang_assignment_statement_type; | |
81 | ||
89cdebba | 82 | typedef struct lang_target_statement_struct { |
252b5132 RH |
83 | lang_statement_header_type header; |
84 | const char *target; | |
85 | } lang_target_statement_type; | |
86 | ||
89cdebba | 87 | typedef struct lang_output_statement_struct { |
252b5132 RH |
88 | lang_statement_header_type header; |
89 | const char *name; | |
90 | } lang_output_statement_type; | |
91 | ||
92 | /* Section types specified in a linker script. */ | |
93 | ||
89cdebba | 94 | enum section_type { |
252b5132 RH |
95 | normal_section, |
96 | dsect_section, | |
97 | copy_section, | |
98 | noload_section, | |
99 | info_section, | |
100 | overlay_section | |
101 | }; | |
102 | ||
103 | /* This structure holds a list of program headers describing segments | |
104 | in which this section should be placed. */ | |
105 | ||
89cdebba | 106 | struct lang_output_section_phdr_list { |
252b5132 RH |
107 | struct lang_output_section_phdr_list *next; |
108 | const char *name; | |
109 | boolean used; | |
110 | }; | |
111 | ||
89cdebba | 112 | typedef struct lang_output_section_statement_struct { |
252b5132 RH |
113 | lang_statement_header_type header; |
114 | union etree_union *addr_tree; | |
115 | lang_statement_list_type children; | |
116 | const char *memspec; | |
117 | union lang_statement_union *next; | |
118 | const char *name; | |
119 | ||
120 | boolean processed; | |
5cc18311 | 121 | |
252b5132 RH |
122 | asection *bfd_section; |
123 | flagword flags; /* Or together of all input sections */ | |
124 | enum section_type sectype; | |
125 | struct memory_region_struct *region; | |
562d3460 | 126 | struct memory_region_struct *lma_region; |
252b5132 RH |
127 | size_t block_value; |
128 | fill_type fill; | |
129 | ||
89cdebba KH |
130 | int subsection_alignment; /* alignment of components */ |
131 | int section_alignment; /* alignment of start of section */ | |
252b5132 RH |
132 | |
133 | union etree_union *load_base; | |
134 | ||
135 | struct lang_output_section_phdr_list *phdrs; | |
136 | } lang_output_section_statement_type; | |
137 | ||
89cdebba | 138 | typedef struct { |
252b5132 RH |
139 | lang_statement_header_type header; |
140 | } lang_common_statement_type; | |
141 | ||
89cdebba | 142 | typedef struct { |
252b5132 RH |
143 | lang_statement_header_type header; |
144 | } lang_object_symbols_statement_type; | |
145 | ||
89cdebba | 146 | typedef struct { |
252b5132 RH |
147 | lang_statement_header_type header; |
148 | fill_type fill; | |
149 | int size; | |
150 | asection *output_section; | |
151 | } lang_fill_statement_type; | |
152 | ||
89cdebba | 153 | typedef struct { |
252b5132 RH |
154 | lang_statement_header_type header; |
155 | unsigned int type; | |
89cdebba | 156 | union etree_union *exp; |
252b5132 RH |
157 | bfd_vma value; |
158 | asection *output_section; | |
159 | bfd_vma output_vma; | |
160 | } lang_data_statement_type; | |
161 | ||
162 | /* Generate a reloc in the output file. */ | |
163 | ||
89cdebba | 164 | typedef struct { |
252b5132 RH |
165 | lang_statement_header_type header; |
166 | ||
167 | /* Reloc to generate. */ | |
168 | bfd_reloc_code_real_type reloc; | |
169 | ||
170 | /* Reloc howto structure. */ | |
171 | reloc_howto_type *howto; | |
172 | ||
173 | /* Section to generate reloc against. Exactly one of section and | |
174 | name must be NULL. */ | |
175 | asection *section; | |
176 | ||
177 | /* Name of symbol to generate reloc against. Exactly one of section | |
178 | and name must be NULL. */ | |
179 | const char *name; | |
180 | ||
181 | /* Expression for addend. */ | |
182 | union etree_union *addend_exp; | |
183 | ||
184 | /* Resolved addend. */ | |
185 | bfd_vma addend_value; | |
186 | ||
187 | /* Output section where reloc should be performed. */ | |
188 | asection *output_section; | |
189 | ||
190 | /* VMA within output section. */ | |
191 | bfd_vma output_vma; | |
192 | } lang_reloc_statement_type; | |
193 | ||
89cdebba | 194 | typedef struct lang_input_statement_struct { |
252b5132 RH |
195 | lang_statement_header_type header; |
196 | /* Name of this file. */ | |
197 | const char *filename; | |
198 | /* Name to use for the symbol giving address of text start */ | |
199 | /* Usually the same as filename, but for a file spec'd with -l | |
200 | this is the -l switch itself rather than the filename. */ | |
201 | const char *local_sym_name; | |
5cc18311 | 202 | |
252b5132 | 203 | bfd *the_bfd; |
5cc18311 | 204 | |
252b5132 RH |
205 | boolean closed; |
206 | file_ptr passive_position; | |
5cc18311 | 207 | |
252b5132 RH |
208 | /* Symbol table of the file. */ |
209 | asymbol **asymbols; | |
210 | unsigned int symbol_count; | |
5cc18311 | 211 | |
252b5132 RH |
212 | /* Point to the next file - whatever it is, wanders up and down |
213 | archives */ | |
5cc18311 | 214 | |
89cdebba | 215 | union lang_statement_union *next; |
252b5132 | 216 | /* Point to the next file, but skips archive contents */ |
89cdebba | 217 | union lang_statement_union *next_real_file; |
5cc18311 | 218 | |
252b5132 | 219 | boolean is_archive; |
5cc18311 | 220 | |
252b5132 RH |
221 | /* 1 means search a set of directories for this file. */ |
222 | boolean search_dirs_flag; | |
5cc18311 | 223 | |
252b5132 RH |
224 | /* 1 means this is base file of incremental load. |
225 | Do not load this file's text or data. | |
5cc18311 KH |
226 | Also default text_start to after this file's bss. */ |
227 | ||
252b5132 RH |
228 | boolean just_syms_flag; |
229 | ||
230 | /* Whether to search for this entry as a dynamic archive. */ | |
231 | boolean dynamic; | |
232 | ||
233 | /* Whether to include the entire contents of an archive. */ | |
234 | boolean whole_archive; | |
235 | ||
236 | boolean loaded; | |
5cc18311 | 237 | |
89cdebba KH |
238 | #if 0 |
239 | unsigned int globals_in_this_file; | |
240 | #endif | |
252b5132 RH |
241 | const char *target; |
242 | boolean real; | |
243 | } lang_input_statement_type; | |
244 | ||
89cdebba | 245 | typedef struct { |
252b5132 RH |
246 | lang_statement_header_type header; |
247 | asection *section; | |
248 | lang_input_statement_type *ifile; | |
252b5132 | 249 | |
5cc18311 | 250 | } lang_input_section_type; |
252b5132 | 251 | |
89cdebba | 252 | typedef struct { |
252b5132 RH |
253 | lang_statement_header_type header; |
254 | asection *section; | |
255 | union lang_statement_union *file; | |
256 | } lang_afile_asection_pair_statement_type; | |
257 | ||
89cdebba | 258 | typedef struct lang_wild_statement_struct { |
252b5132 | 259 | lang_statement_header_type header; |
252b5132 RH |
260 | const char *filename; |
261 | boolean filenames_sorted; | |
b6bf44ba | 262 | struct wildcard_list *section_list; |
252b5132 | 263 | boolean keep_sections; |
252b5132 RH |
264 | lang_statement_list_type children; |
265 | } lang_wild_statement_type; | |
266 | ||
89cdebba | 267 | typedef struct lang_address_statement_struct { |
252b5132 | 268 | lang_statement_header_type header; |
89cdebba KH |
269 | const char *section_name; |
270 | union etree_union *address; | |
252b5132 RH |
271 | } lang_address_statement_type; |
272 | ||
89cdebba | 273 | typedef struct { |
252b5132 RH |
274 | lang_statement_header_type header; |
275 | bfd_vma output_offset; | |
276 | size_t size; | |
277 | asection *output_section; | |
278 | fill_type fill; | |
279 | } lang_padding_statement_type; | |
280 | ||
281 | /* A group statement collects a set of libraries together. The | |
282 | libraries are searched multiple times, until no new undefined | |
283 | symbols are found. The effect is to search a group of libraries as | |
284 | though they were a single library. */ | |
285 | ||
89cdebba | 286 | typedef struct { |
252b5132 RH |
287 | lang_statement_header_type header; |
288 | lang_statement_list_type children; | |
289 | } lang_group_statement_type; | |
290 | ||
89cdebba | 291 | typedef union lang_statement_union { |
252b5132 | 292 | lang_statement_header_type header; |
252b5132 RH |
293 | lang_wild_statement_type wild_statement; |
294 | lang_data_statement_type data_statement; | |
295 | lang_reloc_statement_type reloc_statement; | |
296 | lang_address_statement_type address_statement; | |
297 | lang_output_section_statement_type output_section_statement; | |
298 | lang_afile_asection_pair_statement_type afile_asection_pair_statement; | |
299 | lang_assignment_statement_type assignment_statement; | |
300 | lang_input_statement_type input_statement; | |
301 | lang_target_statement_type target_statement; | |
302 | lang_output_statement_type output_statement; | |
303 | lang_input_section_type input_section; | |
304 | lang_common_statement_type common_statement; | |
305 | lang_object_symbols_statement_type object_symbols_statement; | |
306 | lang_fill_statement_type fill_statement; | |
307 | lang_padding_statement_type padding_statement; | |
308 | lang_group_statement_type group_statement; | |
309 | } lang_statement_union_type; | |
310 | ||
311 | /* This structure holds information about a program header, from the | |
312 | PHDRS command in the linker script. */ | |
313 | ||
89cdebba | 314 | struct lang_phdr { |
252b5132 RH |
315 | struct lang_phdr *next; |
316 | const char *name; | |
317 | unsigned long type; | |
318 | boolean filehdr; | |
319 | boolean phdrs; | |
320 | etree_type *at; | |
321 | etree_type *flags; | |
322 | }; | |
323 | ||
324 | /* This structure is used to hold a list of sections which may not | |
325 | cross reference each other. */ | |
326 | ||
89cdebba | 327 | struct lang_nocrossref { |
252b5132 RH |
328 | struct lang_nocrossref *next; |
329 | const char *name; | |
330 | }; | |
331 | ||
332 | /* The list of nocrossref lists. */ | |
333 | ||
89cdebba | 334 | struct lang_nocrossrefs { |
252b5132 RH |
335 | struct lang_nocrossrefs *next; |
336 | struct lang_nocrossref *list; | |
337 | }; | |
338 | ||
339 | extern struct lang_nocrossrefs *nocrossref_list; | |
340 | ||
577a0623 AM |
341 | /* This structure is used to hold a list of input section names which |
342 | will not match an output section in the linker script. */ | |
343 | ||
344 | struct unique_sections { | |
345 | struct unique_sections *next; | |
346 | const char *name; | |
347 | }; | |
348 | ||
349 | extern struct unique_sections *unique_section_list; | |
350 | ||
252b5132 | 351 | extern lang_output_section_statement_type *abs_output_section; |
aea4bd9d | 352 | extern lang_statement_list_type lang_output_section_statement; |
252b5132 RH |
353 | extern boolean lang_has_input_file; |
354 | extern etree_type *base; | |
355 | extern lang_statement_list_type *stat_ptr; | |
356 | extern boolean delete_output_file_on_failure; | |
357 | ||
358 | extern const char *entry_symbol; | |
359 | extern boolean entry_from_cmdline; | |
b71e2778 | 360 | extern lang_statement_list_type file_chain; |
252b5132 RH |
361 | |
362 | extern void lang_init PARAMS ((void)); | |
363 | extern struct memory_region_struct *lang_memory_region_lookup | |
364 | PARAMS ((const char *const)); | |
365 | extern struct memory_region_struct *lang_memory_region_default | |
366 | PARAMS ((asection *)); | |
367 | extern void lang_map PARAMS ((void)); | |
aa8804e4 ILT |
368 | extern void lang_set_flags PARAMS ((lang_memory_region_type *, const char *, |
369 | int)); | |
252b5132 | 370 | extern void lang_add_output PARAMS ((const char *, int from_script)); |
aea4bd9d | 371 | extern lang_output_section_statement_type *lang_enter_output_section_statement |
252b5132 RH |
372 | PARAMS ((const char *output_section_statement_name, |
373 | etree_type * address_exp, | |
374 | enum section_type sectype, | |
375 | bfd_vma block_value, | |
376 | etree_type *align, | |
377 | etree_type *subalign, | |
378 | etree_type *)); | |
379 | extern void lang_final PARAMS ((void)); | |
380 | extern void lang_process PARAMS ((void)); | |
381 | extern void lang_section_start PARAMS ((const char *, union etree_union *)); | |
382 | extern void lang_add_entry PARAMS ((const char *, boolean)); | |
383 | extern void lang_add_target PARAMS ((const char *)); | |
384 | extern void lang_add_wild | |
b6bf44ba | 385 | PARAMS ((struct wildcard_spec *, struct wildcard_list *, boolean)); |
252b5132 RH |
386 | extern void lang_add_map PARAMS ((const char *)); |
387 | extern void lang_add_fill PARAMS ((int)); | |
388 | extern lang_assignment_statement_type * lang_add_assignment PARAMS ((union etree_union *)); | |
389 | extern void lang_add_attribute PARAMS ((enum statement_enum)); | |
390 | extern void lang_startup PARAMS ((const char *)); | |
391 | extern void lang_float PARAMS ((enum bfd_boolean)); | |
392 | extern void lang_leave_output_section_statement | |
562d3460 TW |
393 | PARAMS ((bfd_vma, const char *, struct lang_output_section_phdr_list *, |
394 | const char *)); | |
252b5132 RH |
395 | extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *)); |
396 | extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *, | |
397 | const char *)); | |
398 | extern void lang_statement_append PARAMS ((struct statement_list *, | |
399 | union lang_statement_union *, | |
400 | union lang_statement_union **)); | |
401 | extern void lang_for_each_input_file | |
402 | PARAMS ((void (*dothis) (lang_input_statement_type *))); | |
403 | extern void lang_for_each_file | |
404 | PARAMS ((void (*dothis) (lang_input_statement_type *))); | |
405 | extern bfd_vma lang_do_assignments | |
406 | PARAMS ((lang_statement_union_type * s, | |
407 | lang_output_section_statement_type *output_section_statement, | |
408 | fill_type fill, | |
409 | bfd_vma dot)); | |
410 | ||
411 | #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ | |
252b5132 RH |
412 | lang_input_statement_type *statement; \ |
413 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
414 | statement != (lang_input_statement_type *)NULL; \ | |
415 | statement = (lang_input_statement_type *)statement->next)\ | |
5cc18311 | 416 | |
252b5132 RH |
417 | extern void lang_process PARAMS ((void)); |
418 | extern void ldlang_add_file PARAMS ((lang_input_statement_type *)); | |
419 | extern lang_output_section_statement_type *lang_output_section_find | |
420 | PARAMS ((const char * const)); | |
421 | extern lang_input_statement_type *lang_add_input_file | |
422 | PARAMS ((const char *name, lang_input_file_enum_type file_type, | |
423 | const char *target)); | |
424 | extern void lang_add_keepsyms_file PARAMS ((const char *filename)); | |
425 | extern lang_output_section_statement_type * | |
426 | lang_output_section_statement_lookup PARAMS ((const char * const name)); | |
427 | extern void ldlang_add_undef PARAMS ((const char *const name)); | |
428 | extern void lang_add_output_format PARAMS ((const char *, const char *, | |
429 | const char *, int from_script)); | |
430 | extern void lang_list_init PARAMS ((lang_statement_list_type*)); | |
431 | extern void lang_add_data PARAMS ((int type, union etree_union *)); | |
432 | extern void lang_add_reloc | |
433 | PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto, | |
434 | asection *section, const char *name, union etree_union *addend)); | |
435 | extern void lang_for_each_statement | |
436 | PARAMS ((void (*func) (lang_statement_union_type *))); | |
437 | extern PTR stat_alloc PARAMS ((size_t size)); | |
438 | extern void dprint_statement PARAMS ((lang_statement_union_type *, int)); | |
439 | extern bfd_vma lang_size_sections | |
440 | PARAMS ((lang_statement_union_type *s, | |
441 | lang_output_section_statement_type *output_section_statement, | |
442 | lang_statement_union_type **prev, fill_type fill, | |
b3327aad | 443 | bfd_vma dot, boolean *relax)); |
252b5132 RH |
444 | extern void lang_enter_group PARAMS ((void)); |
445 | extern void lang_leave_group PARAMS ((void)); | |
39dcfe18 | 446 | extern void lang_add_section |
252b5132 RH |
447 | PARAMS ((lang_statement_list_type *ptr, asection *section, |
448 | lang_output_section_statement_type *output, | |
449 | lang_input_statement_type *file)); | |
450 | extern void lang_new_phdr | |
451 | PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *, | |
452 | etree_type *)); | |
453 | extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *)); | |
454 | extern void lang_enter_overlay PARAMS ((etree_type *, etree_type *, int)); | |
455 | extern void lang_enter_overlay_section PARAMS ((const char *)); | |
456 | extern void lang_leave_overlay_section | |
457 | PARAMS ((bfd_vma, struct lang_output_section_phdr_list *)); | |
458 | extern void lang_leave_overlay | |
562d3460 TW |
459 | PARAMS ((bfd_vma, const char *, struct lang_output_section_phdr_list *, |
460 | const char *)); | |
252b5132 RH |
461 | |
462 | extern struct bfd_elf_version_tree *lang_elf_version_info; | |
463 | ||
464 | extern struct bfd_elf_version_expr *lang_new_vers_regex | |
465 | PARAMS ((struct bfd_elf_version_expr *, const char *, const char *)); | |
466 | extern struct bfd_elf_version_tree *lang_new_vers_node | |
467 | PARAMS ((struct bfd_elf_version_expr *, struct bfd_elf_version_expr *)); | |
468 | extern struct bfd_elf_version_deps *lang_add_vers_depend | |
469 | PARAMS ((struct bfd_elf_version_deps *, const char *)); | |
470 | extern void lang_register_vers_node | |
471 | PARAMS ((const char *, struct bfd_elf_version_tree *, | |
472 | struct bfd_elf_version_deps *)); | |
577a0623 AM |
473 | boolean unique_section_p PARAMS ((const char *)); |
474 | extern void lang_add_unique PARAMS ((const char *)); | |
252b5132 RH |
475 | |
476 | #endif |