* ldlex.l: Removed duplicate rules.
[deliverable/binutils-gdb.git] / ld / ldlang.h
1 /* ldlang.h - linker command language support
2 Copyright 1991, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, 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_target_statement_enum,
68 lang_output_statement_enum,
69 lang_padding_statement_enum,
70
71 lang_afile_asection_pair_statement_enum,
72 lang_constructors_statement_enum
73 } type;
74 } lang_statement_header_type;
75
76
77 typedef struct
78 {
79 lang_statement_header_type header;
80 union etree_union *exp;
81 } lang_assignment_statement_type;
82
83
84 typedef struct lang_target_statement_struct
85 {
86 lang_statement_header_type header;
87 const char *target;
88 } lang_target_statement_type;
89
90
91 typedef struct lang_output_statement_struct
92 {
93 lang_statement_header_type header;
94 const char *name;
95 } lang_output_statement_type;
96
97
98 typedef struct lang_output_section_statement_struct
99 {
100 lang_statement_header_type header;
101 union etree_union *addr_tree;
102 lang_statement_list_type children;
103 const char *memspec;
104 union lang_statement_union *next;
105 const char *name;
106
107 boolean processed;
108
109 asection *bfd_section;
110 int flags; /* Or together of all input sections */
111 int loadable; /* set from NOLOAD flag in script */
112 struct memory_region_struct *region;
113 size_t block_value;
114 fill_type fill;
115
116 int subsection_alignment; /* alignment of components */
117 int section_alignment; /* alignment of start of section */
118
119 union etree_union *load_base;
120 } lang_output_section_statement_type;
121
122
123 typedef struct
124 {
125 lang_statement_header_type header;
126 } lang_common_statement_type;
127
128 typedef struct
129 {
130 lang_statement_header_type header;
131 } lang_object_symbols_statement_type;
132
133 typedef struct
134 {
135 lang_statement_header_type header;
136 fill_type fill;
137 int size;
138 asection *output_section;
139 } lang_fill_statement_type;
140
141 typedef struct
142 {
143 lang_statement_header_type header;
144 unsigned int type;
145 union etree_union *exp;
146 bfd_vma value;
147 asection *output_section;
148 bfd_vma output_vma;
149 } lang_data_statement_type;
150
151
152
153
154 typedef struct lang_input_statement_struct
155 {
156 lang_statement_header_type header;
157 /* Name of this file. */
158 const char *filename;
159 /* Name to use for the symbol giving address of text start */
160 /* Usually the same as filename, but for a file spec'd with -l
161 this is the -l switch itself rather than the filename. */
162 const char *local_sym_name;
163
164 bfd *the_bfd;
165
166 boolean closed;
167 file_ptr passive_position;
168
169 /* Symbol table of the file. */
170 asymbol **asymbols;
171 unsigned int symbol_count;
172
173 /* For library members only */
174
175 /* For a library, points to chain of entries for the library members. */
176 struct lang_input_statement_struct *subfiles;
177
178 /* Size of contents of this file, if library member. */
179 bfd_size_type total_size;
180
181 /* For library member, points to the library's own entry. */
182 struct lang_input_statement_struct *superfile;
183
184 /* For library member, points to next entry for next member. */
185 struct lang_input_statement_struct *chain;
186
187 /* Point to the next file - whatever it is, wanders up and down
188 archives */
189
190 union lang_statement_union *next;
191 /* Point to the next file, but skips archive contents */
192 union lang_statement_union *next_real_file;
193
194 boolean is_archive;
195
196 /* 1 means search a set of directories for this file. */
197 boolean search_dirs_flag;
198
199 /* 1 means this is base file of incremental load.
200 Do not load this file's text or data.
201 Also default text_start to after this file's bss. */
202
203 boolean just_syms_flag;
204
205 boolean loaded;
206
207
208 /* unsigned int globals_in_this_file;*/
209 const char *target;
210 boolean real;
211 asection *common_section;
212 asection *common_output_section;
213 boolean complained;
214 } lang_input_statement_type;
215
216 typedef struct
217 {
218 lang_statement_header_type header;
219 asection *section;
220 lang_input_statement_type *ifile;
221
222 } lang_input_section_type;
223
224
225 typedef struct
226 {
227 lang_statement_header_type header;
228 asection *section;
229 union lang_statement_union *file;
230 } lang_afile_asection_pair_statement_type;
231
232 typedef struct lang_wild_statement_struct
233 {
234 lang_statement_header_type header;
235 const char *section_name;
236 const char *filename;
237 lang_statement_list_type children;
238 } lang_wild_statement_type;
239
240 typedef struct lang_address_statement_struct
241 {
242 lang_statement_header_type header;
243 const char *section_name;
244 union etree_union *address;
245 } lang_address_statement_type;
246
247 typedef struct
248 {
249 lang_statement_header_type header;
250 bfd_vma output_offset;
251 size_t size;
252 asection *output_section;
253 fill_type fill;
254 } lang_padding_statement_type;
255
256 typedef union lang_statement_union
257 {
258 lang_statement_header_type header;
259 union lang_statement_union *next;
260 lang_wild_statement_type wild_statement;
261 lang_data_statement_type data_statement;
262 lang_address_statement_type address_statement;
263 lang_output_section_statement_type output_section_statement;
264 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
265 lang_assignment_statement_type assignment_statement;
266 lang_input_statement_type input_statement;
267 lang_target_statement_type target_statement;
268 lang_output_statement_type output_statement;
269 lang_input_section_type input_section;
270 lang_common_statement_type common_statement;
271 lang_object_symbols_statement_type object_symbols_statement;
272 lang_fill_statement_type fill_statement;
273 lang_padding_statement_type padding_statement;
274 } lang_statement_union_type;
275
276 extern bfd_size_type largest_section;
277 extern lang_output_section_statement_type *abs_output_section;
278 extern boolean lang_has_input_file;
279 extern etree_type *base;
280 extern lang_statement_list_type *stat_ptr;
281 extern boolean delete_output_file_on_failure;
282
283 extern void lang_init PARAMS ((void));
284 extern struct memory_region_struct *lang_memory_region_lookup
285 PARAMS ((const char *const));
286 extern void lang_map PARAMS ((void));
287 extern void lang_set_flags PARAMS ((int *, const char *));
288 extern void lang_add_output PARAMS ((const char *, int from_script));
289 extern void lang_enter_output_section_statement
290 PARAMS ((const char *output_section_statement_name,
291 etree_type * address_exp,
292 int flags,
293 bfd_vma block_value,
294 etree_type *align,
295 etree_type *subalign,
296 etree_type *));
297 extern void lang_final PARAMS ((void));
298 extern void lang_process PARAMS ((void));
299 extern void lang_section_start PARAMS ((const char *, union etree_union *));
300 extern void lang_add_entry PARAMS ((const char *));
301 extern void lang_add_target PARAMS ((const char *));
302 extern void lang_add_wild PARAMS ((const char *const , const char *const));
303 extern void lang_add_map PARAMS ((const char *));
304 extern void lang_add_fill PARAMS ((int));
305 extern void lang_add_assignment PARAMS ((union etree_union *));
306 extern void lang_add_attribute PARAMS ((enum statement_enum));
307 extern void lang_startup PARAMS ((const char *));
308 extern void lang_float PARAMS ((enum bfd_boolean));
309 extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
310 const char *));
311 extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
312 extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
313 const char *));
314 extern void lang_statement_append PARAMS ((struct statement_list *,
315 union lang_statement_union *,
316 union lang_statement_union **));
317 extern void lang_for_each_file
318 PARAMS ((void (*dothis) (lang_input_statement_type *)));
319
320 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
321 extern lang_statement_list_type file_chain; \
322 lang_input_statement_type *statement; \
323 for (statement = (lang_input_statement_type *)file_chain.head;\
324 statement != (lang_input_statement_type *)NULL; \
325 statement = (lang_input_statement_type *)statement->next)\
326
327 #define LANG_FOR_EACH_INPUT_SECTION(statement, abfd, section, x) \
328 { \
329 extern lang_statement_list_type file_chain; \
330 lang_input_statement_type *statement; \
331 for (statement = (lang_input_statement_type *)file_chain.head; \
332 statement != (lang_input_statement_type *)NULL; \
333 statement = (lang_input_statement_type *)statement->next) \
334 { \
335 asection *section; \
336 bfd *abfd = statement->the_bfd; \
337 for (section = abfd->sections; \
338 section != (asection *)NULL; \
339 section = section->next) \
340 { \
341 x; \
342 } \
343 } \
344 }
345
346 #define LANG_FOR_EACH_OUTPUT_SECTION(section, x) \
347 { \
348 extern bfd *output_bfd; \
349 asection *section; \
350 for (section = output_bfd->sections; \
351 section != (asection *)NULL; \
352 section = section->next) \
353 { \
354 x; \
355 } \
356 }
357
358 extern void lang_process PARAMS ((void));
359 extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
360 extern lang_output_section_statement_type *lang_output_section_find
361 PARAMS ((const char * const));
362 extern lang_input_statement_type *lang_add_input_file
363 PARAMS ((const char *name, lang_input_file_enum_type file_type,
364 const char *target));
365 extern void lang_add_keepsyms_file PARAMS ((const char *filename));
366 extern lang_output_section_statement_type *
367 lang_output_section_statement_lookup PARAMS ((const char * const name));
368 extern void ldlang_add_undef PARAMS ((const char *const name));
369 extern void lang_add_output_format PARAMS ((const char *, int from_script));
370 extern void lang_list_init PARAMS ((lang_statement_list_type*));
371 extern void lang_add_data PARAMS ((int type, union etree_union *));
372 extern void lang_for_each_statement
373 PARAMS ((void (*func) (lang_statement_union_type *)));
374 extern PTR stat_alloc PARAMS ((size_t size));
375
376 #endif
This page took 0.036271 seconds and 4 git commands to generate.