* gasp.c (change_base): Don't modify numbers in strings. (pr7583)
[deliverable/binutils-gdb.git] / ld / ldlang.h
CommitLineData
fcf276c4 1/* ldlang.h - linker command language support
943fbd5b 2 Copyright 1991, 1992, 1993, 1994, 1995 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
943fbd5b 18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2fa0b342 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,
60e8a534 67 lang_reloc_statement_enum,
c611e285
SC
68 lang_target_statement_enum,
69 lang_output_statement_enum,
70 lang_padding_statement_enum,
943fbd5b
KR
71 lang_group_statement_enum,
72
c611e285 73 lang_afile_asection_pair_statement_enum,
fcf276c4
ILT
74 lang_constructors_statement_enum
75 } type;
76} lang_statement_header_type;
2fa0b342
DHW
77
78
79typedef struct
fcf276c4
ILT
80{
81 lang_statement_header_type header;
82 union etree_union *exp;
83} lang_assignment_statement_type;
2fa0b342
DHW
84
85
fcf276c4
ILT
86typedef struct lang_target_statement_struct
87{
2fa0b342 88 lang_statement_header_type header;
fcf276c4 89 const char *target;
2fa0b342
DHW
90} lang_target_statement_type;
91
92
fcf276c4
ILT
93typedef struct lang_output_statement_struct
94{
2fa0b342 95 lang_statement_header_type header;
fcf276c4 96 const char *name;
2fa0b342
DHW
97} lang_output_statement_type;
98
99
100typedef struct lang_output_section_statement_struct
fcf276c4
ILT
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;
c611e285 110
fcf276c4
ILT
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;
2fa0b342
DHW
123
124
fcf276c4
ILT
125typedef struct
126{
2fa0b342
DHW
127 lang_statement_header_type header;
128} lang_common_statement_type;
129
fcf276c4
ILT
130typedef struct
131{
2fa0b342
DHW
132 lang_statement_header_type header;
133} lang_object_symbols_statement_type;
134
fcf276c4
ILT
135typedef struct
136{
2fa0b342 137 lang_statement_header_type header;
1418c83b 138 fill_type fill;
bfbdc80f
SC
139 int size;
140 asection *output_section;
2fa0b342
DHW
141} lang_fill_statement_type;
142
fcf276c4
ILT
143typedef struct
144{
2fa0b342
DHW
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
60e8a534 153/* Generate a reloc in the output file. */
2fa0b342 154
60e8a534
ILT
155typedef struct
156{
157 lang_statement_header_type header;
158
159 /* Reloc to generate. */
160 bfd_reloc_code_real_type reloc;
2fa0b342 161
60e8a534 162 /* Reloc howto structure. */
943fbd5b 163 reloc_howto_type *howto;
60e8a534
ILT
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;
2fa0b342
DHW
185
186typedef struct lang_input_statement_struct
fcf276c4
ILT
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;
c611e285 195
fcf276c4 196 bfd *the_bfd;
c611e285 197
fcf276c4
ILT
198 boolean closed;
199 file_ptr passive_position;
c611e285 200
fcf276c4
ILT
201 /* Symbol table of the file. */
202 asymbol **asymbols;
203 unsigned int symbol_count;
c611e285 204
fcf276c4
ILT
205 /* Point to the next file - whatever it is, wanders up and down
206 archives */
c611e285 207
fcf276c4
ILT
208 union lang_statement_union *next;
209 /* Point to the next file, but skips archive contents */
210 union lang_statement_union *next_real_file;
c611e285 211
fcf276c4 212 boolean is_archive;
c611e285 213
fcf276c4
ILT
214 /* 1 means search a set of directories for this file. */
215 boolean search_dirs_flag;
c611e285 216
fcf276c4
ILT
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. */
c611e285 220
fcf276c4 221 boolean just_syms_flag;
c611e285 222
fcf276c4 223 boolean loaded;
c611e285 224
c611e285 225
fcf276c4
ILT
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
234typedef struct
235{
2fa0b342
DHW
236 lang_statement_header_type header;
237 asection *section;
238 lang_input_statement_type *ifile;
c611e285 239
2fa0b342
DHW
240} lang_input_section_type;
241
242
fcf276c4
ILT
243typedef struct
244{
2fa0b342
DHW
245 lang_statement_header_type header;
246 asection *section;
247 union lang_statement_union *file;
248} lang_afile_asection_pair_statement_type;
249
fcf276c4
ILT
250typedef struct lang_wild_statement_struct
251{
2fa0b342 252 lang_statement_header_type header;
fcf276c4
ILT
253 const char *section_name;
254 const char *filename;
2fa0b342
DHW
255 lang_statement_list_type children;
256} lang_wild_statement_type;
257
fcf276c4
ILT
258typedef struct lang_address_statement_struct
259{
2fa0b342 260 lang_statement_header_type header;
fcf276c4 261 const char *section_name;
2fa0b342
DHW
262 union etree_union *address;
263} lang_address_statement_type;
264
fcf276c4
ILT
265typedef struct
266{
2fa0b342
DHW
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
943fbd5b
KR
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
279typedef struct
280{
281 lang_statement_header_type header;
282 lang_statement_list_type children;
283} lang_group_statement_type;
284
2fa0b342 285typedef union lang_statement_union
fcf276c4
ILT
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;
60e8a534 291 lang_reloc_statement_type reloc_statement;
fcf276c4
ILT
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;
943fbd5b 304 lang_group_statement_type group_statement;
fcf276c4
ILT
305} lang_statement_union_type;
306
fcf276c4 307extern lang_output_section_statement_type *abs_output_section;
fcf276c4 308extern boolean lang_has_input_file;
fcf276c4
ILT
309extern etree_type *base;
310extern lang_statement_list_type *stat_ptr;
311extern boolean delete_output_file_on_failure;
fcf276c4
ILT
312
313extern void lang_init PARAMS ((void));
314extern struct memory_region_struct *lang_memory_region_lookup
315 PARAMS ((const char *const));
316extern void lang_map PARAMS ((void));
317extern void lang_set_flags PARAMS ((int *, const char *));
318extern void lang_add_output PARAMS ((const char *, int from_script));
319extern 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,
755f42fe 326 etree_type *));
fcf276c4 327extern void lang_final PARAMS ((void));
fcf276c4
ILT
328extern void lang_process PARAMS ((void));
329extern void lang_section_start PARAMS ((const char *, union etree_union *));
60e8a534 330extern void lang_add_entry PARAMS ((const char *, int));
fcf276c4
ILT
331extern void lang_add_target PARAMS ((const char *));
332extern void lang_add_wild PARAMS ((const char *const , const char *const));
333extern void lang_add_map PARAMS ((const char *));
334extern void lang_add_fill PARAMS ((int));
335extern void lang_add_assignment PARAMS ((union etree_union *));
336extern void lang_add_attribute PARAMS ((enum statement_enum));
337extern void lang_startup PARAMS ((const char *));
338extern void lang_float PARAMS ((enum bfd_boolean));
339extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
340 const char *));
341extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
342extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
343 const char *));
344extern void lang_statement_append PARAMS ((struct statement_list *,
345 union lang_statement_union *,
346 union lang_statement_union **));
943fbd5b
KR
347extern void lang_for_each_input_file
348 PARAMS ((void (*dothis) (lang_input_statement_type *)));
fcf276c4
ILT
349extern void lang_for_each_file
350 PARAMS ((void (*dothis) (lang_input_statement_type *)));
943fbd5b
KR
351extern 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));
fcf276c4
ILT
356
357#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
2fa0b342
DHW
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)\
c611e285 363
fcf276c4
ILT
364extern void lang_process PARAMS ((void));
365extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
366extern lang_output_section_statement_type *lang_output_section_find
367 PARAMS ((const char * const));
368extern lang_input_statement_type *lang_add_input_file
369 PARAMS ((const char *name, lang_input_file_enum_type file_type,
370 const char *target));
371extern void lang_add_keepsyms_file PARAMS ((const char *filename));
372extern lang_output_section_statement_type *
373 lang_output_section_statement_lookup PARAMS ((const char * const name));
374extern void ldlang_add_undef PARAMS ((const char *const name));
943fbd5b
KR
375extern void lang_add_output_format PARAMS ((const char *, const char *,
376 const char *, int from_script));
fcf276c4
ILT
377extern void lang_list_init PARAMS ((lang_statement_list_type*));
378extern void lang_add_data PARAMS ((int type, union etree_union *));
60e8a534 379extern void lang_add_reloc
943fbd5b 380 PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
60e8a534 381 asection *section, const char *name, union etree_union *addend));
755f42fe
ILT
382extern void lang_for_each_statement
383 PARAMS ((void (*func) (lang_statement_union_type *)));
fcf276c4 384extern PTR stat_alloc PARAMS ((size_t size));
60e8a534
ILT
385extern 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));
943fbd5b
KR
390extern void lang_enter_group PARAMS ((void));
391extern void lang_leave_group PARAMS ((void));
392extern 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));
fcf276c4
ILT
396
397#endif
This page took 0.160268 seconds and 4 git commands to generate.