1 /* ldlang.h - linker command language support
2 Copyright 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
4 This file is part of GLD, the Gnu Linker.
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)
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.
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 the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 lang_input_file_is_l_enum
,
27 lang_input_file_is_symbols_only_enum
,
28 lang_input_file_is_marker_enum
,
29 lang_input_file_is_fake_enum
,
30 lang_input_file_is_search_file_enum
,
31 lang_input_file_is_file_enum
32 } lang_input_file_enum_type
;
34 typedef unsigned int fill_type
;
35 typedef struct statement_list
37 union lang_statement_union
*head
;
38 union lang_statement_union
**tail
;
39 } lang_statement_list_type
;
42 typedef struct memory_region_struct
45 struct memory_region_struct
*next
;
49 bfd_size_type old_length
;
52 boolean had_full_message
;
53 } lang_memory_region_type
;
55 typedef struct lang_statement_header_struct
57 union lang_statement_union
*next
;
60 lang_output_section_statement_enum
,
61 lang_assignment_statement_enum
,
62 lang_input_statement_enum
,
63 lang_address_statement_enum
,
64 lang_wild_statement_enum
,
65 lang_input_section_enum
,
66 lang_object_symbols_statement_enum
,
67 lang_fill_statement_enum
,
68 lang_data_statement_enum
,
69 lang_reloc_statement_enum
,
70 lang_target_statement_enum
,
71 lang_output_statement_enum
,
72 lang_padding_statement_enum
,
73 lang_group_statement_enum
,
75 lang_afile_asection_pair_statement_enum
,
76 lang_constructors_statement_enum
78 } lang_statement_header_type
;
83 lang_statement_header_type header
;
84 union etree_union
*exp
;
85 } lang_assignment_statement_type
;
88 typedef struct lang_target_statement_struct
90 lang_statement_header_type header
;
92 } lang_target_statement_type
;
95 typedef struct lang_output_statement_struct
97 lang_statement_header_type header
;
99 } lang_output_statement_type
;
101 /* Section types specified in a linker script. */
113 /* This structure holds a list of program headers describing segments
114 in which this section should be placed. */
116 struct lang_output_section_phdr_list
118 struct lang_output_section_phdr_list
*next
;
123 typedef struct lang_output_section_statement_struct
125 lang_statement_header_type header
;
126 union etree_union
*addr_tree
;
127 lang_statement_list_type children
;
129 union lang_statement_union
*next
;
134 asection
*bfd_section
;
135 flagword flags
; /* Or together of all input sections */
136 enum section_type sectype
;
137 struct memory_region_struct
*region
;
141 int subsection_alignment
; /* alignment of components */
142 int section_alignment
; /* alignment of start of section */
144 union etree_union
*load_base
;
146 struct lang_output_section_phdr_list
*phdrs
;
147 } lang_output_section_statement_type
;
152 lang_statement_header_type header
;
153 } lang_common_statement_type
;
157 lang_statement_header_type header
;
158 } lang_object_symbols_statement_type
;
162 lang_statement_header_type header
;
165 asection
*output_section
;
166 } lang_fill_statement_type
;
170 lang_statement_header_type header
;
172 union etree_union
*exp
;
174 asection
*output_section
;
176 } lang_data_statement_type
;
178 /* Generate a reloc in the output file. */
182 lang_statement_header_type header
;
184 /* Reloc to generate. */
185 bfd_reloc_code_real_type reloc
;
187 /* Reloc howto structure. */
188 reloc_howto_type
*howto
;
190 /* Section to generate reloc against. Exactly one of section and
191 name must be NULL. */
194 /* Name of symbol to generate reloc against. Exactly one of section
195 and name must be NULL. */
198 /* Expression for addend. */
199 union etree_union
*addend_exp
;
201 /* Resolved addend. */
202 bfd_vma addend_value
;
204 /* Output section where reloc should be performed. */
205 asection
*output_section
;
207 /* VMA within output section. */
209 } lang_reloc_statement_type
;
211 typedef struct lang_input_statement_struct
213 lang_statement_header_type header
;
214 /* Name of this file. */
215 const char *filename
;
216 /* Name to use for the symbol giving address of text start */
217 /* Usually the same as filename, but for a file spec'd with -l
218 this is the -l switch itself rather than the filename. */
219 const char *local_sym_name
;
224 file_ptr passive_position
;
226 /* Symbol table of the file. */
228 unsigned int symbol_count
;
230 /* Point to the next file - whatever it is, wanders up and down
233 union lang_statement_union
*next
;
234 /* Point to the next file, but skips archive contents */
235 union lang_statement_union
*next_real_file
;
239 /* 1 means search a set of directories for this file. */
240 boolean search_dirs_flag
;
242 /* 1 means this is base file of incremental load.
243 Do not load this file's text or data.
244 Also default text_start to after this file's bss. */
246 boolean just_syms_flag
;
248 /* Whether to search for this entry as a dynamic archive. */
251 /* Whether to include the entire contents of an archive. */
252 boolean whole_archive
;
256 /* unsigned int globals_in_this_file;*/
259 } lang_input_statement_type
;
263 lang_statement_header_type header
;
265 lang_input_statement_type
*ifile
;
267 } lang_input_section_type
;
272 lang_statement_header_type header
;
274 union lang_statement_union
*file
;
275 } lang_afile_asection_pair_statement_type
;
277 typedef struct lang_wild_statement_struct
279 lang_statement_header_type header
;
280 const char *section_name
;
281 boolean sections_sorted
;
282 const char *filename
;
283 boolean filenames_sorted
;
284 boolean keep_sections
;
285 const char *exclude_filename
;
286 lang_statement_list_type children
;
287 } lang_wild_statement_type
;
289 typedef struct lang_address_statement_struct
291 lang_statement_header_type header
;
292 const char *section_name
;
293 union etree_union
*address
;
294 } lang_address_statement_type
;
298 lang_statement_header_type header
;
299 bfd_vma output_offset
;
301 asection
*output_section
;
303 } lang_padding_statement_type
;
305 /* A group statement collects a set of libraries together. The
306 libraries are searched multiple times, until no new undefined
307 symbols are found. The effect is to search a group of libraries as
308 though they were a single library. */
312 lang_statement_header_type header
;
313 lang_statement_list_type children
;
314 } lang_group_statement_type
;
316 typedef union lang_statement_union
318 lang_statement_header_type header
;
319 union lang_statement_union
*next
;
320 lang_wild_statement_type wild_statement
;
321 lang_data_statement_type data_statement
;
322 lang_reloc_statement_type reloc_statement
;
323 lang_address_statement_type address_statement
;
324 lang_output_section_statement_type output_section_statement
;
325 lang_afile_asection_pair_statement_type afile_asection_pair_statement
;
326 lang_assignment_statement_type assignment_statement
;
327 lang_input_statement_type input_statement
;
328 lang_target_statement_type target_statement
;
329 lang_output_statement_type output_statement
;
330 lang_input_section_type input_section
;
331 lang_common_statement_type common_statement
;
332 lang_object_symbols_statement_type object_symbols_statement
;
333 lang_fill_statement_type fill_statement
;
334 lang_padding_statement_type padding_statement
;
335 lang_group_statement_type group_statement
;
336 } lang_statement_union_type
;
338 /* This structure holds information about a program header, from the
339 PHDRS command in the linker script. */
343 struct lang_phdr
*next
;
352 /* This structure is used to hold a list of sections which may not
353 cross reference each other. */
355 struct lang_nocrossref
357 struct lang_nocrossref
*next
;
361 /* The list of nocrossref lists. */
363 struct lang_nocrossrefs
365 struct lang_nocrossrefs
*next
;
366 struct lang_nocrossref
*list
;
369 extern struct lang_nocrossrefs
*nocrossref_list
;
371 extern lang_output_section_statement_type
*abs_output_section
;
372 extern boolean lang_has_input_file
;
373 extern etree_type
*base
;
374 extern lang_statement_list_type
*stat_ptr
;
375 extern boolean delete_output_file_on_failure
;
377 extern const char *entry_symbol
;
378 extern boolean entry_from_cmdline
;
380 extern void lang_init
PARAMS ((void));
381 extern struct memory_region_struct
*lang_memory_region_lookup
382 PARAMS ((const char *const));
383 extern struct memory_region_struct
*lang_memory_region_default
384 PARAMS ((asection
*));
385 extern void lang_map
PARAMS ((void));
386 extern void lang_set_flags
PARAMS ((lang_memory_region_type
*, const char *));
387 extern void lang_add_output
PARAMS ((const char *, int from_script
));
388 extern void lang_enter_output_section_statement
389 PARAMS ((const char *output_section_statement_name
,
390 etree_type
* address_exp
,
391 enum section_type sectype
,
394 etree_type
*subalign
,
396 extern void lang_final
PARAMS ((void));
397 extern void lang_process
PARAMS ((void));
398 extern void lang_section_start
PARAMS ((const char *, union etree_union
*));
399 extern void lang_add_entry
PARAMS ((const char *, boolean
));
400 extern void lang_add_target
PARAMS ((const char *));
401 extern void lang_add_wild
402 PARAMS ((const char *, boolean
, const char *, boolean
, boolean
, const char *));
403 extern void lang_add_map
PARAMS ((const char *));
404 extern void lang_add_fill
PARAMS ((int));
405 extern lang_assignment_statement_type
* lang_add_assignment
PARAMS ((union etree_union
*));
406 extern void lang_add_attribute
PARAMS ((enum statement_enum
));
407 extern void lang_startup
PARAMS ((const char *));
408 extern void lang_float
PARAMS ((enum bfd_boolean
));
409 extern void lang_leave_output_section_statement
410 PARAMS ((bfd_vma
, const char *, struct lang_output_section_phdr_list
*));
411 extern void lang_abs_symbol_at_end_of
PARAMS ((const char *, const char *));
412 extern void lang_abs_symbol_at_beginning_of
PARAMS ((const char *,
414 extern void lang_statement_append
PARAMS ((struct statement_list
*,
415 union lang_statement_union
*,
416 union lang_statement_union
**));
417 extern void lang_for_each_input_file
418 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
419 extern void lang_for_each_file
420 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
421 extern bfd_vma lang_do_assignments
422 PARAMS ((lang_statement_union_type
* s
,
423 lang_output_section_statement_type
*output_section_statement
,
427 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
428 extern lang_statement_list_type file_chain; \
429 lang_input_statement_type *statement; \
430 for (statement = (lang_input_statement_type *)file_chain.head;\
431 statement != (lang_input_statement_type *)NULL; \
432 statement = (lang_input_statement_type *)statement->next)\
434 extern void lang_process
PARAMS ((void));
435 extern void ldlang_add_file
PARAMS ((lang_input_statement_type
*));
436 extern lang_output_section_statement_type
*lang_output_section_find
437 PARAMS ((const char * const));
438 extern lang_input_statement_type
*lang_add_input_file
439 PARAMS ((const char *name
, lang_input_file_enum_type file_type
,
440 const char *target
));
441 extern void lang_add_keepsyms_file
PARAMS ((const char *filename
));
442 extern lang_output_section_statement_type
*
443 lang_output_section_statement_lookup
PARAMS ((const char * const name
));
444 extern void ldlang_add_undef
PARAMS ((const char *const name
));
445 extern void lang_add_output_format
PARAMS ((const char *, const char *,
446 const char *, int from_script
));
447 extern void lang_list_init
PARAMS ((lang_statement_list_type
*));
448 extern void lang_add_data
PARAMS ((int type
, union etree_union
*));
449 extern void lang_add_reloc
450 PARAMS ((bfd_reloc_code_real_type reloc
, reloc_howto_type
*howto
,
451 asection
*section
, const char *name
, union etree_union
*addend
));
452 extern void lang_for_each_statement
453 PARAMS ((void (*func
) (lang_statement_union_type
*)));
454 extern PTR stat_alloc
PARAMS ((size_t size
));
455 extern void dprint_statement
PARAMS ((lang_statement_union_type
*, int));
456 extern bfd_vma lang_size_sections
457 PARAMS ((lang_statement_union_type
*s
,
458 lang_output_section_statement_type
*output_section_statement
,
459 lang_statement_union_type
**prev
, fill_type fill
,
460 bfd_vma dot
, boolean relax
));
461 extern void lang_enter_group
PARAMS ((void));
462 extern void lang_leave_group
PARAMS ((void));
463 extern void wild_doit
464 PARAMS ((lang_statement_list_type
*ptr
, asection
*section
,
465 lang_output_section_statement_type
*output
,
466 lang_input_statement_type
*file
));
467 extern void lang_new_phdr
468 PARAMS ((const char *, etree_type
*, boolean
, boolean
, etree_type
*,
470 extern void lang_add_nocrossref
PARAMS ((struct lang_nocrossref
*));
471 extern void lang_enter_overlay
PARAMS ((etree_type
*, etree_type
*, int));
472 extern void lang_enter_overlay_section
PARAMS ((const char *));
473 extern void lang_leave_overlay_section
474 PARAMS ((bfd_vma
, struct lang_output_section_phdr_list
*));
475 extern void lang_leave_overlay
476 PARAMS ((bfd_vma
, const char *, struct lang_output_section_phdr_list
*));
478 extern struct bfd_elf_version_tree
*lang_elf_version_info
;
480 extern struct bfd_elf_version_expr
*lang_new_vers_regex
481 PARAMS ((struct bfd_elf_version_expr
*, const char *, const char *));
482 extern struct bfd_elf_version_tree
*lang_new_vers_node
483 PARAMS ((struct bfd_elf_version_expr
*, struct bfd_elf_version_expr
*));
484 extern struct bfd_elf_version_deps
*lang_add_vers_depend
485 PARAMS ((struct bfd_elf_version_deps
*, const char *));
486 extern void lang_register_vers_node
487 PARAMS ((const char *, struct bfd_elf_version_tree
*,
488 struct bfd_elf_version_deps
*));