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