1 /* ldlang.h - linker command language support
2 Copyright 1991, 1992, 1993, 1994, 1995 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;
100 /* This structure holds a list of program headers describing segments
101 in which this section should be placed. */
103 struct lang_output_section_phdr_list
105 struct lang_output_section_phdr_list *next;
110 typedef struct lang_output_section_statement_struct
112 lang_statement_header_type header;
113 union etree_union *addr_tree;
114 lang_statement_list_type children;
116 union lang_statement_union *next;
121 asection *bfd_section;
122 int flags; /* Or together of all input sections */
123 int loadable; /* set from NOLOAD flag in script */
124 struct memory_region_struct *region;
128 int subsection_alignment; /* alignment of components */
129 int section_alignment; /* alignment of start of section */
131 union etree_union *load_base;
133 struct lang_output_section_phdr_list *phdrs;
134 } lang_output_section_statement_type;
139 lang_statement_header_type header;
140 } lang_common_statement_type;
144 lang_statement_header_type header;
145 } lang_object_symbols_statement_type;
149 lang_statement_header_type header;
152 asection *output_section;
153 } lang_fill_statement_type;
157 lang_statement_header_type header;
159 union etree_union *exp;
161 asection *output_section;
163 } lang_data_statement_type;
165 /* Generate a reloc in the output file. */
169 lang_statement_header_type header;
171 /* Reloc to generate. */
172 bfd_reloc_code_real_type reloc;
174 /* Reloc howto structure. */
175 reloc_howto_type *howto;
177 /* Section to generate reloc against. Exactly one of section and
178 name must be NULL. */
181 /* Name of symbol to generate reloc against. Exactly one of section
182 and name must be NULL. */
185 /* Expression for addend. */
186 union etree_union *addend_exp;
188 /* Resolved addend. */
189 bfd_vma addend_value;
191 /* Output section where reloc should be performed. */
192 asection *output_section;
194 /* VMA within output section. */
196 } lang_reloc_statement_type;
198 typedef struct lang_input_statement_struct
200 lang_statement_header_type header;
201 /* Name of this file. */
202 const char *filename;
203 /* Name to use for the symbol giving address of text start */
204 /* Usually the same as filename, but for a file spec'd with -l
205 this is the -l switch itself rather than the filename. */
206 const char *local_sym_name;
211 file_ptr passive_position;
213 /* Symbol table of the file. */
215 unsigned int symbol_count;
217 /* Point to the next file - whatever it is, wanders up and down
220 union lang_statement_union *next;
221 /* Point to the next file, but skips archive contents */
222 union lang_statement_union *next_real_file;
226 /* 1 means search a set of directories for this file. */
227 boolean search_dirs_flag;
229 /* 1 means this is base file of incremental load.
230 Do not load this file's text or data.
231 Also default text_start to after this file's bss. */
233 boolean just_syms_flag;
235 /* Whether to search for this entry as a dynamic archive. */
238 /* Whether to include the entire contents of an archive. */
239 boolean whole_archive;
243 /* unsigned int globals_in_this_file;*/
246 asection *common_section;
247 asection *common_output_section;
249 } lang_input_statement_type;
253 lang_statement_header_type header;
255 lang_input_statement_type *ifile;
257 } lang_input_section_type;
262 lang_statement_header_type header;
264 union lang_statement_union *file;
265 } lang_afile_asection_pair_statement_type;
267 typedef struct lang_wild_statement_struct
269 lang_statement_header_type header;
270 const char *section_name;
271 const char *filename;
272 lang_statement_list_type children;
273 } lang_wild_statement_type;
275 typedef struct lang_address_statement_struct
277 lang_statement_header_type header;
278 const char *section_name;
279 union etree_union *address;
280 } lang_address_statement_type;
284 lang_statement_header_type header;
285 bfd_vma output_offset;
287 asection *output_section;
289 } lang_padding_statement_type;
291 /* A group statement collects a set of libraries together. The
292 libraries are searched multiple times, until no new undefined
293 symbols are found. The effect is to search a group of libraries as
294 though they were a single library. */
298 lang_statement_header_type header;
299 lang_statement_list_type children;
300 } lang_group_statement_type;
302 typedef union lang_statement_union
304 lang_statement_header_type header;
305 union lang_statement_union *next;
306 lang_wild_statement_type wild_statement;
307 lang_data_statement_type data_statement;
308 lang_reloc_statement_type reloc_statement;
309 lang_address_statement_type address_statement;
310 lang_output_section_statement_type output_section_statement;
311 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
312 lang_assignment_statement_type assignment_statement;
313 lang_input_statement_type input_statement;
314 lang_target_statement_type target_statement;
315 lang_output_statement_type output_statement;
316 lang_input_section_type input_section;
317 lang_common_statement_type common_statement;
318 lang_object_symbols_statement_type object_symbols_statement;
319 lang_fill_statement_type fill_statement;
320 lang_padding_statement_type padding_statement;
321 lang_group_statement_type group_statement;
322 } lang_statement_union_type;
324 /* This structure holds information about a program header, from the
325 PHDRS command in the linker script. */
329 struct lang_phdr *next;
338 extern lang_output_section_statement_type *abs_output_section;
339 extern boolean lang_has_input_file;
340 extern etree_type *base;
341 extern lang_statement_list_type *stat_ptr;
342 extern boolean delete_output_file_on_failure;
344 extern const char *entry_symbol;
345 extern boolean entry_from_cmdline;
347 extern void lang_init PARAMS ((void));
348 extern struct memory_region_struct *lang_memory_region_lookup
349 PARAMS ((const char *const));
350 extern void lang_map PARAMS ((void));
351 extern void lang_set_flags PARAMS ((int *, const char *));
352 extern void lang_add_output PARAMS ((const char *, int from_script));
353 extern void lang_enter_output_section_statement
354 PARAMS ((const char *output_section_statement_name,
355 etree_type * address_exp,
359 etree_type *subalign,
361 extern void lang_final PARAMS ((void));
362 extern void lang_process PARAMS ((void));
363 extern void lang_section_start PARAMS ((const char *, union etree_union *));
364 extern void lang_add_entry PARAMS ((const char *, boolean));
365 extern void lang_add_target PARAMS ((const char *));
366 extern void lang_add_wild PARAMS ((const char *const , const char *const));
367 extern void lang_add_map PARAMS ((const char *));
368 extern void lang_add_fill PARAMS ((int));
369 extern void lang_add_assignment PARAMS ((union etree_union *));
370 extern void lang_add_attribute PARAMS ((enum statement_enum));
371 extern void lang_startup PARAMS ((const char *));
372 extern void lang_float PARAMS ((enum bfd_boolean));
373 extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
375 extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
376 extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
378 extern void lang_statement_append PARAMS ((struct statement_list *,
379 union lang_statement_union *,
380 union lang_statement_union **));
381 extern void lang_for_each_input_file
382 PARAMS ((void (*dothis) (lang_input_statement_type *)));
383 extern void lang_for_each_file
384 PARAMS ((void (*dothis) (lang_input_statement_type *)));
385 extern bfd_vma lang_do_assignments
386 PARAMS ((lang_statement_union_type * s,
387 lang_output_section_statement_type *output_section_statement,
391 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
392 extern lang_statement_list_type file_chain; \
393 lang_input_statement_type *statement; \
394 for (statement = (lang_input_statement_type *)file_chain.head;\
395 statement != (lang_input_statement_type *)NULL; \
396 statement = (lang_input_statement_type *)statement->next)\
398 extern void lang_process PARAMS ((void));
399 extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
400 extern lang_output_section_statement_type *lang_output_section_find
401 PARAMS ((const char * const));
402 extern lang_input_statement_type *lang_add_input_file
403 PARAMS ((const char *name, lang_input_file_enum_type file_type,
404 const char *target));
405 extern void lang_add_keepsyms_file PARAMS ((const char *filename));
406 extern lang_output_section_statement_type *
407 lang_output_section_statement_lookup PARAMS ((const char * const name));
408 extern void ldlang_add_undef PARAMS ((const char *const name));
409 extern void lang_add_output_format PARAMS ((const char *, const char *,
410 const char *, int from_script));
411 extern void lang_list_init PARAMS ((lang_statement_list_type*));
412 extern void lang_add_data PARAMS ((int type, union etree_union *));
413 extern void lang_add_reloc
414 PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
415 asection *section, const char *name, union etree_union *addend));
416 extern void lang_for_each_statement
417 PARAMS ((void (*func) (lang_statement_union_type *)));
418 extern PTR stat_alloc PARAMS ((size_t size));
419 extern bfd_vma lang_size_sections
420 PARAMS ((lang_statement_union_type *s,
421 lang_output_section_statement_type *output_section_statement,
422 lang_statement_union_type **prev, fill_type fill,
423 bfd_vma dot, boolean relax));
424 extern void lang_enter_group PARAMS ((void));
425 extern void lang_leave_group PARAMS ((void));
426 extern void wild_doit
427 PARAMS ((lang_statement_list_type *ptr, asection *section,
428 lang_output_section_statement_type *output,
429 lang_input_statement_type *file));
430 extern void lang_new_phdr
431 PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
433 extern void lang_section_in_phdr PARAMS ((const char *));