1 /* ldlang.h - linker command language support
2 Copyright 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
4 This file is part of GLD, the Gnu Linker.
6 GLD is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GLD is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 lang_input_file_is_l_enum,
26 lang_input_file_is_symbols_only_enum,
27 lang_input_file_is_marker_enum,
28 lang_input_file_is_fake_enum,
29 lang_input_file_is_search_file_enum,
30 lang_input_file_is_file_enum
31 } lang_input_file_enum_type;
33 typedef unsigned int fill_type;
34 typedef struct statement_list
36 union lang_statement_union *head;
37 union lang_statement_union **tail;
38 } lang_statement_list_type;
41 typedef struct memory_region_struct
44 struct memory_region_struct *next;
48 bfd_size_type old_length;
50 boolean had_full_message;
51 } lang_memory_region_type ;
53 typedef struct lang_statement_header_struct
55 union lang_statement_union *next;
58 lang_output_section_statement_enum,
59 lang_assignment_statement_enum,
60 lang_input_statement_enum,
61 lang_address_statement_enum,
62 lang_wild_statement_enum,
63 lang_input_section_enum,
64 lang_object_symbols_statement_enum,
65 lang_fill_statement_enum,
66 lang_data_statement_enum,
67 lang_reloc_statement_enum,
68 lang_target_statement_enum,
69 lang_output_statement_enum,
70 lang_padding_statement_enum,
71 lang_group_statement_enum,
73 lang_afile_asection_pair_statement_enum,
74 lang_constructors_statement_enum
76 } lang_statement_header_type;
81 lang_statement_header_type header;
82 union etree_union *exp;
83 } lang_assignment_statement_type;
86 typedef struct lang_target_statement_struct
88 lang_statement_header_type header;
90 } lang_target_statement_type;
93 typedef struct lang_output_statement_struct
95 lang_statement_header_type header;
97 } lang_output_statement_type;
99 /* Section types specified in a linker script. */
111 /* This structure holds a list of program headers describing segments
112 in which this section should be placed. */
114 struct lang_output_section_phdr_list
116 struct lang_output_section_phdr_list *next;
121 typedef struct lang_output_section_statement_struct
123 lang_statement_header_type header;
124 union etree_union *addr_tree;
125 lang_statement_list_type children;
127 union lang_statement_union *next;
132 asection *bfd_section;
133 int flags; /* Or together of all input sections */
134 enum section_type sectype;
135 struct memory_region_struct *region;
139 int subsection_alignment; /* alignment of components */
140 int section_alignment; /* alignment of start of section */
142 union etree_union *load_base;
144 struct lang_output_section_phdr_list *phdrs;
145 } lang_output_section_statement_type;
150 lang_statement_header_type header;
151 } lang_common_statement_type;
155 lang_statement_header_type header;
156 } lang_object_symbols_statement_type;
160 lang_statement_header_type header;
163 asection *output_section;
164 } lang_fill_statement_type;
168 lang_statement_header_type header;
170 union etree_union *exp;
172 asection *output_section;
174 } lang_data_statement_type;
176 /* Generate a reloc in the output file. */
180 lang_statement_header_type header;
182 /* Reloc to generate. */
183 bfd_reloc_code_real_type reloc;
185 /* Reloc howto structure. */
186 reloc_howto_type *howto;
188 /* Section to generate reloc against. Exactly one of section and
189 name must be NULL. */
192 /* Name of symbol to generate reloc against. Exactly one of section
193 and name must be NULL. */
196 /* Expression for addend. */
197 union etree_union *addend_exp;
199 /* Resolved addend. */
200 bfd_vma addend_value;
202 /* Output section where reloc should be performed. */
203 asection *output_section;
205 /* VMA within output section. */
207 } lang_reloc_statement_type;
209 typedef struct lang_input_statement_struct
211 lang_statement_header_type header;
212 /* Name of this file. */
213 const char *filename;
214 /* Name to use for the symbol giving address of text start */
215 /* Usually the same as filename, but for a file spec'd with -l
216 this is the -l switch itself rather than the filename. */
217 const char *local_sym_name;
222 file_ptr passive_position;
224 /* Symbol table of the file. */
226 unsigned int symbol_count;
228 /* Point to the next file - whatever it is, wanders up and down
231 union lang_statement_union *next;
232 /* Point to the next file, but skips archive contents */
233 union lang_statement_union *next_real_file;
237 /* 1 means search a set of directories for this file. */
238 boolean search_dirs_flag;
240 /* 1 means this is base file of incremental load.
241 Do not load this file's text or data.
242 Also default text_start to after this file's bss. */
244 boolean just_syms_flag;
246 /* Whether to search for this entry as a dynamic archive. */
249 /* Whether to include the entire contents of an archive. */
250 boolean whole_archive;
254 /* unsigned int globals_in_this_file;*/
257 } lang_input_statement_type;
261 lang_statement_header_type header;
263 lang_input_statement_type *ifile;
265 } lang_input_section_type;
270 lang_statement_header_type header;
272 union lang_statement_union *file;
273 } lang_afile_asection_pair_statement_type;
275 typedef struct lang_wild_statement_struct
277 lang_statement_header_type header;
278 const char *section_name;
279 const char *filename;
280 lang_statement_list_type children;
281 } lang_wild_statement_type;
283 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;
292 lang_statement_header_type header;
293 bfd_vma output_offset;
295 asection *output_section;
297 } lang_padding_statement_type;
299 /* A group statement collects a set of libraries together. The
300 libraries are searched multiple times, until no new undefined
301 symbols are found. The effect is to search a group of libraries as
302 though they were a single library. */
306 lang_statement_header_type header;
307 lang_statement_list_type children;
308 } lang_group_statement_type;
310 typedef union lang_statement_union
312 lang_statement_header_type header;
313 union lang_statement_union *next;
314 lang_wild_statement_type wild_statement;
315 lang_data_statement_type data_statement;
316 lang_reloc_statement_type reloc_statement;
317 lang_address_statement_type address_statement;
318 lang_output_section_statement_type output_section_statement;
319 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
320 lang_assignment_statement_type assignment_statement;
321 lang_input_statement_type input_statement;
322 lang_target_statement_type target_statement;
323 lang_output_statement_type output_statement;
324 lang_input_section_type input_section;
325 lang_common_statement_type common_statement;
326 lang_object_symbols_statement_type object_symbols_statement;
327 lang_fill_statement_type fill_statement;
328 lang_padding_statement_type padding_statement;
329 lang_group_statement_type group_statement;
330 } lang_statement_union_type;
332 /* This structure holds information about a program header, from the
333 PHDRS command in the linker script. */
337 struct lang_phdr *next;
346 /* This structure is used to hold a list of sections which may not
347 cross reference each other. */
349 struct lang_nocrossref
351 struct lang_nocrossref *next;
355 /* The list of nocrossref lists. */
357 struct lang_nocrossrefs
359 struct lang_nocrossrefs *next;
360 struct lang_nocrossref *list;
363 extern struct lang_nocrossrefs *nocrossref_list;
365 extern lang_output_section_statement_type *abs_output_section;
366 extern boolean lang_has_input_file;
367 extern etree_type *base;
368 extern lang_statement_list_type *stat_ptr;
369 extern boolean delete_output_file_on_failure;
371 extern const char *entry_symbol;
372 extern boolean entry_from_cmdline;
374 extern void lang_init PARAMS ((void));
375 extern struct memory_region_struct *lang_memory_region_lookup
376 PARAMS ((const char *const));
377 extern void lang_map PARAMS ((void));
378 extern void lang_set_flags PARAMS ((int *, const char *));
379 extern void lang_add_output PARAMS ((const char *, int from_script));
380 extern void lang_enter_output_section_statement
381 PARAMS ((const char *output_section_statement_name,
382 etree_type * address_exp,
383 enum section_type sectype,
386 etree_type *subalign,
388 extern void lang_final PARAMS ((void));
389 extern void lang_process PARAMS ((void));
390 extern void lang_section_start PARAMS ((const char *, union etree_union *));
391 extern void lang_add_entry PARAMS ((const char *, boolean));
392 extern void lang_add_target PARAMS ((const char *));
393 extern void lang_add_wild PARAMS ((const char *const , const char *const));
394 extern void lang_add_map PARAMS ((const char *));
395 extern void lang_add_fill PARAMS ((int));
396 extern void lang_add_assignment PARAMS ((union etree_union *));
397 extern void lang_add_attribute PARAMS ((enum statement_enum));
398 extern void lang_startup PARAMS ((const char *));
399 extern void lang_float PARAMS ((enum bfd_boolean));
400 extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
402 extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
403 extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
405 extern void lang_statement_append PARAMS ((struct statement_list *,
406 union lang_statement_union *,
407 union lang_statement_union **));
408 extern void lang_for_each_input_file
409 PARAMS ((void (*dothis) (lang_input_statement_type *)));
410 extern void lang_for_each_file
411 PARAMS ((void (*dothis) (lang_input_statement_type *)));
412 extern bfd_vma lang_do_assignments
413 PARAMS ((lang_statement_union_type * s,
414 lang_output_section_statement_type *output_section_statement,
418 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
419 extern lang_statement_list_type file_chain; \
420 lang_input_statement_type *statement; \
421 for (statement = (lang_input_statement_type *)file_chain.head;\
422 statement != (lang_input_statement_type *)NULL; \
423 statement = (lang_input_statement_type *)statement->next)\
425 extern void lang_process PARAMS ((void));
426 extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
427 extern lang_output_section_statement_type *lang_output_section_find
428 PARAMS ((const char * const));
429 extern lang_input_statement_type *lang_add_input_file
430 PARAMS ((const char *name, lang_input_file_enum_type file_type,
431 const char *target));
432 extern void lang_add_keepsyms_file PARAMS ((const char *filename));
433 extern lang_output_section_statement_type *
434 lang_output_section_statement_lookup PARAMS ((const char * const name));
435 extern void ldlang_add_undef PARAMS ((const char *const name));
436 extern void lang_add_output_format PARAMS ((const char *, const char *,
437 const char *, int from_script));
438 extern void lang_list_init PARAMS ((lang_statement_list_type*));
439 extern void lang_add_data PARAMS ((int type, union etree_union *));
440 extern void lang_add_reloc
441 PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
442 asection *section, const char *name, union etree_union *addend));
443 extern void lang_for_each_statement
444 PARAMS ((void (*func) (lang_statement_union_type *)));
445 extern PTR stat_alloc PARAMS ((size_t size));
446 extern bfd_vma lang_size_sections
447 PARAMS ((lang_statement_union_type *s,
448 lang_output_section_statement_type *output_section_statement,
449 lang_statement_union_type **prev, fill_type fill,
450 bfd_vma dot, boolean relax));
451 extern void lang_enter_group PARAMS ((void));
452 extern void lang_leave_group PARAMS ((void));
453 extern void wild_doit
454 PARAMS ((lang_statement_list_type *ptr, asection *section,
455 lang_output_section_statement_type *output,
456 lang_input_statement_type *file));
457 extern void lang_new_phdr
458 PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
460 extern void lang_section_in_phdr PARAMS ((const char *));
461 extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *));