Fix initialisation of debug_line_pointer_sizes array so that it is done as needed
[binutils.git] / ld / ldlang.h
blob87318b0501c3acb60fe643896e9243352095fbe1
1 /* ldlang.h - linker command language support
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004
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)
11 any later version.
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
21 02111-1307, USA. */
23 #ifndef LDLANG_H
24 #define LDLANG_H
26 #define DEFAULT_MEMORY_REGION "*default*"
28 typedef enum {
29 lang_input_file_is_l_enum,
30 lang_input_file_is_symbols_only_enum,
31 lang_input_file_is_marker_enum,
32 lang_input_file_is_fake_enum,
33 lang_input_file_is_search_file_enum,
34 lang_input_file_is_file_enum
35 } lang_input_file_enum_type;
37 struct _fill_type {
38 size_t size;
39 unsigned char data[1];
42 typedef struct statement_list {
43 union lang_statement_union *head;
44 union lang_statement_union **tail;
45 } lang_statement_list_type;
47 typedef struct memory_region_struct {
48 char *name;
49 struct memory_region_struct *next;
50 bfd_vma origin;
51 bfd_size_type length;
52 bfd_vma current;
53 bfd_size_type old_length;
54 flagword flags;
55 flagword not_flags;
56 bfd_boolean had_full_message;
57 } lang_memory_region_type;
59 typedef struct lang_statement_header_struct {
60 union lang_statement_union *next;
61 enum statement_enum {
62 lang_output_section_statement_enum,
63 lang_assignment_statement_enum,
64 lang_input_statement_enum,
65 lang_address_statement_enum,
66 lang_wild_statement_enum,
67 lang_input_section_enum,
68 lang_object_symbols_statement_enum,
69 lang_fill_statement_enum,
70 lang_data_statement_enum,
71 lang_reloc_statement_enum,
72 lang_target_statement_enum,
73 lang_output_statement_enum,
74 lang_padding_statement_enum,
75 lang_group_statement_enum,
77 lang_afile_asection_pair_statement_enum,
78 lang_constructors_statement_enum
79 } type;
80 } lang_statement_header_type;
82 typedef struct {
83 lang_statement_header_type header;
84 union etree_union *exp;
85 } lang_assignment_statement_type;
87 typedef struct lang_target_statement_struct {
88 lang_statement_header_type header;
89 const char *target;
90 } lang_target_statement_type;
92 typedef struct lang_output_statement_struct {
93 lang_statement_header_type header;
94 const char *name;
95 } lang_output_statement_type;
97 /* Section types specified in a linker script. */
99 enum section_type {
100 normal_section,
101 dsect_section,
102 copy_section,
103 noload_section,
104 info_section,
105 overlay_section
108 /* This structure holds a list of program headers describing segments
109 in which this section should be placed. */
111 struct lang_output_section_phdr_list {
112 struct lang_output_section_phdr_list *next;
113 const char *name;
114 bfd_boolean used;
117 typedef struct lang_output_section_statement_struct {
118 lang_statement_header_type header;
119 union etree_union *addr_tree;
120 lang_statement_list_type children;
121 const char *memspec;
122 union lang_statement_union *next;
123 const char *name;
125 bfd_boolean processed;
127 asection *bfd_section;
128 flagword flags; /* Or together of all input sections */
129 enum section_type sectype;
130 struct memory_region_struct *region;
131 struct memory_region_struct *lma_region;
132 size_t block_value;
133 fill_type *fill;
135 int subsection_alignment; /* alignment of components */
136 int section_alignment; /* alignment of start of section */
138 union etree_union *load_base;
140 /* If non-null, an expression to evaluate after setting the section's
141 size. The expression is evaluated inside REGION (above) with '.'
142 set to the end of the section. Used in the last overlay section
143 to move '.' past all the overlaid sections. */
144 union etree_union *update_dot_tree;
146 struct lang_output_section_phdr_list *phdrs;
147 } lang_output_section_statement_type;
149 typedef struct {
150 lang_statement_header_type header;
151 } lang_common_statement_type;
153 typedef struct {
154 lang_statement_header_type header;
155 } lang_object_symbols_statement_type;
157 typedef struct {
158 lang_statement_header_type header;
159 fill_type *fill;
160 int size;
161 asection *output_section;
162 } lang_fill_statement_type;
164 typedef struct {
165 lang_statement_header_type header;
166 unsigned int type;
167 union etree_union *exp;
168 bfd_vma value;
169 asection *output_section;
170 bfd_vma output_vma;
171 } lang_data_statement_type;
173 /* Generate a reloc in the output file. */
175 typedef struct {
176 lang_statement_header_type header;
178 /* Reloc to generate. */
179 bfd_reloc_code_real_type reloc;
181 /* Reloc howto structure. */
182 reloc_howto_type *howto;
184 /* Section to generate reloc against. Exactly one of section and
185 name must be NULL. */
186 asection *section;
188 /* Name of symbol to generate reloc against. Exactly one of section
189 and name must be NULL. */
190 const char *name;
192 /* Expression for addend. */
193 union etree_union *addend_exp;
195 /* Resolved addend. */
196 bfd_vma addend_value;
198 /* Output section where reloc should be performed. */
199 asection *output_section;
201 /* VMA within output section. */
202 bfd_vma output_vma;
203 } lang_reloc_statement_type;
205 typedef struct lang_input_statement_struct {
206 lang_statement_header_type header;
207 /* Name of this file. */
208 const char *filename;
209 /* Name to use for the symbol giving address of text start */
210 /* Usually the same as filename, but for a file spec'd with -l
211 this is the -l switch itself rather than the filename. */
212 const char *local_sym_name;
214 bfd *the_bfd;
216 bfd_boolean closed;
217 file_ptr passive_position;
219 /* Symbol table of the file. */
220 asymbol **asymbols;
221 unsigned int symbol_count;
223 /* Point to the next file - whatever it is, wanders up and down
224 archives */
226 union lang_statement_union *next;
227 /* Point to the next file, but skips archive contents */
228 union lang_statement_union *next_real_file;
230 bfd_boolean is_archive;
232 /* 1 means search a set of directories for this file. */
233 bfd_boolean search_dirs_flag;
235 /* 1 means this was found in a search directory marked as sysrooted,
236 if search_dirs_flag is false, otherwise, that it should be
237 searched in ld_sysroot before any other location, as long as it
238 starts with a slash. */
239 bfd_boolean sysrooted;
241 /* 1 means this is base file of incremental load.
242 Do not load this file's text or data.
243 Also default text_start to after this file's bss. */
245 bfd_boolean just_syms_flag;
247 /* Whether to search for this entry as a dynamic archive. */
248 bfd_boolean dynamic;
250 /* Whether to include the entire contents of an archive. */
251 bfd_boolean whole_archive;
253 bfd_boolean loaded;
255 #if 0
256 unsigned int globals_in_this_file;
257 #endif
258 const char *target;
259 bfd_boolean real;
260 } lang_input_statement_type;
262 typedef struct {
263 lang_statement_header_type header;
264 asection *section;
265 lang_input_statement_type *ifile;
267 } lang_input_section_type;
269 typedef struct {
270 lang_statement_header_type header;
271 asection *section;
272 union lang_statement_union *file;
273 } lang_afile_asection_pair_statement_type;
275 typedef struct lang_wild_statement_struct {
276 lang_statement_header_type header;
277 const char *filename;
278 bfd_boolean filenames_sorted;
279 struct wildcard_list *section_list;
280 bfd_boolean keep_sections;
281 lang_statement_list_type children;
282 } lang_wild_statement_type;
284 typedef struct lang_address_statement_struct {
285 lang_statement_header_type header;
286 const char *section_name;
287 union etree_union *address;
288 } lang_address_statement_type;
290 typedef struct {
291 lang_statement_header_type header;
292 bfd_vma output_offset;
293 size_t size;
294 asection *output_section;
295 fill_type *fill;
296 } lang_padding_statement_type;
298 /* A group statement collects a set of libraries together. The
299 libraries are searched multiple times, until no new undefined
300 symbols are found. The effect is to search a group of libraries as
301 though they were a single library. */
303 typedef struct {
304 lang_statement_header_type header;
305 lang_statement_list_type children;
306 } lang_group_statement_type;
308 typedef union lang_statement_union {
309 lang_statement_header_type header;
310 lang_wild_statement_type wild_statement;
311 lang_data_statement_type data_statement;
312 lang_reloc_statement_type reloc_statement;
313 lang_address_statement_type address_statement;
314 lang_output_section_statement_type output_section_statement;
315 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
316 lang_assignment_statement_type assignment_statement;
317 lang_input_statement_type input_statement;
318 lang_target_statement_type target_statement;
319 lang_output_statement_type output_statement;
320 lang_input_section_type input_section;
321 lang_common_statement_type common_statement;
322 lang_object_symbols_statement_type object_symbols_statement;
323 lang_fill_statement_type fill_statement;
324 lang_padding_statement_type padding_statement;
325 lang_group_statement_type group_statement;
326 } lang_statement_union_type;
328 /* This structure holds information about a program header, from the
329 PHDRS command in the linker script. */
331 struct lang_phdr {
332 struct lang_phdr *next;
333 const char *name;
334 unsigned long type;
335 bfd_boolean filehdr;
336 bfd_boolean phdrs;
337 etree_type *at;
338 etree_type *flags;
341 /* This structure is used to hold a list of sections which may not
342 cross reference each other. */
344 struct lang_nocrossref {
345 struct lang_nocrossref *next;
346 const char *name;
349 /* The list of nocrossref lists. */
351 struct lang_nocrossrefs {
352 struct lang_nocrossrefs *next;
353 struct lang_nocrossref *list;
356 extern struct lang_nocrossrefs *nocrossref_list;
358 /* This structure is used to hold a list of input section names which
359 will not match an output section in the linker script. */
361 struct unique_sections {
362 struct unique_sections *next;
363 const char *name;
366 /* This structure records symbols for which we need to keep track of
367 definedness for use in the DEFINED () test. */
369 struct lang_definedness_hash_entry {
370 struct bfd_hash_entry root;
371 int iteration;
374 extern struct unique_sections *unique_section_list;
376 extern lang_output_section_statement_type *abs_output_section;
377 extern lang_statement_list_type lang_output_section_statement;
378 extern bfd_boolean lang_has_input_file;
379 extern etree_type *base;
380 extern lang_statement_list_type *stat_ptr;
381 extern bfd_boolean delete_output_file_on_failure;
383 extern struct bfd_sym_chain entry_symbol;
384 extern const char *entry_section;
385 extern bfd_boolean entry_from_cmdline;
386 extern lang_statement_list_type file_chain;
388 extern int lang_statement_iteration;
390 extern void lang_init
391 (void);
392 extern struct memory_region_struct *lang_memory_region_lookup
393 (const char *const, bfd_boolean);
394 extern struct memory_region_struct *lang_memory_region_default
395 (asection *);
396 extern void lang_map
397 (void);
398 extern void lang_set_flags
399 (lang_memory_region_type *, const char *, int);
400 extern void lang_add_output
401 (const char *, int from_script);
402 extern lang_output_section_statement_type *lang_enter_output_section_statement
403 (const char *output_section_statement_name,
404 etree_type *address_exp,
405 enum section_type sectype,
406 etree_type *align,
407 etree_type *subalign,
408 etree_type *);
409 extern void lang_final
410 (void);
411 extern void lang_process
412 (void);
413 extern void lang_section_start
414 (const char *, union etree_union *);
415 extern void lang_add_entry
416 (const char *, bfd_boolean);
417 extern void lang_add_target
418 (const char *);
419 extern void lang_add_wild
420 (struct wildcard_spec *, struct wildcard_list *, bfd_boolean);
421 extern void lang_add_map
422 (const char *);
423 extern void lang_add_fill
424 (fill_type *);
425 extern lang_assignment_statement_type *lang_add_assignment
426 (union etree_union *);
427 extern void lang_add_attribute
428 (enum statement_enum);
429 extern void lang_startup
430 (const char *);
431 extern void lang_float
432 (bfd_boolean);
433 extern void lang_leave_output_section_statement
434 (fill_type *, const char *, struct lang_output_section_phdr_list *,
435 const char *);
436 extern void lang_abs_symbol_at_end_of
437 (const char *, const char *);
438 extern void lang_abs_symbol_at_beginning_of
439 (const char *, const char *);
440 extern void lang_statement_append
441 (struct statement_list *, union lang_statement_union *,
442 union lang_statement_union **);
443 extern void lang_for_each_input_file
444 (void (*dothis) (lang_input_statement_type *));
445 extern void lang_for_each_file
446 (void (*dothis) (lang_input_statement_type *));
447 extern void lang_reset_memory_regions
448 (void);
449 extern void lang_do_assignments
450 (lang_statement_union_type *, lang_output_section_statement_type *,
451 fill_type *, bfd_vma);
453 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
454 lang_input_statement_type *statement; \
455 for (statement = (lang_input_statement_type *) file_chain.head; \
456 statement != (lang_input_statement_type *) NULL; \
457 statement = (lang_input_statement_type *) statement->next) \
459 extern void lang_process
460 (void);
461 extern void ldlang_add_file
462 (lang_input_statement_type *);
463 extern lang_output_section_statement_type *lang_output_section_find
464 (const char * const);
465 extern lang_input_statement_type *lang_add_input_file
466 (const char *, lang_input_file_enum_type, const char *);
467 extern void lang_add_keepsyms_file
468 (const char *);
469 extern lang_output_section_statement_type *
470 lang_output_section_statement_lookup
471 (const char *const);
472 extern void ldlang_add_undef
473 (const char *const);
474 extern void lang_add_output_format
475 (const char *, const char *, const char *, int);
476 extern void lang_list_init
477 (lang_statement_list_type *);
478 extern void lang_add_data
479 (int type, union etree_union *);
480 extern void lang_add_reloc
481 (bfd_reloc_code_real_type, reloc_howto_type *, asection *, const char *,
482 union etree_union *);
483 extern void lang_for_each_statement
484 (void (*) (lang_statement_union_type *));
485 extern void *stat_alloc
486 (size_t);
487 extern void dprint_statement
488 (lang_statement_union_type *, int);
489 extern bfd_vma lang_size_sections
490 (lang_statement_union_type *, lang_output_section_statement_type *,
491 lang_statement_union_type **, fill_type *, bfd_vma, bfd_boolean *,
492 bfd_boolean);
493 extern void lang_enter_group
494 (void);
495 extern void lang_leave_group
496 (void);
497 extern void lang_add_section
498 (lang_statement_list_type *, asection *,
499 lang_output_section_statement_type *, lang_input_statement_type *);
500 extern void lang_new_phdr
501 (const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
502 etree_type *);
503 extern void lang_add_nocrossref
504 (struct lang_nocrossref *);
505 extern void lang_enter_overlay
506 (etree_type *, etree_type *);
507 extern void lang_enter_overlay_section
508 (const char *);
509 extern void lang_leave_overlay_section
510 (fill_type *, struct lang_output_section_phdr_list *);
511 extern void lang_leave_overlay
512 (etree_type *, int, fill_type *, const char *,
513 struct lang_output_section_phdr_list *, const char *);
515 extern struct bfd_elf_version_tree *lang_elf_version_info;
517 extern struct bfd_elf_version_expr *lang_new_vers_pattern
518 (struct bfd_elf_version_expr *, const char *, const char *);
519 extern struct bfd_elf_version_tree *lang_new_vers_node
520 (struct bfd_elf_version_expr *, struct bfd_elf_version_expr *);
521 extern struct bfd_elf_version_deps *lang_add_vers_depend
522 (struct bfd_elf_version_deps *, const char *);
523 extern void lang_register_vers_node
524 (const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
525 bfd_boolean unique_section_p
526 (const char *);
527 extern void lang_add_unique
528 (const char *);
529 extern const char *lang_get_output_target
530 (void);
531 extern void lang_track_definedness (const char *);
532 extern int lang_symbol_definition_iteration (const char *);
533 extern void lang_update_definedness
534 (const char *, struct bfd_link_hash_entry *);
536 #endif