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 1, 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
;
35 typedef unsigned int fill_type
;
37 typedef struct statement_list
{
38 union lang_statement_union
*head
;
39 union lang_statement_union
**tail
;
40 } lang_statement_list_type
;
42 typedef struct memory_region_struct
{
44 struct memory_region_struct
*next
;
48 bfd_size_type old_length
;
51 boolean had_full_message
;
52 } lang_memory_region_type
;
54 typedef struct lang_statement_header_struct
{
55 union lang_statement_union
*next
;
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
,
72 lang_afile_asection_pair_statement_enum
,
73 lang_constructors_statement_enum
75 } lang_statement_header_type
;
78 lang_statement_header_type header
;
79 union etree_union
*exp
;
80 } lang_assignment_statement_type
;
82 typedef struct lang_target_statement_struct
{
83 lang_statement_header_type header
;
85 } lang_target_statement_type
;
87 typedef struct lang_output_statement_struct
{
88 lang_statement_header_type header
;
90 } lang_output_statement_type
;
92 /* Section types specified in a linker script. */
103 /* This structure holds a list of program headers describing segments
104 in which this section should be placed. */
106 struct lang_output_section_phdr_list
{
107 struct lang_output_section_phdr_list
*next
;
112 typedef struct lang_output_section_statement_struct
{
113 lang_statement_header_type header
;
114 union etree_union
*addr_tree
;
115 lang_statement_list_type children
;
117 union lang_statement_union
*next
;
122 asection
*bfd_section
;
123 flagword flags
; /* Or together of all input sections */
124 enum section_type sectype
;
125 struct memory_region_struct
*region
;
126 struct memory_region_struct
*lma_region
;
130 int subsection_alignment
; /* alignment of components */
131 int section_alignment
; /* alignment of start of section */
133 union etree_union
*load_base
;
135 struct lang_output_section_phdr_list
*phdrs
;
136 } lang_output_section_statement_type
;
139 lang_statement_header_type header
;
140 } lang_common_statement_type
;
143 lang_statement_header_type header
;
144 } lang_object_symbols_statement_type
;
147 lang_statement_header_type header
;
150 asection
*output_section
;
151 } lang_fill_statement_type
;
154 lang_statement_header_type header
;
156 union etree_union
*exp
;
158 asection
*output_section
;
160 } lang_data_statement_type
;
162 /* Generate a reloc in the output file. */
165 lang_statement_header_type header
;
167 /* Reloc to generate. */
168 bfd_reloc_code_real_type reloc
;
170 /* Reloc howto structure. */
171 reloc_howto_type
*howto
;
173 /* Section to generate reloc against. Exactly one of section and
174 name must be NULL. */
177 /* Name of symbol to generate reloc against. Exactly one of section
178 and name must be NULL. */
181 /* Expression for addend. */
182 union etree_union
*addend_exp
;
184 /* Resolved addend. */
185 bfd_vma addend_value
;
187 /* Output section where reloc should be performed. */
188 asection
*output_section
;
190 /* VMA within output section. */
192 } lang_reloc_statement_type
;
194 typedef struct lang_input_statement_struct
{
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
;
206 file_ptr passive_position
;
208 /* Symbol table of the file. */
210 unsigned int symbol_count
;
212 /* Point to the next file - whatever it is, wanders up and down
215 union lang_statement_union
*next
;
216 /* Point to the next file, but skips archive contents */
217 union lang_statement_union
*next_real_file
;
221 /* 1 means search a set of directories for this file. */
222 boolean search_dirs_flag
;
224 /* 1 means this is base file of incremental load.
225 Do not load this file's text or data.
226 Also default text_start to after this file's bss. */
228 boolean just_syms_flag
;
230 /* Whether to search for this entry as a dynamic archive. */
233 /* Whether to include the entire contents of an archive. */
234 boolean whole_archive
;
239 unsigned int globals_in_this_file
;
243 } lang_input_statement_type
;
246 lang_statement_header_type header
;
248 lang_input_statement_type
*ifile
;
250 } lang_input_section_type
;
253 lang_statement_header_type header
;
255 union lang_statement_union
*file
;
256 } lang_afile_asection_pair_statement_type
;
258 typedef struct lang_wild_statement_struct
{
259 lang_statement_header_type header
;
260 const char *section_name
;
261 boolean sections_sorted
;
262 const char *filename
;
263 boolean filenames_sorted
;
264 boolean keep_sections
;
265 struct name_list
*exclude_filename_list
;
266 lang_statement_list_type children
;
267 } lang_wild_statement_type
;
269 typedef struct lang_address_statement_struct
{
270 lang_statement_header_type header
;
271 const char *section_name
;
272 union etree_union
*address
;
273 } lang_address_statement_type
;
276 lang_statement_header_type header
;
277 bfd_vma output_offset
;
279 asection
*output_section
;
281 } lang_padding_statement_type
;
283 /* A group statement collects a set of libraries together. The
284 libraries are searched multiple times, until no new undefined
285 symbols are found. The effect is to search a group of libraries as
286 though they were a single library. */
289 lang_statement_header_type header
;
290 lang_statement_list_type children
;
291 } lang_group_statement_type
;
293 typedef union lang_statement_union
{
294 lang_statement_header_type header
;
295 union lang_statement_union
*next
;
296 lang_wild_statement_type wild_statement
;
297 lang_data_statement_type data_statement
;
298 lang_reloc_statement_type reloc_statement
;
299 lang_address_statement_type address_statement
;
300 lang_output_section_statement_type output_section_statement
;
301 lang_afile_asection_pair_statement_type afile_asection_pair_statement
;
302 lang_assignment_statement_type assignment_statement
;
303 lang_input_statement_type input_statement
;
304 lang_target_statement_type target_statement
;
305 lang_output_statement_type output_statement
;
306 lang_input_section_type input_section
;
307 lang_common_statement_type common_statement
;
308 lang_object_symbols_statement_type object_symbols_statement
;
309 lang_fill_statement_type fill_statement
;
310 lang_padding_statement_type padding_statement
;
311 lang_group_statement_type group_statement
;
312 } lang_statement_union_type
;
314 /* This structure holds information about a program header, from the
315 PHDRS command in the linker script. */
318 struct lang_phdr
*next
;
327 /* This structure is used to hold a list of sections which may not
328 cross reference each other. */
330 struct lang_nocrossref
{
331 struct lang_nocrossref
*next
;
335 /* The list of nocrossref lists. */
337 struct lang_nocrossrefs
{
338 struct lang_nocrossrefs
*next
;
339 struct lang_nocrossref
*list
;
342 extern struct lang_nocrossrefs
*nocrossref_list
;
344 /* This structure is used to hold a list of input section names which
345 will not match an output section in the linker script. */
347 struct unique_sections
{
348 struct unique_sections
*next
;
352 extern struct unique_sections
*unique_section_list
;
354 extern lang_output_section_statement_type
*abs_output_section
;
355 extern lang_statement_list_type lang_output_section_statement
;
356 extern boolean lang_has_input_file
;
357 extern etree_type
*base
;
358 extern lang_statement_list_type
*stat_ptr
;
359 extern boolean delete_output_file_on_failure
;
361 extern const char *entry_symbol
;
362 extern boolean entry_from_cmdline
;
363 extern lang_statement_list_type file_chain
;
365 extern void lang_init
PARAMS ((void));
366 extern struct memory_region_struct
*lang_memory_region_lookup
367 PARAMS ((const char *const));
368 extern struct memory_region_struct
*lang_memory_region_default
369 PARAMS ((asection
*));
370 extern void lang_map
PARAMS ((void));
371 extern void lang_set_flags
PARAMS ((lang_memory_region_type
*, const char *,
373 extern void lang_add_output
PARAMS ((const char *, int from_script
));
374 extern lang_output_section_statement_type
*lang_enter_output_section_statement
375 PARAMS ((const char *output_section_statement_name
,
376 etree_type
* address_exp
,
377 enum section_type sectype
,
380 etree_type
*subalign
,
382 extern void lang_final
PARAMS ((void));
383 extern void lang_process
PARAMS ((void));
384 extern void lang_section_start
PARAMS ((const char *, union etree_union
*));
385 extern void lang_add_entry
PARAMS ((const char *, boolean
));
386 extern void lang_add_target
PARAMS ((const char *));
387 extern void lang_add_wild
388 PARAMS ((const char *, boolean
, const char *, boolean
, boolean
, name_list
*));
389 extern void lang_add_map
PARAMS ((const char *));
390 extern void lang_add_fill
PARAMS ((int));
391 extern lang_assignment_statement_type
* lang_add_assignment
PARAMS ((union etree_union
*));
392 extern void lang_add_attribute
PARAMS ((enum statement_enum
));
393 extern void lang_startup
PARAMS ((const char *));
394 extern void lang_float
PARAMS ((enum bfd_boolean
));
395 extern void lang_leave_output_section_statement
396 PARAMS ((bfd_vma
, const char *, struct lang_output_section_phdr_list
*,
398 extern void lang_abs_symbol_at_end_of
PARAMS ((const char *, const char *));
399 extern void lang_abs_symbol_at_beginning_of
PARAMS ((const char *,
401 extern void lang_statement_append
PARAMS ((struct statement_list
*,
402 union lang_statement_union
*,
403 union lang_statement_union
**));
404 extern void lang_for_each_input_file
405 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
406 extern void lang_for_each_file
407 PARAMS ((void (*dothis
) (lang_input_statement_type
*)));
408 extern bfd_vma lang_do_assignments
409 PARAMS ((lang_statement_union_type
* s
,
410 lang_output_section_statement_type
*output_section_statement
,
414 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
415 lang_input_statement_type *statement; \
416 for (statement = (lang_input_statement_type *)file_chain.head;\
417 statement != (lang_input_statement_type *)NULL; \
418 statement = (lang_input_statement_type *)statement->next)\
420 extern void lang_process PARAMS ((void));
421 extern void ldlang_add_file
PARAMS ((lang_input_statement_type
*));
422 extern lang_output_section_statement_type
*lang_output_section_find
423 PARAMS ((const char * const));
424 extern lang_input_statement_type
*lang_add_input_file
425 PARAMS ((const char *name
, lang_input_file_enum_type file_type
,
426 const char *target
));
427 extern void lang_add_keepsyms_file
PARAMS ((const char *filename
));
428 extern lang_output_section_statement_type
*
429 lang_output_section_statement_lookup
PARAMS ((const char * const name
));
430 extern void ldlang_add_undef
PARAMS ((const char *const name
));
431 extern void lang_add_output_format
PARAMS ((const char *, const char *,
432 const char *, int from_script
));
433 extern void lang_list_init
PARAMS ((lang_statement_list_type
*));
434 extern void lang_add_data
PARAMS ((int type
, union etree_union
*));
435 extern void lang_add_reloc
436 PARAMS ((bfd_reloc_code_real_type reloc
, reloc_howto_type
*howto
,
437 asection
*section
, const char *name
, union etree_union
*addend
));
438 extern void lang_for_each_statement
439 PARAMS ((void (*func
) (lang_statement_union_type
*)));
440 extern PTR stat_alloc
PARAMS ((size_t size
));
441 extern void dprint_statement
PARAMS ((lang_statement_union_type
*, int));
442 extern bfd_vma lang_size_sections
443 PARAMS ((lang_statement_union_type
*s
,
444 lang_output_section_statement_type
*output_section_statement
,
445 lang_statement_union_type
**prev
, fill_type fill
,
446 bfd_vma dot
, boolean relax
));
447 extern void lang_enter_group
PARAMS ((void));
448 extern void lang_leave_group
PARAMS ((void));
449 extern void wild_doit
450 PARAMS ((lang_statement_list_type
*ptr
, asection
*section
,
451 lang_output_section_statement_type
*output
,
452 lang_input_statement_type
*file
));
453 extern void lang_new_phdr
454 PARAMS ((const char *, etree_type
*, boolean
, boolean
, etree_type
*,
456 extern void lang_add_nocrossref
PARAMS ((struct lang_nocrossref
*));
457 extern void lang_enter_overlay
PARAMS ((etree_type
*, etree_type
*, int));
458 extern void lang_enter_overlay_section
PARAMS ((const char *));
459 extern void lang_leave_overlay_section
460 PARAMS ((bfd_vma
, struct lang_output_section_phdr_list
*));
461 extern void lang_leave_overlay
462 PARAMS ((bfd_vma
, const char *, struct lang_output_section_phdr_list
*,
465 extern struct bfd_elf_version_tree
*lang_elf_version_info
;
467 extern struct bfd_elf_version_expr
*lang_new_vers_regex
468 PARAMS ((struct bfd_elf_version_expr
*, const char *, const char *));
469 extern struct bfd_elf_version_tree
*lang_new_vers_node
470 PARAMS ((struct bfd_elf_version_expr
*, struct bfd_elf_version_expr
*));
471 extern struct bfd_elf_version_deps
*lang_add_vers_depend
472 PARAMS ((struct bfd_elf_version_deps
*, const char *));
473 extern void lang_register_vers_node
474 PARAMS ((const char *, struct bfd_elf_version_tree
*,
475 struct bfd_elf_version_deps
*));
476 boolean unique_section_p
PARAMS ((const char *));
477 extern void lang_add_unique
PARAMS ((const char *));