Disable region size checking whilst relaxing sections.
[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,
cf888e70 3 2001, 2002, 2003
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
89cdebba 26typedef enum {
252b5132
RH
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;
34
2c382fb6
AM
35struct _fill_type {
36 size_t size;
37 unsigned char data[1];
38};
89cdebba
KH
39
40typedef struct statement_list {
252b5132
RH
41 union lang_statement_union *head;
42 union lang_statement_union **tail;
43} lang_statement_list_type;
44
89cdebba 45typedef struct memory_region_struct {
252b5132
RH
46 char *name;
47 struct memory_region_struct *next;
48 bfd_vma origin;
49 bfd_size_type length;
50 bfd_vma current;
51 bfd_size_type old_length;
52 flagword flags;
53 flagword not_flags;
b34976b6 54 bfd_boolean had_full_message;
89cdebba
KH
55} lang_memory_region_type;
56
57typedef struct lang_statement_header_struct {
58 union lang_statement_union *next;
59 enum statement_enum {
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,
74
75 lang_afile_asection_pair_statement_enum,
76 lang_constructors_statement_enum
77 } type;
252b5132
RH
78} lang_statement_header_type;
79
89cdebba 80typedef struct {
252b5132
RH
81 lang_statement_header_type header;
82 union etree_union *exp;
83} lang_assignment_statement_type;
84
89cdebba 85typedef struct lang_target_statement_struct {
252b5132
RH
86 lang_statement_header_type header;
87 const char *target;
88} lang_target_statement_type;
89
89cdebba 90typedef struct lang_output_statement_struct {
252b5132
RH
91 lang_statement_header_type header;
92 const char *name;
93} lang_output_statement_type;
94
95/* Section types specified in a linker script. */
96
89cdebba 97enum section_type {
252b5132
RH
98 normal_section,
99 dsect_section,
100 copy_section,
101 noload_section,
102 info_section,
103 overlay_section
104};
105
106/* This structure holds a list of program headers describing segments
107 in which this section should be placed. */
108
89cdebba 109struct lang_output_section_phdr_list {
252b5132
RH
110 struct lang_output_section_phdr_list *next;
111 const char *name;
b34976b6 112 bfd_boolean used;
252b5132
RH
113};
114
89cdebba 115typedef struct lang_output_section_statement_struct {
252b5132
RH
116 lang_statement_header_type header;
117 union etree_union *addr_tree;
118 lang_statement_list_type children;
119 const char *memspec;
120 union lang_statement_union *next;
121 const char *name;
122
b34976b6 123 bfd_boolean processed;
5cc18311 124
252b5132
RH
125 asection *bfd_section;
126 flagword flags; /* Or together of all input sections */
127 enum section_type sectype;
128 struct memory_region_struct *region;
562d3460 129 struct memory_region_struct *lma_region;
252b5132 130 size_t block_value;
2c382fb6 131 fill_type *fill;
252b5132 132
89cdebba
KH
133 int subsection_alignment; /* alignment of components */
134 int section_alignment; /* alignment of start of section */
252b5132
RH
135
136 union etree_union *load_base;
137
9f88b410
RS
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;
143
252b5132
RH
144 struct lang_output_section_phdr_list *phdrs;
145} lang_output_section_statement_type;
146
89cdebba 147typedef struct {
252b5132
RH
148 lang_statement_header_type header;
149} lang_common_statement_type;
150
89cdebba 151typedef struct {
252b5132
RH
152 lang_statement_header_type header;
153} lang_object_symbols_statement_type;
154
89cdebba 155typedef struct {
252b5132 156 lang_statement_header_type header;
2c382fb6 157 fill_type *fill;
252b5132
RH
158 int size;
159 asection *output_section;
160} lang_fill_statement_type;
161
89cdebba 162typedef struct {
252b5132
RH
163 lang_statement_header_type header;
164 unsigned int type;
89cdebba 165 union etree_union *exp;
252b5132
RH
166 bfd_vma value;
167 asection *output_section;
168 bfd_vma output_vma;
169} lang_data_statement_type;
170
171/* Generate a reloc in the output file. */
172
89cdebba 173typedef struct {
252b5132
RH
174 lang_statement_header_type header;
175
176 /* Reloc to generate. */
177 bfd_reloc_code_real_type reloc;
178
179 /* Reloc howto structure. */
180 reloc_howto_type *howto;
181
182 /* Section to generate reloc against. Exactly one of section and
183 name must be NULL. */
184 asection *section;
185
186 /* Name of symbol to generate reloc against. Exactly one of section
187 and name must be NULL. */
188 const char *name;
189
190 /* Expression for addend. */
191 union etree_union *addend_exp;
192
193 /* Resolved addend. */
194 bfd_vma addend_value;
195
196 /* Output section where reloc should be performed. */
197 asection *output_section;
198
199 /* VMA within output section. */
200 bfd_vma output_vma;
201} lang_reloc_statement_type;
202
89cdebba 203typedef struct lang_input_statement_struct {
252b5132
RH
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;
5cc18311 211
252b5132 212 bfd *the_bfd;
5cc18311 213
b34976b6 214 bfd_boolean closed;
252b5132 215 file_ptr passive_position;
5cc18311 216
252b5132
RH
217 /* Symbol table of the file. */
218 asymbol **asymbols;
219 unsigned int symbol_count;
5cc18311 220
252b5132
RH
221 /* Point to the next file - whatever it is, wanders up and down
222 archives */
5cc18311 223
89cdebba 224 union lang_statement_union *next;
252b5132 225 /* Point to the next file, but skips archive contents */
89cdebba 226 union lang_statement_union *next_real_file;
5cc18311 227
b34976b6 228 bfd_boolean is_archive;
5cc18311 229
252b5132 230 /* 1 means search a set of directories for this file. */
b34976b6 231 bfd_boolean search_dirs_flag;
5cc18311 232
252b5132
RH
233 /* 1 means this is base file of incremental load.
234 Do not load this file's text or data.
5cc18311
KH
235 Also default text_start to after this file's bss. */
236
b34976b6 237 bfd_boolean just_syms_flag;
252b5132
RH
238
239 /* Whether to search for this entry as a dynamic archive. */
b34976b6 240 bfd_boolean dynamic;
252b5132
RH
241
242 /* Whether to include the entire contents of an archive. */
b34976b6 243 bfd_boolean whole_archive;
252b5132 244
b34976b6 245 bfd_boolean loaded;
5cc18311 246
89cdebba
KH
247#if 0
248 unsigned int globals_in_this_file;
249#endif
252b5132 250 const char *target;
b34976b6 251 bfd_boolean real;
252b5132
RH
252} lang_input_statement_type;
253
89cdebba 254typedef struct {
252b5132
RH
255 lang_statement_header_type header;
256 asection *section;
257 lang_input_statement_type *ifile;
252b5132 258
5cc18311 259} lang_input_section_type;
252b5132 260
89cdebba 261typedef struct {
252b5132
RH
262 lang_statement_header_type header;
263 asection *section;
264 union lang_statement_union *file;
265} lang_afile_asection_pair_statement_type;
266
89cdebba 267typedef struct lang_wild_statement_struct {
252b5132 268 lang_statement_header_type header;
252b5132 269 const char *filename;
b34976b6 270 bfd_boolean filenames_sorted;
b6bf44ba 271 struct wildcard_list *section_list;
b34976b6 272 bfd_boolean keep_sections;
252b5132
RH
273 lang_statement_list_type children;
274} lang_wild_statement_type;
275
89cdebba 276typedef struct lang_address_statement_struct {
252b5132 277 lang_statement_header_type header;
89cdebba
KH
278 const char *section_name;
279 union etree_union *address;
252b5132
RH
280} lang_address_statement_type;
281
89cdebba 282typedef struct {
252b5132
RH
283 lang_statement_header_type header;
284 bfd_vma output_offset;
285 size_t size;
286 asection *output_section;
2c382fb6 287 fill_type *fill;
252b5132
RH
288} lang_padding_statement_type;
289
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. */
294
89cdebba 295typedef struct {
252b5132
RH
296 lang_statement_header_type header;
297 lang_statement_list_type children;
298} lang_group_statement_type;
299
89cdebba 300typedef union lang_statement_union {
252b5132 301 lang_statement_header_type header;
252b5132
RH
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;
319
320/* This structure holds information about a program header, from the
321 PHDRS command in the linker script. */
322
89cdebba 323struct lang_phdr {
252b5132
RH
324 struct lang_phdr *next;
325 const char *name;
326 unsigned long type;
b34976b6
AM
327 bfd_boolean filehdr;
328 bfd_boolean phdrs;
252b5132
RH
329 etree_type *at;
330 etree_type *flags;
331};
332
333/* This structure is used to hold a list of sections which may not
334 cross reference each other. */
335
89cdebba 336struct lang_nocrossref {
252b5132
RH
337 struct lang_nocrossref *next;
338 const char *name;
339};
340
341/* The list of nocrossref lists. */
342
89cdebba 343struct lang_nocrossrefs {
252b5132
RH
344 struct lang_nocrossrefs *next;
345 struct lang_nocrossref *list;
346};
347
348extern struct lang_nocrossrefs *nocrossref_list;
349
577a0623
AM
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. */
352
353struct unique_sections {
354 struct unique_sections *next;
355 const char *name;
356};
357
358extern struct unique_sections *unique_section_list;
359
252b5132 360extern lang_output_section_statement_type *abs_output_section;
aea4bd9d 361extern lang_statement_list_type lang_output_section_statement;
b34976b6 362extern bfd_boolean lang_has_input_file;
252b5132
RH
363extern etree_type *base;
364extern lang_statement_list_type *stat_ptr;
b34976b6 365extern bfd_boolean delete_output_file_on_failure;
252b5132 366
e3e942e9 367extern struct bfd_sym_chain entry_symbol;
1e281515 368extern const char *entry_section;
b34976b6 369extern bfd_boolean entry_from_cmdline;
b71e2778 370extern lang_statement_list_type file_chain;
252b5132 371
f53154de
AM
372extern void lang_init
373 PARAMS ((void));
252b5132
RH
374extern struct memory_region_struct *lang_memory_region_lookup
375 PARAMS ((const char *const));
376extern struct memory_region_struct *lang_memory_region_default
377 PARAMS ((asection *));
f53154de
AM
378extern void lang_map
379 PARAMS ((void));
380extern void lang_set_flags
381 PARAMS ((lang_memory_region_type *, const char *, int));
382extern void lang_add_output
383 PARAMS ((const char *, int from_script));
aea4bd9d 384extern lang_output_section_statement_type *lang_enter_output_section_statement
252b5132 385 PARAMS ((const char *output_section_statement_name,
f53154de 386 etree_type *address_exp,
252b5132
RH
387 enum section_type sectype,
388 bfd_vma block_value,
389 etree_type *align,
390 etree_type *subalign,
391 etree_type *));
f53154de
AM
392extern void lang_final
393 PARAMS ((void));
394extern void lang_process
395 PARAMS ((void));
396extern void lang_section_start
397 PARAMS ((const char *, union etree_union *));
398extern void lang_add_entry
399 PARAMS ((const char *, bfd_boolean));
400extern void lang_add_target
401 PARAMS ((const char *));
252b5132 402extern void lang_add_wild
b34976b6 403 PARAMS ((struct wildcard_spec *, struct wildcard_list *, bfd_boolean));
f53154de
AM
404extern void lang_add_map
405 PARAMS ((const char *));
406extern void lang_add_fill
407 PARAMS ((fill_type *));
408extern lang_assignment_statement_type * lang_add_assignment
409 PARAMS ((union etree_union *));
410extern void lang_add_attribute
411 PARAMS ((enum statement_enum));
412extern void lang_startup
413 PARAMS ((const char *));
414extern void lang_float
415 PARAMS ((bfd_boolean));
252b5132 416extern void lang_leave_output_section_statement
2c382fb6 417 PARAMS ((fill_type *, const char *, struct lang_output_section_phdr_list *,
562d3460 418 const char *));
f53154de
AM
419extern void lang_abs_symbol_at_end_of
420 PARAMS ((const char *, const char *));
421extern void lang_abs_symbol_at_beginning_of
422 PARAMS ((const char *, const char *));
423extern void lang_statement_append
424 PARAMS ((struct statement_list *, union lang_statement_union *,
425 union lang_statement_union **));
252b5132
RH
426extern void lang_for_each_input_file
427 PARAMS ((void (*dothis) (lang_input_statement_type *)));
428extern void lang_for_each_file
429 PARAMS ((void (*dothis) (lang_input_statement_type *)));
f53154de
AM
430extern void lang_reset_memory_regions
431 PARAMS ((void));
252b5132
RH
432extern bfd_vma lang_do_assignments
433 PARAMS ((lang_statement_union_type * s,
434 lang_output_section_statement_type *output_section_statement,
2c382fb6 435 fill_type *fill,
252b5132
RH
436 bfd_vma dot));
437
f53154de
AM
438#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
439 lang_input_statement_type *statement; \
440 for (statement = (lang_input_statement_type *) file_chain.head; \
441 statement != (lang_input_statement_type *) NULL; \
442 statement = (lang_input_statement_type *) statement->next) \
5cc18311 443
f53154de
AM
444extern void lang_process
445 PARAMS ((void));
446extern void ldlang_add_file
447 PARAMS ((lang_input_statement_type *));
252b5132
RH
448extern lang_output_section_statement_type *lang_output_section_find
449 PARAMS ((const char * const));
450extern lang_input_statement_type *lang_add_input_file
451 PARAMS ((const char *name, lang_input_file_enum_type file_type,
452 const char *target));
f53154de
AM
453extern void lang_add_keepsyms_file
454 PARAMS ((const char *filename));
252b5132 455extern lang_output_section_statement_type *
f53154de
AM
456 lang_output_section_statement_lookup
457 PARAMS ((const char * const name));
458extern void ldlang_add_undef
459 PARAMS ((const char *const name));
460extern void lang_add_output_format
461 PARAMS ((const char *, const char *, const char *, int from_script));
462extern void lang_list_init
463 PARAMS ((lang_statement_list_type*));
464extern void lang_add_data
465 PARAMS ((int type, union etree_union *));
252b5132
RH
466extern void lang_add_reloc
467 PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
468 asection *section, const char *name, union etree_union *addend));
469extern void lang_for_each_statement
470 PARAMS ((void (*func) (lang_statement_union_type *)));
f53154de
AM
471extern PTR stat_alloc
472 PARAMS ((size_t size));
473extern void dprint_statement
474 PARAMS ((lang_statement_union_type *, int));
252b5132
RH
475extern bfd_vma lang_size_sections
476 PARAMS ((lang_statement_union_type *s,
477 lang_output_section_statement_type *output_section_statement,
2c382fb6 478 lang_statement_union_type **prev, fill_type *fill,
cf888e70 479 bfd_vma dot, bfd_boolean *relax, bfd_boolean check_regions));
f53154de
AM
480extern void lang_enter_group
481 PARAMS ((void));
482extern void lang_leave_group
483 PARAMS ((void));
39dcfe18 484extern void lang_add_section
252b5132
RH
485 PARAMS ((lang_statement_list_type *ptr, asection *section,
486 lang_output_section_statement_type *output,
487 lang_input_statement_type *file));
488extern void lang_new_phdr
b34976b6 489 PARAMS ((const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
252b5132 490 etree_type *));
f53154de
AM
491extern void lang_add_nocrossref
492 PARAMS ((struct lang_nocrossref *));
493extern void lang_enter_overlay
494 PARAMS ((etree_type *));
495extern void lang_enter_overlay_section
496 PARAMS ((const char *));
252b5132 497extern void lang_leave_overlay_section
2c382fb6 498 PARAMS ((fill_type *, struct lang_output_section_phdr_list *));
252b5132 499extern void lang_leave_overlay
9f88b410
RS
500 PARAMS ((etree_type *, int, fill_type *, const char *,
501 struct lang_output_section_phdr_list *, const char *));
252b5132
RH
502
503extern struct bfd_elf_version_tree *lang_elf_version_info;
504
313e35ee 505extern struct bfd_elf_version_expr *lang_new_vers_pattern
252b5132
RH
506 PARAMS ((struct bfd_elf_version_expr *, const char *, const char *));
507extern struct bfd_elf_version_tree *lang_new_vers_node
508 PARAMS ((struct bfd_elf_version_expr *, struct bfd_elf_version_expr *));
509extern struct bfd_elf_version_deps *lang_add_vers_depend
510 PARAMS ((struct bfd_elf_version_deps *, const char *));
511extern void lang_register_vers_node
512 PARAMS ((const char *, struct bfd_elf_version_tree *,
513 struct bfd_elf_version_deps *));
f53154de
AM
514bfd_boolean unique_section_p
515 PARAMS ((const char *));
516extern void lang_add_unique
517 PARAMS ((const char *));
518extern const char *lang_get_output_target
519 PARAMS ((void));
252b5132
RH
520
521#endif
This page took 0.205154 seconds and 4 git commands to generate.