* ldlex.l: Removed duplicate rules.
[deliverable/binutils-gdb.git] / ld / ldlang.h
CommitLineData
fcf276c4
ILT
1/* ldlang.h - linker command language support
2 Copyright 1991, 1992, 1993 Free Software Foundation, Inc.
c611e285 3
2fa0b342 4 This file is part of GLD, the Gnu Linker.
c611e285 5
2fa0b342
DHW
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.
c611e285 10
2fa0b342
DHW
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.
c611e285 15
2fa0b342
DHW
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
fcf276c4
ILT
20#ifndef LDLANG_H
21#define LDLANG_H
2fa0b342 22
fcf276c4
ILT
23typedef enum
24{
2fa0b342
DHW
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,
c611e285 29 lang_input_file_is_search_file_enum,
fcf276c4
ILT
30 lang_input_file_is_file_enum
31} lang_input_file_enum_type;
2fa0b342 32
755f42fe 33typedef unsigned int fill_type;
fcf276c4
ILT
34typedef struct statement_list
35{
2fa0b342
DHW
36 union lang_statement_union *head;
37 union lang_statement_union **tail;
38} lang_statement_list_type;
39
40
fcf276c4
ILT
41typedef struct memory_region_struct
42{
2fa0b342
DHW
43 char *name;
44 struct memory_region_struct *next;
45 bfd_vma origin;
fcf276c4 46 bfd_size_type length;
2fa0b342 47 bfd_vma current;
fcf276c4 48 bfd_size_type old_length;
c611e285 49 int flags;
1bd1fa2d 50 boolean had_full_message;
2fa0b342
DHW
51} lang_memory_region_type ;
52
53typedef struct lang_statement_header_struct
fcf276c4
ILT
54{
55 union lang_statement_union *next;
56 enum statement_enum
57 {
c611e285
SC
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,
fcf276c4
ILT
72 lang_constructors_statement_enum
73 } type;
74} lang_statement_header_type;
2fa0b342
DHW
75
76
77typedef struct
fcf276c4
ILT
78{
79 lang_statement_header_type header;
80 union etree_union *exp;
81} lang_assignment_statement_type;
2fa0b342
DHW
82
83
fcf276c4
ILT
84typedef struct lang_target_statement_struct
85{
2fa0b342 86 lang_statement_header_type header;
fcf276c4 87 const char *target;
2fa0b342
DHW
88} lang_target_statement_type;
89
90
fcf276c4
ILT
91typedef struct lang_output_statement_struct
92{
2fa0b342 93 lang_statement_header_type header;
fcf276c4 94 const char *name;
2fa0b342
DHW
95} lang_output_statement_type;
96
97
98typedef struct lang_output_section_statement_struct
fcf276c4
ILT
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;
c611e285 108
fcf276c4
ILT
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;
2fa0b342
DHW
121
122
fcf276c4
ILT
123typedef struct
124{
2fa0b342
DHW
125 lang_statement_header_type header;
126} lang_common_statement_type;
127
fcf276c4
ILT
128typedef struct
129{
2fa0b342
DHW
130 lang_statement_header_type header;
131} lang_object_symbols_statement_type;
132
fcf276c4
ILT
133typedef struct
134{
2fa0b342 135 lang_statement_header_type header;
1418c83b 136 fill_type fill;
bfbdc80f
SC
137 int size;
138 asection *output_section;
2fa0b342
DHW
139} lang_fill_statement_type;
140
fcf276c4
ILT
141typedef struct
142{
2fa0b342
DHW
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
154typedef struct lang_input_statement_struct
fcf276c4
ILT
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;
c611e285 163
fcf276c4 164 bfd *the_bfd;
c611e285 165
fcf276c4
ILT
166 boolean closed;
167 file_ptr passive_position;
c611e285 168
fcf276c4
ILT
169 /* Symbol table of the file. */
170 asymbol **asymbols;
171 unsigned int symbol_count;
c611e285 172
fcf276c4 173 /* For library members only */
c611e285 174
fcf276c4
ILT
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 */
c611e285 189
fcf276c4
ILT
190 union lang_statement_union *next;
191 /* Point to the next file, but skips archive contents */
192 union lang_statement_union *next_real_file;
c611e285 193
fcf276c4 194 boolean is_archive;
c611e285 195
fcf276c4
ILT
196 /* 1 means search a set of directories for this file. */
197 boolean search_dirs_flag;
c611e285 198
fcf276c4
ILT
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. */
c611e285 202
fcf276c4 203 boolean just_syms_flag;
c611e285 204
fcf276c4 205 boolean loaded;
c611e285 206
c611e285 207
fcf276c4
ILT
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
216typedef struct
217{
2fa0b342
DHW
218 lang_statement_header_type header;
219 asection *section;
220 lang_input_statement_type *ifile;
c611e285 221
2fa0b342
DHW
222} lang_input_section_type;
223
224
fcf276c4
ILT
225typedef struct
226{
2fa0b342
DHW
227 lang_statement_header_type header;
228 asection *section;
229 union lang_statement_union *file;
230} lang_afile_asection_pair_statement_type;
231
fcf276c4
ILT
232typedef struct lang_wild_statement_struct
233{
2fa0b342 234 lang_statement_header_type header;
fcf276c4
ILT
235 const char *section_name;
236 const char *filename;
2fa0b342
DHW
237 lang_statement_list_type children;
238} lang_wild_statement_type;
239
fcf276c4
ILT
240typedef struct lang_address_statement_struct
241{
2fa0b342 242 lang_statement_header_type header;
fcf276c4 243 const char *section_name;
2fa0b342
DHW
244 union etree_union *address;
245} lang_address_statement_type;
246
fcf276c4
ILT
247typedef struct
248{
2fa0b342
DHW
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
256typedef union lang_statement_union
fcf276c4
ILT
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
276extern bfd_size_type largest_section;
277extern lang_output_section_statement_type *abs_output_section;
fcf276c4 278extern boolean lang_has_input_file;
fcf276c4
ILT
279extern etree_type *base;
280extern lang_statement_list_type *stat_ptr;
281extern boolean delete_output_file_on_failure;
fcf276c4
ILT
282
283extern void lang_init PARAMS ((void));
284extern struct memory_region_struct *lang_memory_region_lookup
285 PARAMS ((const char *const));
286extern void lang_map PARAMS ((void));
287extern void lang_set_flags PARAMS ((int *, const char *));
288extern void lang_add_output PARAMS ((const char *, int from_script));
289extern 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,
755f42fe 296 etree_type *));
fcf276c4 297extern void lang_final PARAMS ((void));
fcf276c4
ILT
298extern void lang_process PARAMS ((void));
299extern void lang_section_start PARAMS ((const char *, union etree_union *));
300extern void lang_add_entry PARAMS ((const char *));
301extern void lang_add_target PARAMS ((const char *));
302extern void lang_add_wild PARAMS ((const char *const , const char *const));
303extern void lang_add_map PARAMS ((const char *));
304extern void lang_add_fill PARAMS ((int));
305extern void lang_add_assignment PARAMS ((union etree_union *));
306extern void lang_add_attribute PARAMS ((enum statement_enum));
307extern void lang_startup PARAMS ((const char *));
308extern void lang_float PARAMS ((enum bfd_boolean));
309extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
310 const char *));
311extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
312extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
313 const char *));
314extern void lang_statement_append PARAMS ((struct statement_list *,
315 union lang_statement_union *,
316 union lang_statement_union **));
317extern void lang_for_each_file
318 PARAMS ((void (*dothis) (lang_input_statement_type *)));
319
320#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
2fa0b342
DHW
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)\
c611e285 326
fcf276c4
ILT
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; \
c611e285 338 section != (asection *)NULL; \
fcf276c4
ILT
339 section = section->next) \
340 { \
341 x; \
342 } \
343 } \
344 }
2fa0b342 345
fcf276c4
ILT
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
358extern void lang_process PARAMS ((void));
359extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
360extern lang_output_section_statement_type *lang_output_section_find
361 PARAMS ((const char * const));
362extern lang_input_statement_type *lang_add_input_file
363 PARAMS ((const char *name, lang_input_file_enum_type file_type,
364 const char *target));
365extern void lang_add_keepsyms_file PARAMS ((const char *filename));
366extern lang_output_section_statement_type *
367 lang_output_section_statement_lookup PARAMS ((const char * const name));
368extern void ldlang_add_undef PARAMS ((const char *const name));
369extern void lang_add_output_format PARAMS ((const char *, int from_script));
370extern void lang_list_init PARAMS ((lang_statement_list_type*));
371extern void lang_add_data PARAMS ((int type, union etree_union *));
755f42fe
ILT
372extern void lang_for_each_statement
373 PARAMS ((void (*func) (lang_statement_union_type *)));
fcf276c4
ILT
374extern PTR stat_alloc PARAMS ((size_t size));
375
376#endif
This page took 0.136841 seconds and 4 git commands to generate.