* acinclude.m4 (AM_PROG_LEX): Override installed definition.
[deliverable/binutils-gdb.git] / ld / ldlang.h
CommitLineData
252b5132 1/* ldlang.h - linker command language support
577a0623 2 Copyright 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
aa8804e4 3 Free Software Foundation, Inc.
5cc18311 4
252b5132 5 This file is part of GLD, the Gnu Linker.
5cc18311 6
252b5132
RH
7 GLD is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
10 any later version.
5cc18311 11
252b5132
RH
12 GLD is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
5cc18311 16
252b5132
RH
17 You should have received a copy of the GNU General Public License
18 along with GLD; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#ifndef LDLANG_H
23#define LDLANG_H
24
89cdebba 25typedef enum {
252b5132
RH
26 lang_input_file_is_l_enum,
27 lang_input_file_is_symbols_only_enum,
28 lang_input_file_is_marker_enum,
29 lang_input_file_is_fake_enum,
30 lang_input_file_is_search_file_enum,
31 lang_input_file_is_file_enum
32} lang_input_file_enum_type;
33
34typedef unsigned int fill_type;
89cdebba
KH
35
36typedef struct statement_list {
252b5132
RH
37 union lang_statement_union *head;
38 union lang_statement_union **tail;
39} lang_statement_list_type;
40
89cdebba 41typedef struct memory_region_struct {
252b5132
RH
42 char *name;
43 struct memory_region_struct *next;
44 bfd_vma origin;
45 bfd_size_type length;
46 bfd_vma current;
47 bfd_size_type old_length;
48 flagword flags;
49 flagword not_flags;
50 boolean had_full_message;
89cdebba
KH
51} lang_memory_region_type;
52
53typedef struct lang_statement_header_struct {
54 union lang_statement_union *next;
55 enum statement_enum {
56 lang_output_section_statement_enum,
57 lang_assignment_statement_enum,
58 lang_input_statement_enum,
59 lang_address_statement_enum,
60 lang_wild_statement_enum,
61 lang_input_section_enum,
62 lang_object_symbols_statement_enum,
63 lang_fill_statement_enum,
64 lang_data_statement_enum,
65 lang_reloc_statement_enum,
66 lang_target_statement_enum,
67 lang_output_statement_enum,
68 lang_padding_statement_enum,
69 lang_group_statement_enum,
70
71 lang_afile_asection_pair_statement_enum,
72 lang_constructors_statement_enum
73 } type;
252b5132
RH
74} lang_statement_header_type;
75
89cdebba 76typedef struct {
252b5132
RH
77 lang_statement_header_type header;
78 union etree_union *exp;
79} lang_assignment_statement_type;
80
89cdebba 81typedef struct lang_target_statement_struct {
252b5132
RH
82 lang_statement_header_type header;
83 const char *target;
84} lang_target_statement_type;
85
89cdebba 86typedef struct lang_output_statement_struct {
252b5132
RH
87 lang_statement_header_type header;
88 const char *name;
89} lang_output_statement_type;
90
91/* Section types specified in a linker script. */
92
89cdebba 93enum section_type {
252b5132
RH
94 normal_section,
95 dsect_section,
96 copy_section,
97 noload_section,
98 info_section,
99 overlay_section
100};
101
102/* This structure holds a list of program headers describing segments
103 in which this section should be placed. */
104
89cdebba 105struct lang_output_section_phdr_list {
252b5132
RH
106 struct lang_output_section_phdr_list *next;
107 const char *name;
108 boolean used;
109};
110
89cdebba 111typedef struct lang_output_section_statement_struct {
252b5132
RH
112 lang_statement_header_type header;
113 union etree_union *addr_tree;
114 lang_statement_list_type children;
115 const char *memspec;
116 union lang_statement_union *next;
117 const char *name;
118
119 boolean processed;
5cc18311 120
252b5132
RH
121 asection *bfd_section;
122 flagword flags; /* Or together of all input sections */
123 enum section_type sectype;
124 struct memory_region_struct *region;
562d3460 125 struct memory_region_struct *lma_region;
252b5132
RH
126 size_t block_value;
127 fill_type fill;
128
89cdebba
KH
129 int subsection_alignment; /* alignment of components */
130 int section_alignment; /* alignment of start of section */
252b5132
RH
131
132 union etree_union *load_base;
133
134 struct lang_output_section_phdr_list *phdrs;
135} lang_output_section_statement_type;
136
89cdebba 137typedef struct {
252b5132
RH
138 lang_statement_header_type header;
139} lang_common_statement_type;
140
89cdebba 141typedef struct {
252b5132
RH
142 lang_statement_header_type header;
143} lang_object_symbols_statement_type;
144
89cdebba 145typedef struct {
252b5132
RH
146 lang_statement_header_type header;
147 fill_type fill;
148 int size;
149 asection *output_section;
150} lang_fill_statement_type;
151
89cdebba 152typedef struct {
252b5132
RH
153 lang_statement_header_type header;
154 unsigned int type;
89cdebba 155 union etree_union *exp;
252b5132
RH
156 bfd_vma value;
157 asection *output_section;
158 bfd_vma output_vma;
159} lang_data_statement_type;
160
161/* Generate a reloc in the output file. */
162
89cdebba 163typedef struct {
252b5132
RH
164 lang_statement_header_type header;
165
166 /* Reloc to generate. */
167 bfd_reloc_code_real_type reloc;
168
169 /* Reloc howto structure. */
170 reloc_howto_type *howto;
171
172 /* Section to generate reloc against. Exactly one of section and
173 name must be NULL. */
174 asection *section;
175
176 /* Name of symbol to generate reloc against. Exactly one of section
177 and name must be NULL. */
178 const char *name;
179
180 /* Expression for addend. */
181 union etree_union *addend_exp;
182
183 /* Resolved addend. */
184 bfd_vma addend_value;
185
186 /* Output section where reloc should be performed. */
187 asection *output_section;
188
189 /* VMA within output section. */
190 bfd_vma output_vma;
191} lang_reloc_statement_type;
192
89cdebba 193typedef struct lang_input_statement_struct {
252b5132
RH
194 lang_statement_header_type header;
195 /* Name of this file. */
196 const char *filename;
197 /* Name to use for the symbol giving address of text start */
198 /* Usually the same as filename, but for a file spec'd with -l
199 this is the -l switch itself rather than the filename. */
200 const char *local_sym_name;
5cc18311 201
252b5132 202 bfd *the_bfd;
5cc18311 203
252b5132
RH
204 boolean closed;
205 file_ptr passive_position;
5cc18311 206
252b5132
RH
207 /* Symbol table of the file. */
208 asymbol **asymbols;
209 unsigned int symbol_count;
5cc18311 210
252b5132
RH
211 /* Point to the next file - whatever it is, wanders up and down
212 archives */
5cc18311 213
89cdebba 214 union lang_statement_union *next;
252b5132 215 /* Point to the next file, but skips archive contents */
89cdebba 216 union lang_statement_union *next_real_file;
5cc18311 217
252b5132 218 boolean is_archive;
5cc18311 219
252b5132
RH
220 /* 1 means search a set of directories for this file. */
221 boolean search_dirs_flag;
5cc18311 222
252b5132
RH
223 /* 1 means this is base file of incremental load.
224 Do not load this file's text or data.
5cc18311
KH
225 Also default text_start to after this file's bss. */
226
252b5132
RH
227 boolean just_syms_flag;
228
229 /* Whether to search for this entry as a dynamic archive. */
230 boolean dynamic;
231
232 /* Whether to include the entire contents of an archive. */
233 boolean whole_archive;
234
235 boolean loaded;
5cc18311 236
89cdebba
KH
237#if 0
238 unsigned int globals_in_this_file;
239#endif
252b5132
RH
240 const char *target;
241 boolean real;
242} lang_input_statement_type;
243
89cdebba 244typedef struct {
252b5132
RH
245 lang_statement_header_type header;
246 asection *section;
247 lang_input_statement_type *ifile;
252b5132 248
5cc18311 249} lang_input_section_type;
252b5132 250
89cdebba 251typedef struct {
252b5132
RH
252 lang_statement_header_type header;
253 asection *section;
254 union lang_statement_union *file;
255} lang_afile_asection_pair_statement_type;
256
89cdebba 257typedef struct lang_wild_statement_struct {
252b5132
RH
258 lang_statement_header_type header;
259 const char *section_name;
260 boolean sections_sorted;
261 const char *filename;
262 boolean filenames_sorted;
263 boolean keep_sections;
18625d54 264 struct name_list *exclude_filename_list;
252b5132
RH
265 lang_statement_list_type children;
266} lang_wild_statement_type;
267
89cdebba 268typedef struct lang_address_statement_struct {
252b5132 269 lang_statement_header_type header;
89cdebba
KH
270 const char *section_name;
271 union etree_union *address;
252b5132
RH
272} lang_address_statement_type;
273
89cdebba 274typedef struct {
252b5132
RH
275 lang_statement_header_type header;
276 bfd_vma output_offset;
277 size_t size;
278 asection *output_section;
279 fill_type fill;
280} lang_padding_statement_type;
281
282/* A group statement collects a set of libraries together. The
283 libraries are searched multiple times, until no new undefined
284 symbols are found. The effect is to search a group of libraries as
285 though they were a single library. */
286
89cdebba 287typedef struct {
252b5132
RH
288 lang_statement_header_type header;
289 lang_statement_list_type children;
290} lang_group_statement_type;
291
89cdebba 292typedef union lang_statement_union {
252b5132
RH
293 lang_statement_header_type header;
294 union lang_statement_union *next;
295 lang_wild_statement_type wild_statement;
296 lang_data_statement_type data_statement;
297 lang_reloc_statement_type reloc_statement;
298 lang_address_statement_type address_statement;
299 lang_output_section_statement_type output_section_statement;
300 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
301 lang_assignment_statement_type assignment_statement;
302 lang_input_statement_type input_statement;
303 lang_target_statement_type target_statement;
304 lang_output_statement_type output_statement;
305 lang_input_section_type input_section;
306 lang_common_statement_type common_statement;
307 lang_object_symbols_statement_type object_symbols_statement;
308 lang_fill_statement_type fill_statement;
309 lang_padding_statement_type padding_statement;
310 lang_group_statement_type group_statement;
311} lang_statement_union_type;
312
313/* This structure holds information about a program header, from the
314 PHDRS command in the linker script. */
315
89cdebba 316struct lang_phdr {
252b5132
RH
317 struct lang_phdr *next;
318 const char *name;
319 unsigned long type;
320 boolean filehdr;
321 boolean phdrs;
322 etree_type *at;
323 etree_type *flags;
324};
325
326/* This structure is used to hold a list of sections which may not
327 cross reference each other. */
328
89cdebba 329struct lang_nocrossref {
252b5132
RH
330 struct lang_nocrossref *next;
331 const char *name;
332};
333
334/* The list of nocrossref lists. */
335
89cdebba 336struct lang_nocrossrefs {
252b5132
RH
337 struct lang_nocrossrefs *next;
338 struct lang_nocrossref *list;
339};
340
341extern struct lang_nocrossrefs *nocrossref_list;
342
577a0623
AM
343/* This structure is used to hold a list of input section names which
344 will not match an output section in the linker script. */
345
346struct unique_sections {
347 struct unique_sections *next;
348 const char *name;
349};
350
351extern struct unique_sections *unique_section_list;
352
252b5132 353extern lang_output_section_statement_type *abs_output_section;
aea4bd9d 354extern lang_statement_list_type lang_output_section_statement;
252b5132
RH
355extern boolean lang_has_input_file;
356extern etree_type *base;
357extern lang_statement_list_type *stat_ptr;
358extern boolean delete_output_file_on_failure;
359
360extern const char *entry_symbol;
361extern boolean entry_from_cmdline;
b71e2778 362extern lang_statement_list_type file_chain;
252b5132
RH
363
364extern void lang_init PARAMS ((void));
365extern struct memory_region_struct *lang_memory_region_lookup
366 PARAMS ((const char *const));
367extern struct memory_region_struct *lang_memory_region_default
368 PARAMS ((asection *));
369extern void lang_map PARAMS ((void));
aa8804e4
ILT
370extern void lang_set_flags PARAMS ((lang_memory_region_type *, const char *,
371 int));
252b5132 372extern void lang_add_output PARAMS ((const char *, int from_script));
aea4bd9d 373extern lang_output_section_statement_type *lang_enter_output_section_statement
252b5132
RH
374 PARAMS ((const char *output_section_statement_name,
375 etree_type * address_exp,
376 enum section_type sectype,
377 bfd_vma block_value,
378 etree_type *align,
379 etree_type *subalign,
380 etree_type *));
381extern void lang_final PARAMS ((void));
382extern void lang_process PARAMS ((void));
383extern void lang_section_start PARAMS ((const char *, union etree_union *));
384extern void lang_add_entry PARAMS ((const char *, boolean));
385extern void lang_add_target PARAMS ((const char *));
386extern void lang_add_wild
18625d54 387 PARAMS ((const char *, boolean, const char *, boolean, boolean, name_list *));
252b5132
RH
388extern void lang_add_map PARAMS ((const char *));
389extern void lang_add_fill PARAMS ((int));
390extern lang_assignment_statement_type * lang_add_assignment PARAMS ((union etree_union *));
391extern void lang_add_attribute PARAMS ((enum statement_enum));
392extern void lang_startup PARAMS ((const char *));
393extern void lang_float PARAMS ((enum bfd_boolean));
394extern void lang_leave_output_section_statement
562d3460
TW
395 PARAMS ((bfd_vma, const char *, struct lang_output_section_phdr_list *,
396 const char *));
252b5132
RH
397extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
398extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
399 const char *));
400extern void lang_statement_append PARAMS ((struct statement_list *,
401 union lang_statement_union *,
402 union lang_statement_union **));
403extern void lang_for_each_input_file
404 PARAMS ((void (*dothis) (lang_input_statement_type *)));
405extern void lang_for_each_file
406 PARAMS ((void (*dothis) (lang_input_statement_type *)));
407extern bfd_vma lang_do_assignments
408 PARAMS ((lang_statement_union_type * s,
409 lang_output_section_statement_type *output_section_statement,
410 fill_type fill,
411 bfd_vma dot));
412
413#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
252b5132
RH
414 lang_input_statement_type *statement; \
415 for (statement = (lang_input_statement_type *)file_chain.head;\
416 statement != (lang_input_statement_type *)NULL; \
417 statement = (lang_input_statement_type *)statement->next)\
5cc18311 418
252b5132
RH
419extern void lang_process PARAMS ((void));
420extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
421extern lang_output_section_statement_type *lang_output_section_find
422 PARAMS ((const char * const));
423extern lang_input_statement_type *lang_add_input_file
424 PARAMS ((const char *name, lang_input_file_enum_type file_type,
425 const char *target));
426extern void lang_add_keepsyms_file PARAMS ((const char *filename));
427extern lang_output_section_statement_type *
428 lang_output_section_statement_lookup PARAMS ((const char * const name));
429extern void ldlang_add_undef PARAMS ((const char *const name));
430extern void lang_add_output_format PARAMS ((const char *, const char *,
431 const char *, int from_script));
432extern void lang_list_init PARAMS ((lang_statement_list_type*));
433extern void lang_add_data PARAMS ((int type, union etree_union *));
434extern void lang_add_reloc
435 PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
436 asection *section, const char *name, union etree_union *addend));
437extern void lang_for_each_statement
438 PARAMS ((void (*func) (lang_statement_union_type *)));
439extern PTR stat_alloc PARAMS ((size_t size));
440extern void dprint_statement PARAMS ((lang_statement_union_type *, int));
441extern bfd_vma lang_size_sections
442 PARAMS ((lang_statement_union_type *s,
443 lang_output_section_statement_type *output_section_statement,
444 lang_statement_union_type **prev, fill_type fill,
445 bfd_vma dot, boolean relax));
446extern void lang_enter_group PARAMS ((void));
447extern void lang_leave_group PARAMS ((void));
448extern void wild_doit
449 PARAMS ((lang_statement_list_type *ptr, asection *section,
450 lang_output_section_statement_type *output,
451 lang_input_statement_type *file));
452extern void lang_new_phdr
453 PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
454 etree_type *));
455extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *));
456extern void lang_enter_overlay PARAMS ((etree_type *, etree_type *, int));
457extern void lang_enter_overlay_section PARAMS ((const char *));
458extern void lang_leave_overlay_section
459 PARAMS ((bfd_vma, struct lang_output_section_phdr_list *));
460extern void lang_leave_overlay
562d3460
TW
461 PARAMS ((bfd_vma, const char *, struct lang_output_section_phdr_list *,
462 const char *));
252b5132
RH
463
464extern struct bfd_elf_version_tree *lang_elf_version_info;
465
466extern struct bfd_elf_version_expr *lang_new_vers_regex
467 PARAMS ((struct bfd_elf_version_expr *, const char *, const char *));
468extern struct bfd_elf_version_tree *lang_new_vers_node
469 PARAMS ((struct bfd_elf_version_expr *, struct bfd_elf_version_expr *));
470extern struct bfd_elf_version_deps *lang_add_vers_depend
471 PARAMS ((struct bfd_elf_version_deps *, const char *));
472extern void lang_register_vers_node
473 PARAMS ((const char *, struct bfd_elf_version_tree *,
474 struct bfd_elf_version_deps *));
577a0623
AM
475boolean unique_section_p PARAMS ((const char *));
476extern void lang_add_unique PARAMS ((const char *));
252b5132
RH
477
478#endif
This page took 0.081306 seconds and 4 git commands to generate.