fsf address update, but not in COPYING files
[platform/upstream/binutils.git] / ld / ldlang.h
1 /* ldlang.h - linker command language support
2    Copyright 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3    
4    This file is part of GLD, the Gnu Linker.
5    
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)
9    any later version.
10    
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.
15    
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.  */
19
20 #ifndef LDLANG_H
21 #define LDLANG_H
22
23 typedef enum
24 {
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;
32
33 typedef unsigned int fill_type;
34 typedef struct statement_list
35 {
36   union lang_statement_union *head;
37   union lang_statement_union **tail;
38 } lang_statement_list_type;
39
40
41 typedef struct memory_region_struct
42 {
43   char *name;
44   struct memory_region_struct *next;
45   bfd_vma origin;
46   bfd_size_type length;
47   bfd_vma current;
48   bfd_size_type old_length;
49   int flags;
50   boolean had_full_message;
51 } lang_memory_region_type ;
52
53 typedef struct lang_statement_header_struct 
54 {
55   union  lang_statement_union  *next;
56   enum statement_enum
57     {
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,
72
73       lang_afile_asection_pair_statement_enum,
74       lang_constructors_statement_enum
75     } type;
76 } lang_statement_header_type;
77
78
79 typedef struct 
80 {
81   lang_statement_header_type header;
82   union etree_union *exp;
83 } lang_assignment_statement_type;
84
85
86 typedef struct lang_target_statement_struct
87 {
88   lang_statement_header_type header;
89   const char *target;
90 } lang_target_statement_type;
91
92
93 typedef struct lang_output_statement_struct
94 {
95   lang_statement_header_type header;
96   const char *name;
97 } lang_output_statement_type;
98
99
100 typedef struct lang_output_section_statement_struct 
101 {
102   lang_statement_header_type header;
103   union etree_union *addr_tree;
104   lang_statement_list_type children;
105   const char *memspec;
106   union lang_statement_union *next;
107   const char *name;
108
109   boolean processed;
110     
111   asection *bfd_section;
112   int flags;                    /* Or together of all input sections */
113   int loadable;                 /* set from NOLOAD flag in script */
114   struct memory_region_struct *region;
115   size_t block_value;
116   fill_type fill;
117
118   int subsection_alignment;  /* alignment of components */
119   int section_alignment;  /* alignment of start of section */
120
121   union etree_union *load_base;  
122 } lang_output_section_statement_type;
123
124
125 typedef struct
126 {
127   lang_statement_header_type header;
128 } lang_common_statement_type;
129
130 typedef struct
131 {
132   lang_statement_header_type header;
133 } lang_object_symbols_statement_type;
134
135 typedef struct
136 {
137   lang_statement_header_type header;
138   fill_type fill;
139   int size;
140   asection *output_section;
141 } lang_fill_statement_type;
142
143 typedef struct
144 {
145   lang_statement_header_type header;
146   unsigned int type;
147   union  etree_union *exp;
148   bfd_vma value;
149   asection *output_section;
150   bfd_vma output_vma;
151 } lang_data_statement_type;
152
153 /* Generate a reloc in the output file.  */
154
155 typedef struct
156 {
157   lang_statement_header_type header;
158
159   /* Reloc to generate.  */
160   bfd_reloc_code_real_type reloc;
161
162   /* Reloc howto structure.  */
163   reloc_howto_type *howto;
164
165   /* Section to generate reloc against.  Exactly one of section and
166      name must be NULL.  */
167   asection *section;
168
169   /* Name of symbol to generate reloc against.  Exactly one of section
170      and name must be NULL.  */
171   const char *name;
172
173   /* Expression for addend.  */
174   union etree_union *addend_exp;
175
176   /* Resolved addend.  */
177   bfd_vma addend_value;
178
179   /* Output section where reloc should be performed.  */
180   asection *output_section;
181
182   /* VMA within output section.  */
183   bfd_vma output_vma;
184 } lang_reloc_statement_type;
185
186 typedef struct lang_input_statement_struct
187 {
188   lang_statement_header_type header;
189   /* Name of this file.  */
190   const char *filename;
191   /* Name to use for the symbol giving address of text start */
192   /* Usually the same as filename, but for a file spec'd with -l
193      this is the -l switch itself rather than the filename.  */
194   const char *local_sym_name;
195     
196   bfd *the_bfd;
197     
198   boolean closed;
199   file_ptr passive_position;
200     
201   /* Symbol table of the file.  */
202   asymbol **asymbols;
203   unsigned int symbol_count;
204     
205   /* Point to the next file - whatever it is, wanders up and down
206      archives */
207     
208   union lang_statement_union  *next;
209   /* Point to the next file, but skips archive contents */
210   union  lang_statement_union  *next_real_file;
211     
212   boolean is_archive;
213     
214   /* 1 means search a set of directories for this file.  */
215   boolean search_dirs_flag;
216     
217   /* 1 means this is base file of incremental load.
218      Do not load this file's text or data.
219      Also default text_start to after this file's bss. */
220     
221   boolean just_syms_flag;
222     
223   boolean loaded;
224     
225     
226   /*    unsigned int globals_in_this_file;*/
227   const char *target;
228   boolean real;
229   asection *common_section;
230   asection *common_output_section;
231   boolean complained;
232 } lang_input_statement_type;
233
234 typedef struct
235 {
236   lang_statement_header_type header;
237   asection *section;
238   lang_input_statement_type *ifile;
239   
240 } lang_input_section_type;
241
242
243 typedef struct
244 {
245   lang_statement_header_type header;
246   asection *section;
247   union lang_statement_union *file;
248 } lang_afile_asection_pair_statement_type;
249
250 typedef struct lang_wild_statement_struct
251 {
252   lang_statement_header_type header;
253   const char *section_name;
254   const char *filename;
255   lang_statement_list_type children;
256 } lang_wild_statement_type;
257
258 typedef struct lang_address_statement_struct
259 {
260   lang_statement_header_type header;
261   const  char *section_name;
262   union  etree_union *address;
263 } lang_address_statement_type;
264
265 typedef struct
266 {
267   lang_statement_header_type header;
268   bfd_vma output_offset;
269   size_t size;
270   asection *output_section;
271   fill_type fill;
272 } lang_padding_statement_type;
273
274 /* A group statement collects a set of libraries together.  The
275    libraries are searched multiple times, until no new undefined
276    symbols are found.  The effect is to search a group of libraries as
277    though they were a single library.  */
278
279 typedef struct
280 {
281   lang_statement_header_type header;
282   lang_statement_list_type children;
283 } lang_group_statement_type;
284
285 typedef union lang_statement_union 
286 {
287   lang_statement_header_type header;
288   union lang_statement_union *next;
289   lang_wild_statement_type wild_statement;
290   lang_data_statement_type data_statement;
291   lang_reloc_statement_type reloc_statement;
292   lang_address_statement_type address_statement;
293   lang_output_section_statement_type output_section_statement;
294   lang_afile_asection_pair_statement_type afile_asection_pair_statement;
295   lang_assignment_statement_type assignment_statement;
296   lang_input_statement_type input_statement;
297   lang_target_statement_type target_statement;
298   lang_output_statement_type output_statement;
299   lang_input_section_type input_section;
300   lang_common_statement_type common_statement;
301   lang_object_symbols_statement_type object_symbols_statement;
302   lang_fill_statement_type fill_statement;
303   lang_padding_statement_type padding_statement;
304   lang_group_statement_type group_statement;
305 } lang_statement_union_type;
306
307 extern lang_output_section_statement_type *abs_output_section;
308 extern boolean lang_has_input_file;
309 extern etree_type *base;
310 extern lang_statement_list_type *stat_ptr;
311 extern boolean delete_output_file_on_failure;
312
313 extern void lang_init PARAMS ((void));
314 extern struct memory_region_struct *lang_memory_region_lookup
315   PARAMS ((const char *const));
316 extern void lang_map PARAMS ((void));
317 extern void lang_set_flags PARAMS ((int *, const char *));
318 extern void lang_add_output PARAMS ((const char *, int from_script));
319 extern void lang_enter_output_section_statement
320   PARAMS ((const char *output_section_statement_name,
321            etree_type * address_exp,
322            int flags,
323            bfd_vma block_value,
324            etree_type *align,
325            etree_type *subalign,
326            etree_type *));
327 extern void lang_final PARAMS ((void));
328 extern void lang_process PARAMS ((void));
329 extern void lang_section_start PARAMS ((const char *, union etree_union *));
330 extern void lang_add_entry PARAMS ((const char *, int));
331 extern void lang_add_target PARAMS ((const char *));
332 extern void lang_add_wild PARAMS ((const char *const , const char *const));
333 extern void lang_add_map PARAMS ((const char *));
334 extern void lang_add_fill PARAMS ((int));
335 extern void lang_add_assignment PARAMS ((union etree_union *));
336 extern void lang_add_attribute PARAMS ((enum statement_enum));
337 extern void lang_startup PARAMS ((const char *));
338 extern void lang_float PARAMS ((enum bfd_boolean));
339 extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
340                                                          const char *));
341 extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
342 extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
343                                                      const char *));
344 extern void lang_statement_append PARAMS ((struct statement_list *,
345                                            union lang_statement_union *,
346                                            union lang_statement_union **));
347 extern void lang_for_each_input_file
348   PARAMS ((void (*dothis) (lang_input_statement_type *)));
349 extern void lang_for_each_file
350   PARAMS ((void (*dothis) (lang_input_statement_type *)));
351 extern bfd_vma lang_do_assignments
352   PARAMS ((lang_statement_union_type * s,
353            lang_output_section_statement_type *output_section_statement,
354            fill_type fill,
355            bfd_vma dot));
356
357 #define LANG_FOR_EACH_INPUT_STATEMENT(statement)                \
358   extern lang_statement_list_type file_chain;                   \
359   lang_input_statement_type *statement;                         \
360   for (statement = (lang_input_statement_type *)file_chain.head;\
361        statement != (lang_input_statement_type *)NULL;          \
362        statement = (lang_input_statement_type *)statement->next)\
363   
364 extern void lang_process PARAMS ((void));
365 extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
366 extern lang_output_section_statement_type *lang_output_section_find
367   PARAMS ((const char * const));
368 extern lang_input_statement_type *lang_add_input_file
369   PARAMS ((const char *name, lang_input_file_enum_type file_type,
370            const char *target));
371 extern void lang_add_keepsyms_file PARAMS ((const char *filename));
372 extern lang_output_section_statement_type *
373   lang_output_section_statement_lookup PARAMS ((const char * const name));
374 extern void ldlang_add_undef PARAMS ((const char *const name));
375 extern void lang_add_output_format PARAMS ((const char *, const char *,
376                                             const char *, int from_script));
377 extern void lang_list_init PARAMS ((lang_statement_list_type*));
378 extern void lang_add_data PARAMS ((int type, union etree_union *));
379 extern void lang_add_reloc
380   PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
381            asection *section, const char *name, union etree_union *addend));
382 extern void lang_for_each_statement
383   PARAMS ((void (*func) (lang_statement_union_type *)));
384 extern PTR stat_alloc PARAMS ((size_t size));
385 extern bfd_vma lang_size_sections
386   PARAMS ((lang_statement_union_type *s,
387            lang_output_section_statement_type *output_section_statement,
388            lang_statement_union_type **prev, fill_type fill,
389            bfd_vma dot, boolean relax));
390 extern void lang_enter_group PARAMS ((void));
391 extern void lang_leave_group PARAMS ((void));
392 extern void wild_doit
393   PARAMS ((lang_statement_list_type *ptr, asection *section,
394            lang_output_section_statement_type *output,
395            lang_input_statement_type *file));
396
397 #endif