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