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