If dot is advanced, then assume that the section should be allocated.
[deliverable/binutils-gdb.git] / ld / ldlang.h
CommitLineData
252b5132 1/* ldlang.h - linker command language support
a2b64bed 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
e5caa5e0 3 2001, 2002, 2003, 2004
aa8804e4 4 Free Software Foundation, Inc.
5cc18311 5
252b5132 6 This file is part of GLD, the Gnu Linker.
5cc18311 7
252b5132
RH
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
e3dc8847 10 the Free Software Foundation; either version 2, or (at your option)
252b5132 11 any later version.
5cc18311 12
252b5132
RH
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.
5cc18311 17
252b5132
RH
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. */
22
23#ifndef LDLANG_H
24#define LDLANG_H
25
a747ee4d
NC
26#define DEFAULT_MEMORY_REGION "*default*"
27
89cdebba 28typedef enum {
252b5132
RH
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;
36
2c382fb6
AM
37struct _fill_type {
38 size_t size;
39 unsigned char data[1];
40};
89cdebba
KH
41
42typedef struct statement_list {
252b5132
RH
43 union lang_statement_union *head;
44 union lang_statement_union **tail;
45} lang_statement_list_type;
46
89cdebba 47typedef struct memory_region_struct {
252b5132
RH
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;
b34976b6 56 bfd_boolean had_full_message;
89cdebba
KH
57} lang_memory_region_type;
58
59typedef 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,
76
77 lang_afile_asection_pair_statement_enum,
78 lang_constructors_statement_enum
79 } type;
252b5132
RH
80} lang_statement_header_type;
81
89cdebba 82typedef struct {
252b5132
RH
83 lang_statement_header_type header;
84 union etree_union *exp;
85} lang_assignment_statement_type;
86
89cdebba 87typedef struct lang_target_statement_struct {
252b5132
RH
88 lang_statement_header_type header;
89 const char *target;
90} lang_target_statement_type;
91
89cdebba 92typedef struct lang_output_statement_struct {
252b5132
RH
93 lang_statement_header_type header;
94 const char *name;
95} lang_output_statement_type;
96
97/* Section types specified in a linker script. */
98
89cdebba 99enum section_type {
252b5132
RH
100 normal_section,
101 dsect_section,
102 copy_section,
103 noload_section,
104 info_section,
105 overlay_section
106};
107
108/* This structure holds a list of program headers describing segments
109 in which this section should be placed. */
110
89cdebba 111struct lang_output_section_phdr_list {
252b5132
RH
112 struct lang_output_section_phdr_list *next;
113 const char *name;
b34976b6 114 bfd_boolean used;
252b5132
RH
115};
116
89cdebba 117typedef struct lang_output_section_statement_struct {
252b5132
RH
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;
124
b34976b6 125 bfd_boolean processed;
5cc18311 126
252b5132
RH
127 asection *bfd_section;
128 flagword flags; /* Or together of all input sections */
129 enum section_type sectype;
130 struct memory_region_struct *region;
562d3460 131 struct memory_region_struct *lma_region;
252b5132 132 size_t block_value;
2c382fb6 133 fill_type *fill;
252b5132 134
89cdebba
KH
135 int subsection_alignment; /* alignment of components */
136 int section_alignment; /* alignment of start of section */
252b5132
RH
137
138 union etree_union *load_base;
139
9f88b410
RS
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;
145
252b5132
RH
146 struct lang_output_section_phdr_list *phdrs;
147} lang_output_section_statement_type;
148
89cdebba 149typedef struct {
252b5132
RH
150 lang_statement_header_type header;
151} lang_common_statement_type;
152
89cdebba 153typedef struct {
252b5132
RH
154 lang_statement_header_type header;
155} lang_object_symbols_statement_type;
156
89cdebba 157typedef struct {
252b5132 158 lang_statement_header_type header;
2c382fb6 159 fill_type *fill;
252b5132
RH
160 int size;
161 asection *output_section;
162} lang_fill_statement_type;
163
89cdebba 164typedef struct {
252b5132
RH
165 lang_statement_header_type header;
166 unsigned int type;
89cdebba 167 union etree_union *exp;
252b5132
RH
168 bfd_vma value;
169 asection *output_section;
170 bfd_vma output_vma;
171} lang_data_statement_type;
172
173/* Generate a reloc in the output file. */
174
89cdebba 175typedef struct {
252b5132
RH
176 lang_statement_header_type header;
177
178 /* Reloc to generate. */
179 bfd_reloc_code_real_type reloc;
180
181 /* Reloc howto structure. */
182 reloc_howto_type *howto;
183
184 /* Section to generate reloc against. Exactly one of section and
185 name must be NULL. */
186 asection *section;
187
188 /* Name of symbol to generate reloc against. Exactly one of section
189 and name must be NULL. */
190 const char *name;
191
192 /* Expression for addend. */
193 union etree_union *addend_exp;
194
195 /* Resolved addend. */
196 bfd_vma addend_value;
197
198 /* Output section where reloc should be performed. */
199 asection *output_section;
200
201 /* VMA within output section. */
202 bfd_vma output_vma;
203} lang_reloc_statement_type;
204
89cdebba 205typedef struct lang_input_statement_struct {
252b5132
RH
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;
5cc18311 213
252b5132 214 bfd *the_bfd;
5cc18311 215
b34976b6 216 bfd_boolean closed;
252b5132 217 file_ptr passive_position;
5cc18311 218
252b5132
RH
219 /* Symbol table of the file. */
220 asymbol **asymbols;
221 unsigned int symbol_count;
5cc18311 222
252b5132
RH
223 /* Point to the next file - whatever it is, wanders up and down
224 archives */
5cc18311 225
89cdebba 226 union lang_statement_union *next;
252b5132 227 /* Point to the next file, but skips archive contents */
89cdebba 228 union lang_statement_union *next_real_file;
5cc18311 229
b34976b6 230 bfd_boolean is_archive;
5cc18311 231
252b5132 232 /* 1 means search a set of directories for this file. */
b34976b6 233 bfd_boolean search_dirs_flag;
5cc18311 234
e3f2db7f
AO
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;
240
252b5132
RH
241 /* 1 means this is base file of incremental load.
242 Do not load this file's text or data.
5cc18311
KH
243 Also default text_start to after this file's bss. */
244
b34976b6 245 bfd_boolean just_syms_flag;
252b5132
RH
246
247 /* Whether to search for this entry as a dynamic archive. */
b34976b6 248 bfd_boolean dynamic;
252b5132
RH
249
250 /* Whether to include the entire contents of an archive. */
b34976b6 251 bfd_boolean whole_archive;
252b5132 252
b34976b6 253 bfd_boolean loaded;
5cc18311 254
89cdebba
KH
255#if 0
256 unsigned int globals_in_this_file;
257#endif
252b5132 258 const char *target;
b34976b6 259 bfd_boolean real;
252b5132
RH
260} lang_input_statement_type;
261
89cdebba 262typedef struct {
252b5132
RH
263 lang_statement_header_type header;
264 asection *section;
265 lang_input_statement_type *ifile;
252b5132 266
5cc18311 267} lang_input_section_type;
252b5132 268
89cdebba 269typedef struct {
252b5132
RH
270 lang_statement_header_type header;
271 asection *section;
272 union lang_statement_union *file;
273} lang_afile_asection_pair_statement_type;
274
89cdebba 275typedef struct lang_wild_statement_struct {
252b5132 276 lang_statement_header_type header;
252b5132 277 const char *filename;
b34976b6 278 bfd_boolean filenames_sorted;
b6bf44ba 279 struct wildcard_list *section_list;
b34976b6 280 bfd_boolean keep_sections;
252b5132
RH
281 lang_statement_list_type children;
282} lang_wild_statement_type;
283
89cdebba 284typedef struct lang_address_statement_struct {
252b5132 285 lang_statement_header_type header;
89cdebba
KH
286 const char *section_name;
287 union etree_union *address;
252b5132
RH
288} lang_address_statement_type;
289
89cdebba 290typedef struct {
252b5132
RH
291 lang_statement_header_type header;
292 bfd_vma output_offset;
293 size_t size;
294 asection *output_section;
2c382fb6 295 fill_type *fill;
252b5132
RH
296} lang_padding_statement_type;
297
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. */
302
89cdebba 303typedef struct {
252b5132
RH
304 lang_statement_header_type header;
305 lang_statement_list_type children;
306} lang_group_statement_type;
307
89cdebba 308typedef union lang_statement_union {
252b5132 309 lang_statement_header_type header;
252b5132
RH
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;
327
328/* This structure holds information about a program header, from the
329 PHDRS command in the linker script. */
330
89cdebba 331struct lang_phdr {
252b5132
RH
332 struct lang_phdr *next;
333 const char *name;
334 unsigned long type;
b34976b6
AM
335 bfd_boolean filehdr;
336 bfd_boolean phdrs;
252b5132
RH
337 etree_type *at;
338 etree_type *flags;
339};
340
341/* This structure is used to hold a list of sections which may not
342 cross reference each other. */
343
89cdebba 344struct lang_nocrossref {
252b5132
RH
345 struct lang_nocrossref *next;
346 const char *name;
347};
348
349/* The list of nocrossref lists. */
350
89cdebba 351struct lang_nocrossrefs {
252b5132
RH
352 struct lang_nocrossrefs *next;
353 struct lang_nocrossref *list;
354};
355
356extern struct lang_nocrossrefs *nocrossref_list;
357
577a0623
AM
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. */
360
361struct unique_sections {
362 struct unique_sections *next;
363 const char *name;
364};
365
420e579c
HPN
366/* This structure records symbols for which we need to keep track of
367 definedness for use in the DEFINED () test. */
368
369struct lang_definedness_hash_entry {
370 struct bfd_hash_entry root;
371 int iteration;
372};
373
577a0623
AM
374extern struct unique_sections *unique_section_list;
375
252b5132 376extern lang_output_section_statement_type *abs_output_section;
aea4bd9d 377extern lang_statement_list_type lang_output_section_statement;
b34976b6 378extern bfd_boolean lang_has_input_file;
252b5132
RH
379extern etree_type *base;
380extern lang_statement_list_type *stat_ptr;
b34976b6 381extern bfd_boolean delete_output_file_on_failure;
252b5132 382
e3e942e9 383extern struct bfd_sym_chain entry_symbol;
1e281515 384extern const char *entry_section;
b34976b6 385extern bfd_boolean entry_from_cmdline;
b71e2778 386extern lang_statement_list_type file_chain;
252b5132 387
420e579c
HPN
388extern int lang_statement_iteration;
389
f53154de 390extern void lang_init
1579bae1 391 (void);
252b5132 392extern struct memory_region_struct *lang_memory_region_lookup
a747ee4d 393 (const char *const, bfd_boolean);
252b5132 394extern struct memory_region_struct *lang_memory_region_default
1579bae1 395 (asection *);
f53154de 396extern void lang_map
1579bae1 397 (void);
f53154de 398extern void lang_set_flags
1579bae1 399 (lang_memory_region_type *, const char *, int);
f53154de 400extern void lang_add_output
1579bae1 401 (const char *, int from_script);
aea4bd9d 402extern lang_output_section_statement_type *lang_enter_output_section_statement
1579bae1
AM
403 (const char *output_section_statement_name,
404 etree_type *address_exp,
405 enum section_type sectype,
1579bae1
AM
406 etree_type *align,
407 etree_type *subalign,
408 etree_type *);
f53154de 409extern void lang_final
1579bae1 410 (void);
f53154de 411extern void lang_process
1579bae1 412 (void);
f53154de 413extern void lang_section_start
1579bae1 414 (const char *, union etree_union *);
f53154de 415extern void lang_add_entry
1579bae1 416 (const char *, bfd_boolean);
f53154de 417extern void lang_add_target
1579bae1 418 (const char *);
252b5132 419extern void lang_add_wild
1579bae1 420 (struct wildcard_spec *, struct wildcard_list *, bfd_boolean);
f53154de 421extern void lang_add_map
1579bae1 422 (const char *);
f53154de 423extern void lang_add_fill
1579bae1
AM
424 (fill_type *);
425extern lang_assignment_statement_type *lang_add_assignment
426 (union etree_union *);
f53154de 427extern void lang_add_attribute
1579bae1 428 (enum statement_enum);
f53154de 429extern void lang_startup
1579bae1 430 (const char *);
f53154de 431extern void lang_float
1579bae1 432 (bfd_boolean);
252b5132 433extern void lang_leave_output_section_statement
1579bae1
AM
434 (fill_type *, const char *, struct lang_output_section_phdr_list *,
435 const char *);
f53154de 436extern void lang_abs_symbol_at_end_of
1579bae1 437 (const char *, const char *);
f53154de 438extern void lang_abs_symbol_at_beginning_of
1579bae1 439 (const char *, const char *);
f53154de 440extern void lang_statement_append
1579bae1
AM
441 (struct statement_list *, union lang_statement_union *,
442 union lang_statement_union **);
252b5132 443extern void lang_for_each_input_file
1579bae1 444 (void (*dothis) (lang_input_statement_type *));
252b5132 445extern void lang_for_each_file
1579bae1 446 (void (*dothis) (lang_input_statement_type *));
f53154de 447extern void lang_reset_memory_regions
1579bae1 448 (void);
f2241121 449extern void lang_do_assignments
1579bae1
AM
450 (lang_statement_union_type *, lang_output_section_statement_type *,
451 fill_type *, bfd_vma);
252b5132 452
f53154de
AM
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) \
5cc18311 458
f53154de 459extern void lang_process
1579bae1 460 (void);
f53154de 461extern void ldlang_add_file
1579bae1 462 (lang_input_statement_type *);
252b5132 463extern lang_output_section_statement_type *lang_output_section_find
1579bae1 464 (const char * const);
252b5132 465extern lang_input_statement_type *lang_add_input_file
1579bae1 466 (const char *, lang_input_file_enum_type, const char *);
f53154de 467extern void lang_add_keepsyms_file
1579bae1 468 (const char *);
252b5132 469extern lang_output_section_statement_type *
f53154de 470 lang_output_section_statement_lookup
1579bae1 471 (const char *const);
f53154de 472extern void ldlang_add_undef
1579bae1 473 (const char *const);
f53154de 474extern void lang_add_output_format
1579bae1 475 (const char *, const char *, const char *, int);
f53154de 476extern void lang_list_init
1579bae1 477 (lang_statement_list_type *);
f53154de 478extern void lang_add_data
1579bae1 479 (int type, union etree_union *);
252b5132 480extern void lang_add_reloc
1579bae1
AM
481 (bfd_reloc_code_real_type, reloc_howto_type *, asection *, const char *,
482 union etree_union *);
252b5132 483extern void lang_for_each_statement
1579bae1
AM
484 (void (*) (lang_statement_union_type *));
485extern void *stat_alloc
486 (size_t);
f53154de 487extern void dprint_statement
1579bae1 488 (lang_statement_union_type *, int);
252b5132 489extern bfd_vma lang_size_sections
1579bae1
AM
490 (lang_statement_union_type *, lang_output_section_statement_type *,
491 lang_statement_union_type **, fill_type *, bfd_vma, bfd_boolean *,
492 bfd_boolean);
f53154de 493extern void lang_enter_group
1579bae1 494 (void);
f53154de 495extern void lang_leave_group
1579bae1 496 (void);
39dcfe18 497extern void lang_add_section
1579bae1
AM
498 (lang_statement_list_type *, asection *,
499 lang_output_section_statement_type *, lang_input_statement_type *);
252b5132 500extern void lang_new_phdr
1579bae1
AM
501 (const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
502 etree_type *);
f53154de 503extern void lang_add_nocrossref
1579bae1 504 (struct lang_nocrossref *);
f53154de 505extern void lang_enter_overlay
7e7d5768 506 (etree_type *, etree_type *);
f53154de 507extern void lang_enter_overlay_section
1579bae1 508 (const char *);
252b5132 509extern void lang_leave_overlay_section
1579bae1 510 (fill_type *, struct lang_output_section_phdr_list *);
252b5132 511extern void lang_leave_overlay
1579bae1
AM
512 (etree_type *, int, fill_type *, const char *,
513 struct lang_output_section_phdr_list *, const char *);
252b5132
RH
514
515extern struct bfd_elf_version_tree *lang_elf_version_info;
516
313e35ee 517extern struct bfd_elf_version_expr *lang_new_vers_pattern
1579bae1 518 (struct bfd_elf_version_expr *, const char *, const char *);
252b5132 519extern struct bfd_elf_version_tree *lang_new_vers_node
1579bae1 520 (struct bfd_elf_version_expr *, struct bfd_elf_version_expr *);
252b5132 521extern struct bfd_elf_version_deps *lang_add_vers_depend
1579bae1 522 (struct bfd_elf_version_deps *, const char *);
252b5132 523extern void lang_register_vers_node
1579bae1 524 (const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
f53154de 525bfd_boolean unique_section_p
1579bae1 526 (const char *);
f53154de 527extern void lang_add_unique
1579bae1 528 (const char *);
f53154de 529extern const char *lang_get_output_target
1579bae1 530 (void);
420e579c
HPN
531extern void lang_track_definedness (const char *);
532extern int lang_symbol_definition_iteration (const char *);
533extern void lang_update_definedness
534 (const char *, struct bfd_link_hash_entry *);
252b5132
RH
535
536#endif
This page took 0.216379 seconds and 4 git commands to generate.