1 /* ldlang.h - linker command language support
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 Free Software Foundation, Inc.
6 This file is part of GLD, the Gnu Linker.
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 2, or (at your option)
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.
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
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
;
37 unsigned char data
[1];
40 typedef struct statement_list
{
41 union lang_statement_union
*head
;
42 union lang_statement_union
**tail
;
43 } lang_statement_list_type
;
45 typedef struct memory_region_struct
{
47 struct memory_region_struct
*next
;
51 bfd_size_type old_length
;
54 bfd_boolean had_full_message
;
55 } lang_memory_region_type
;
57 typedef struct lang_statement_header_struct
{
58 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
;
81 lang_statement_header_type header
;
82 union etree_union
*exp
;
83 } lang_assignment_statement_type
;
85 typedef struct lang_target_statement_struct
{
86 lang_statement_header_type header
;
88 } lang_target_statement_type
;
90 typedef struct lang_output_statement_struct
{
91 lang_statement_header_type header
;
93 } lang_output_statement_type
;
95 /* Section types specified in a linker script. */
106 /* This structure holds a list of program headers describing segments
107 in which this section should be placed. */
109 struct lang_output_section_phdr_list
{
110 struct lang_output_section_phdr_list
*next
;
115 typedef struct lang_output_section_statement_struct
{
116 lang_statement_header_type header
;
117 union etree_union
*addr_tree
;
118 lang_statement_list_type children
;
120 union lang_statement_union
*next
;
123 bfd_boolean processed
;
125 asection
*bfd_section
;
126 flagword flags
; /* Or together of all input sections */
127 enum section_type sectype
;
128 struct memory_region_struct
*region
;
129 struct memory_region_struct
*lma_region
;
133 int subsection_alignment
; /* alignment of components */
134 int section_alignment
; /* alignment of start of section */
136 union etree_union
*load_base
;
138 /* If non-null, an expression to evaluate after setting the section's
139 size. The expression is evaluated inside REGION (above) with '.'
140 set to the end of the section. Used in the last overlay section
141 to move '.' past all the overlaid sections. */
142 union etree_union
*update_dot_tree
;
144 struct lang_output_section_phdr_list
*phdrs
;
145 } lang_output_section_statement_type
;
148 lang_statement_header_type header
;
149 } lang_common_statement_type
;
152 lang_statement_header_type header
;
153 } lang_object_symbols_statement_type
;
156 lang_statement_header_type header
;
159 asection
*output_section
;
160 } lang_fill_statement_type
;
163 lang_statement_header_type header
;
165 union etree_union
*exp
;
167 asection
*output_section
;
169 } lang_data_statement_type
;
171 /* Generate a reloc in the output file. */
174 lang_statement_header_type header
;
176 /* Reloc to generate. */
177 bfd_reloc_code_real_type reloc
;
179 /* Reloc howto structure. */
180 reloc_howto_type
*howto
;
182 /* Section to generate reloc against. Exactly one of section and
183 name must be NULL. */
186 /* Name of symbol to generate reloc against. Exactly one of section
187 and name must be NULL. */
190 /* Expression for addend. */
191 union etree_union
*addend_exp
;
193 /* Resolved addend. */
194 bfd_vma addend_value
;
196 /* Output section where reloc should be performed. */
197 asection
*output_section
;
199 /* VMA within output section. */
201 } lang_reloc_statement_type
;
203 typedef struct lang_input_statement_struct
{
204 lang_statement_header_type header
;
205 /* Name of this file. */
206 const char *filename
;
207 /* Name to use for the symbol giving address of text start */
208 /* Usually the same as filename, but for a file spec'd with -l
209 this is the -l switch itself rather than the filename. */
210 const char *local_sym_name
;
215 file_ptr passive_position
;
217 /* Symbol table of the file. */
219 unsigned int symbol_count
;
221 /* Point to the next file - whatever it is, wanders up and down
224 union lang_statement_union
*next
;
225 /* Point to the next file, but skips archive contents */
226 union lang_statement_union
*next_real_file
;
228 bfd_boolean is_archive
;
230 /* 1 means search a set of directories for this file. */
231 bfd_boolean search_dirs_flag
;
233 /* 1 means this is base file of incremental load.
234 Do not load this file's text or data.
235 Also default text_start to after this file's bss. */
237 bfd_boolean just_syms_flag
;
239 /* Whether to search for this entry as a dynamic archive. */
242 /* Whether to include the entire contents of an archive. */
243 bfd_boolean whole_archive
;
248 unsigned int globals_in_this_file
;
252 } lang_input_statement_type
;
255 lang_statement_header_type header
;
257 lang_input_statement_type
*ifile
;
259 } lang_input_section_type
;
262 lang_statement_header_type header
;
264 union lang_statement_union
*file
;
265 } lang_afile_asection_pair_statement_type
;
267 typedef struct lang_wild_statement_struct
{
268 lang_statement_header_type header
;
269 const char *filename
;
270 bfd_boolean filenames_sorted
;
271 struct wildcard_list
*section_list
;
272 bfd_boolean keep_sections
;
273 lang_statement_list_type children
;
274 } lang_wild_statement_type
;
276 typedef struct lang_address_statement_struct
{
277 lang_statement_header_type header
;
278 const char *section_name
;
279 union etree_union
*address
;
280 } lang_address_statement_type
;
283 lang_statement_header_type header
;
284 bfd_vma output_offset
;
286 asection
*output_section
;
288 } lang_padding_statement_type
;
290 /* A group statement collects a set of libraries together. The
291 libraries are searched multiple times, until no new undefined
292 symbols are found. The effect is to search a group of libraries as
293 though they were a single library. */
296 lang_statement_header_type header
;
297 lang_statement_list_type children
;
298 } lang_group_statement_type
;
300 typedef union lang_statement_union
{
301 lang_statement_header_type header
;
302 lang_wild_statement_type wild_statement
;
303 lang_data_statement_type data_statement
;
304 lang_reloc_statement_type reloc_statement
;
305 lang_address_statement_type address_statement
;
306 lang_output_section_statement_type output_section_statement
;
307 lang_afile_asection_pair_statement_type afile_asection_pair_statement
;
308 lang_assignment_statement_type assignment_statement
;
309 lang_input_statement_type input_statement
;
310 lang_target_statement_type target_statement
;
311 lang_output_statement_type output_statement
;
312 lang_input_section_type input_section
;
313 lang_common_statement_type common_statement
;
314 lang_object_symbols_statement_type object_symbols_statement
;
315 lang_fill_statement_type fill_statement
;
316 lang_padding_statement_type padding_statement
;
317 lang_group_statement_type group_statement
;
318 } lang_statement_union_type
;
320 /* This structure holds information about a program header, from the
321 PHDRS command in the linker script. */
324 struct lang_phdr
*next
;
333 /* This structure is used to hold a list of sections which may not
334 cross reference each other. */
336 struct lang_nocrossref
{
337 struct lang_nocrossref
*next
;
341 /* The list of nocrossref lists. */
343 struct lang_nocrossrefs
{
344 struct lang_nocrossrefs
*next
;
345 struct lang_nocrossref
*list
;
348 extern struct lang_nocrossrefs
*nocrossref_list
;
350 /* This structure is used to hold a list of input section names which
351 will not match an output section in the linker script. */
353 struct unique_sections
{
354 struct unique_sections
*next
;
358 extern struct unique_sections
*unique_section_list
;
360 extern lang_output_section_statement_type
*abs_output_section
;
361 extern lang_statement_list_type lang_output_section_statement
;
362 extern bfd_boolean lang_has_input_file
;
363 extern etree_type
*base
;
364 extern lang_statement_list_type
*stat_ptr
;
365 extern bfd_boolean delete_output_file_on_failure
;
367 extern struct bfd_sym_chain entry_symbol
;
368 extern const char *entry_section
;
369 extern bfd_boolean entry_from_cmdline
;
370 extern lang_statement_list_type file_chain
;
372 extern void lang_init
PARAMS ((void));
373 extern struct memory_region_struct
*lang_memory_region_lookup
374 PARAMS ((const char *const));
375 extern struct memory_region_struct
*lang_memory_region_default
376 PARAMS ((asection
*));
377 extern void lang_map
PARAMS ((void));
378 extern void lang_set_flags
PARAMS ((lang_memory_region_type
*, const char *,
380 extern void lang_add_output
PARAMS ((const char *, int from_script
));
381 extern lang_output_section_statement_type
*lang_enter_output_section_statement
382 PARAMS ((const char *output_section_statement_name
,
383 etree_type
* address_exp
,
384 enum section_type sectype
,
387 etree_type
*subalign
,
389 extern void lang_final
PARAMS ((void));
390 extern void lang_process
PARAMS ((void));
391 extern void lang_section_start
PARAMS ((const char *, union etree_union
*));
392 extern void lang_add_entry
PARAMS ((const char *, bfd_boolean
));
393 extern void lang_add_target
PARAMS ((const char *));
394 extern void lang_add_wild
395 PARAMS ((struct wildcard_spec
*, struct wildcard_list
*, bfd_boolean
));
396 extern void lang_add_map
PARAMS ((const char *));
397 extern void lang_add_fill
PARAMS ((fill_type
*));
398 extern lang_assignment_statement_type
* lang_add_assignment
PARAMS ((union etree_union
*));
399 extern void lang_add_attribute
PARAMS ((enum statement_enum
));
400 extern void lang_startup
PARAMS ((const char *));
401 extern void lang_float
PARAMS ((bfd_boolean
));
402 extern void lang_leave_output_section_statement
403 PARAMS ((fill_type
*, const char *, struct lang_output_section_phdr_list
*,
405 extern void lang_abs_symbol_at_end_of
PARAMS ((const char *, const char *));
406 extern void lang_abs_symbol_at_beginning_of
PARAMS ((const char *,
408 extern void lang_statement_append
PARAMS ((struct statement_list
*,
409 union lang_statement_union
*,
410 union lang_statement_union
**));
411 extern void lang_for_each_input_file
412 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
413 extern void lang_for_each_file
414 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
415 extern void lang_reset_memory_regions
PARAMS ((void));
416 extern bfd_vma lang_do_assignments
417 PARAMS ((lang_statement_union_type
* s
,
418 lang_output_section_statement_type
*output_section_statement
,
422 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
423 lang_input_statement_type *statement; \
424 for (statement = (lang_input_statement_type *)file_chain.head;\
425 statement != (lang_input_statement_type *)NULL; \
426 statement = (lang_input_statement_type *)statement->next)\
428 extern void lang_process PARAMS ((void));
429 extern void ldlang_add_file
PARAMS ((lang_input_statement_type
*));
430 extern lang_output_section_statement_type
*lang_output_section_find
431 PARAMS ((const char * const));
432 extern lang_input_statement_type
*lang_add_input_file
433 PARAMS ((const char *name
, lang_input_file_enum_type file_type
,
434 const char *target
));
435 extern void lang_add_keepsyms_file
PARAMS ((const char *filename
));
436 extern lang_output_section_statement_type
*
437 lang_output_section_statement_lookup
PARAMS ((const char * const name
));
438 extern void ldlang_add_undef
PARAMS ((const char *const name
));
439 extern void lang_add_output_format
PARAMS ((const char *, const char *,
440 const char *, int from_script
));
441 extern void lang_list_init
PARAMS ((lang_statement_list_type
*));
442 extern void lang_add_data
PARAMS ((int type
, union etree_union
*));
443 extern void lang_add_reloc
444 PARAMS ((bfd_reloc_code_real_type reloc
, reloc_howto_type
*howto
,
445 asection
*section
, const char *name
, union etree_union
*addend
));
446 extern void lang_for_each_statement
447 PARAMS ((void (*func
) (lang_statement_union_type
*)));
448 extern PTR stat_alloc
PARAMS ((size_t size
));
449 extern void dprint_statement
PARAMS ((lang_statement_union_type
*, int));
450 extern bfd_vma lang_size_sections
451 PARAMS ((lang_statement_union_type
*s
,
452 lang_output_section_statement_type
*output_section_statement
,
453 lang_statement_union_type
**prev
, fill_type
*fill
,
454 bfd_vma dot
, bfd_boolean
*relax
));
455 extern void lang_enter_group
PARAMS ((void));
456 extern void lang_leave_group
PARAMS ((void));
457 extern void lang_add_section
458 PARAMS ((lang_statement_list_type
*ptr
, asection
*section
,
459 lang_output_section_statement_type
*output
,
460 lang_input_statement_type
*file
));
461 extern void lang_new_phdr
462 PARAMS ((const char *, etree_type
*, bfd_boolean
, bfd_boolean
, etree_type
*,
464 extern void lang_add_nocrossref
PARAMS ((struct lang_nocrossref
*));
465 extern void lang_enter_overlay
PARAMS ((etree_type
*));
466 extern void lang_enter_overlay_section
PARAMS ((const char *));
467 extern void lang_leave_overlay_section
468 PARAMS ((fill_type
*, struct lang_output_section_phdr_list
*));
469 extern void lang_leave_overlay
470 PARAMS ((etree_type
*, int, fill_type
*, const char *,
471 struct lang_output_section_phdr_list
*, const char *));
473 extern struct bfd_elf_version_tree
*lang_elf_version_info
;
475 extern struct bfd_elf_version_expr
*lang_new_vers_pattern
476 PARAMS ((struct bfd_elf_version_expr
*, const char *, const char *));
477 extern struct bfd_elf_version_tree
*lang_new_vers_node
478 PARAMS ((struct bfd_elf_version_expr
*, struct bfd_elf_version_expr
*));
479 extern struct bfd_elf_version_deps
*lang_add_vers_depend
480 PARAMS ((struct bfd_elf_version_deps
*, const char *));
481 extern void lang_register_vers_node
482 PARAMS ((const char *, struct bfd_elf_version_tree
*,
483 struct bfd_elf_version_deps
*));
484 bfd_boolean unique_section_p
PARAMS ((const char *));
485 extern void lang_add_unique
PARAMS ((const char *));
486 extern const char *lang_get_output_target
PARAMS ((void));