1 /* ldlang.h - linker command language support
2 Copyright 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
3 Free Software Foundation, Inc.
5 This file is part of GLD, the Gnu Linker.
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)
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.
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 the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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
;
35 typedef unsigned int fill_type
;
36 typedef struct statement_list
38 union lang_statement_union
*head
;
39 union lang_statement_union
**tail
;
40 } lang_statement_list_type
;
43 typedef struct memory_region_struct
46 struct memory_region_struct
*next
;
50 bfd_size_type old_length
;
53 boolean had_full_message
;
54 } lang_memory_region_type
;
56 typedef struct lang_statement_header_struct
58 union lang_statement_union
*next
;
61 lang_output_section_statement_enum
,
62 lang_assignment_statement_enum
,
63 lang_input_statement_enum
,
64 lang_address_statement_enum
,
65 lang_wild_statement_enum
,
66 lang_input_section_enum
,
67 lang_object_symbols_statement_enum
,
68 lang_fill_statement_enum
,
69 lang_data_statement_enum
,
70 lang_reloc_statement_enum
,
71 lang_target_statement_enum
,
72 lang_output_statement_enum
,
73 lang_padding_statement_enum
,
74 lang_group_statement_enum
,
76 lang_afile_asection_pair_statement_enum
,
77 lang_constructors_statement_enum
79 } lang_statement_header_type
;
84 lang_statement_header_type header
;
85 union etree_union
*exp
;
86 } lang_assignment_statement_type
;
89 typedef struct lang_target_statement_struct
91 lang_statement_header_type header
;
93 } lang_target_statement_type
;
96 typedef struct lang_output_statement_struct
98 lang_statement_header_type header
;
100 } lang_output_statement_type
;
102 /* Section types specified in a linker script. */
114 /* This structure holds a list of program headers describing segments
115 in which this section should be placed. */
117 struct lang_output_section_phdr_list
119 struct lang_output_section_phdr_list
*next
;
124 typedef struct lang_output_section_statement_struct
126 lang_statement_header_type header
;
127 union etree_union
*addr_tree
;
128 lang_statement_list_type children
;
130 union lang_statement_union
*next
;
135 asection
*bfd_section
;
136 flagword flags
; /* Or together of all input sections */
137 enum section_type sectype
;
138 struct memory_region_struct
*region
;
142 int subsection_alignment
; /* alignment of components */
143 int section_alignment
; /* alignment of start of section */
145 union etree_union
*load_base
;
147 struct lang_output_section_phdr_list
*phdrs
;
148 } lang_output_section_statement_type
;
153 lang_statement_header_type header
;
154 } lang_common_statement_type
;
158 lang_statement_header_type header
;
159 } lang_object_symbols_statement_type
;
163 lang_statement_header_type header
;
166 asection
*output_section
;
167 } lang_fill_statement_type
;
171 lang_statement_header_type header
;
173 union etree_union
*exp
;
175 asection
*output_section
;
177 } lang_data_statement_type
;
179 /* Generate a reloc in the output file. */
183 lang_statement_header_type header
;
185 /* Reloc to generate. */
186 bfd_reloc_code_real_type reloc
;
188 /* Reloc howto structure. */
189 reloc_howto_type
*howto
;
191 /* Section to generate reloc against. Exactly one of section and
192 name must be NULL. */
195 /* Name of symbol to generate reloc against. Exactly one of section
196 and name must be NULL. */
199 /* Expression for addend. */
200 union etree_union
*addend_exp
;
202 /* Resolved addend. */
203 bfd_vma addend_value
;
205 /* Output section where reloc should be performed. */
206 asection
*output_section
;
208 /* VMA within output section. */
210 } lang_reloc_statement_type
;
212 typedef struct lang_input_statement_struct
214 lang_statement_header_type header
;
215 /* Name of this file. */
216 const char *filename
;
217 /* Name to use for the symbol giving address of text start */
218 /* Usually the same as filename, but for a file spec'd with -l
219 this is the -l switch itself rather than the filename. */
220 const char *local_sym_name
;
225 file_ptr passive_position
;
227 /* Symbol table of the file. */
229 unsigned int symbol_count
;
231 /* Point to the next file - whatever it is, wanders up and down
234 union lang_statement_union
*next
;
235 /* Point to the next file, but skips archive contents */
236 union lang_statement_union
*next_real_file
;
240 /* 1 means search a set of directories for this file. */
241 boolean search_dirs_flag
;
243 /* 1 means this is base file of incremental load.
244 Do not load this file's text or data.
245 Also default text_start to after this file's bss. */
247 boolean just_syms_flag
;
249 /* Whether to search for this entry as a dynamic archive. */
252 /* Whether to include the entire contents of an archive. */
253 boolean whole_archive
;
257 /* unsigned int globals_in_this_file;*/
260 } lang_input_statement_type
;
264 lang_statement_header_type header
;
266 lang_input_statement_type
*ifile
;
268 } lang_input_section_type
;
273 lang_statement_header_type header
;
275 union lang_statement_union
*file
;
276 } lang_afile_asection_pair_statement_type
;
278 typedef struct lang_wild_statement_struct
280 lang_statement_header_type header
;
281 const char *section_name
;
282 boolean sections_sorted
;
283 const char *filename
;
284 boolean filenames_sorted
;
285 boolean keep_sections
;
286 struct name_list
*exclude_filename_list
;
287 lang_statement_list_type children
;
288 } lang_wild_statement_type
;
290 typedef struct lang_address_statement_struct
292 lang_statement_header_type header
;
293 const char *section_name
;
294 union etree_union
*address
;
295 } lang_address_statement_type
;
299 lang_statement_header_type header
;
300 bfd_vma output_offset
;
302 asection
*output_section
;
304 } lang_padding_statement_type
;
306 /* A group statement collects a set of libraries together. The
307 libraries are searched multiple times, until no new undefined
308 symbols are found. The effect is to search a group of libraries as
309 though they were a single library. */
313 lang_statement_header_type header
;
314 lang_statement_list_type children
;
315 } lang_group_statement_type
;
317 typedef union lang_statement_union
319 lang_statement_header_type header
;
320 union lang_statement_union
*next
;
321 lang_wild_statement_type wild_statement
;
322 lang_data_statement_type data_statement
;
323 lang_reloc_statement_type reloc_statement
;
324 lang_address_statement_type address_statement
;
325 lang_output_section_statement_type output_section_statement
;
326 lang_afile_asection_pair_statement_type afile_asection_pair_statement
;
327 lang_assignment_statement_type assignment_statement
;
328 lang_input_statement_type input_statement
;
329 lang_target_statement_type target_statement
;
330 lang_output_statement_type output_statement
;
331 lang_input_section_type input_section
;
332 lang_common_statement_type common_statement
;
333 lang_object_symbols_statement_type object_symbols_statement
;
334 lang_fill_statement_type fill_statement
;
335 lang_padding_statement_type padding_statement
;
336 lang_group_statement_type group_statement
;
337 } lang_statement_union_type
;
339 /* This structure holds information about a program header, from the
340 PHDRS command in the linker script. */
344 struct lang_phdr
*next
;
353 /* This structure is used to hold a list of sections which may not
354 cross reference each other. */
356 struct lang_nocrossref
358 struct lang_nocrossref
*next
;
362 /* The list of nocrossref lists. */
364 struct lang_nocrossrefs
366 struct lang_nocrossrefs
*next
;
367 struct lang_nocrossref
*list
;
370 extern struct lang_nocrossrefs
*nocrossref_list
;
372 extern lang_output_section_statement_type
*abs_output_section
;
373 extern boolean lang_has_input_file
;
374 extern etree_type
*base
;
375 extern lang_statement_list_type
*stat_ptr
;
376 extern boolean delete_output_file_on_failure
;
378 extern const char *entry_symbol
;
379 extern boolean entry_from_cmdline
;
381 extern void lang_init
PARAMS ((void));
382 extern struct memory_region_struct
*lang_memory_region_lookup
383 PARAMS ((const char *const));
384 extern struct memory_region_struct
*lang_memory_region_default
385 PARAMS ((asection
*));
386 extern void lang_map
PARAMS ((void));
387 extern void lang_set_flags
PARAMS ((lang_memory_region_type
*, const char *,
389 extern void lang_add_output
PARAMS ((const char *, int from_script
));
390 extern void lang_enter_output_section_statement
391 PARAMS ((const char *output_section_statement_name
,
392 etree_type
* address_exp
,
393 enum section_type sectype
,
396 etree_type
*subalign
,
398 extern void lang_final
PARAMS ((void));
399 extern void lang_process
PARAMS ((void));
400 extern void lang_section_start
PARAMS ((const char *, union etree_union
*));
401 extern void lang_add_entry
PARAMS ((const char *, boolean
));
402 extern void lang_add_target
PARAMS ((const char *));
403 extern void lang_add_wild
404 PARAMS ((const char *, boolean
, const char *, boolean
, boolean
, name_list
*));
405 extern void lang_add_map
PARAMS ((const char *));
406 extern void lang_add_fill
PARAMS ((int));
407 extern lang_assignment_statement_type
* lang_add_assignment
PARAMS ((union etree_union
*));
408 extern void lang_add_attribute
PARAMS ((enum statement_enum
));
409 extern void lang_startup
PARAMS ((const char *));
410 extern void lang_float
PARAMS ((enum bfd_boolean
));
411 extern void lang_leave_output_section_statement
412 PARAMS ((bfd_vma
, const char *, struct lang_output_section_phdr_list
*));
413 extern void lang_abs_symbol_at_end_of
PARAMS ((const char *, const char *));
414 extern void lang_abs_symbol_at_beginning_of
PARAMS ((const char *,
416 extern void lang_statement_append
PARAMS ((struct statement_list
*,
417 union lang_statement_union
*,
418 union lang_statement_union
**));
419 extern void lang_for_each_input_file
420 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
421 extern void lang_for_each_file
422 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
423 extern bfd_vma lang_do_assignments
424 PARAMS ((lang_statement_union_type
* s
,
425 lang_output_section_statement_type
*output_section_statement
,
429 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
430 extern lang_statement_list_type file_chain; \
431 lang_input_statement_type *statement; \
432 for (statement = (lang_input_statement_type *)file_chain.head;\
433 statement != (lang_input_statement_type *)NULL; \
434 statement = (lang_input_statement_type *)statement->next)\
436 extern void lang_process
PARAMS ((void));
437 extern void ldlang_add_file
PARAMS ((lang_input_statement_type
*));
438 extern lang_output_section_statement_type
*lang_output_section_find
439 PARAMS ((const char * const));
440 extern lang_input_statement_type
*lang_add_input_file
441 PARAMS ((const char *name
, lang_input_file_enum_type file_type
,
442 const char *target
));
443 extern void lang_add_keepsyms_file
PARAMS ((const char *filename
));
444 extern lang_output_section_statement_type
*
445 lang_output_section_statement_lookup
PARAMS ((const char * const name
));
446 extern void ldlang_add_undef
PARAMS ((const char *const name
));
447 extern void lang_add_output_format
PARAMS ((const char *, const char *,
448 const char *, int from_script
));
449 extern void lang_list_init
PARAMS ((lang_statement_list_type
*));
450 extern void lang_add_data
PARAMS ((int type
, union etree_union
*));
451 extern void lang_add_reloc
452 PARAMS ((bfd_reloc_code_real_type reloc
, reloc_howto_type
*howto
,
453 asection
*section
, const char *name
, union etree_union
*addend
));
454 extern void lang_for_each_statement
455 PARAMS ((void (*func
) (lang_statement_union_type
*)));
456 extern PTR stat_alloc
PARAMS ((size_t size
));
457 extern void dprint_statement
PARAMS ((lang_statement_union_type
*, int));
458 extern bfd_vma lang_size_sections
459 PARAMS ((lang_statement_union_type
*s
,
460 lang_output_section_statement_type
*output_section_statement
,
461 lang_statement_union_type
**prev
, fill_type fill
,
462 bfd_vma dot
, boolean relax
));
463 extern void lang_enter_group
PARAMS ((void));
464 extern void lang_leave_group
PARAMS ((void));
465 extern void wild_doit
466 PARAMS ((lang_statement_list_type
*ptr
, asection
*section
,
467 lang_output_section_statement_type
*output
,
468 lang_input_statement_type
*file
));
469 extern void lang_new_phdr
470 PARAMS ((const char *, etree_type
*, boolean
, boolean
, etree_type
*,
472 extern void lang_add_nocrossref
PARAMS ((struct lang_nocrossref
*));
473 extern void lang_enter_overlay
PARAMS ((etree_type
*, etree_type
*, int));
474 extern void lang_enter_overlay_section
PARAMS ((const char *));
475 extern void lang_leave_overlay_section
476 PARAMS ((bfd_vma
, struct lang_output_section_phdr_list
*));
477 extern void lang_leave_overlay
478 PARAMS ((bfd_vma
, const char *, struct lang_output_section_phdr_list
*));
480 extern struct bfd_elf_version_tree
*lang_elf_version_info
;
482 extern struct bfd_elf_version_expr
*lang_new_vers_regex
483 PARAMS ((struct bfd_elf_version_expr
*, const char *, const char *));
484 extern struct bfd_elf_version_tree
*lang_new_vers_node
485 PARAMS ((struct bfd_elf_version_expr
*, struct bfd_elf_version_expr
*));
486 extern struct bfd_elf_version_deps
*lang_add_vers_depend
487 PARAMS ((struct bfd_elf_version_deps
*, const char *));
488 extern void lang_register_vers_node
489 PARAMS ((const char *, struct bfd_elf_version_tree
*,
490 struct bfd_elf_version_deps
*));