Add EXTEND11().
[deliverable/binutils-gdb.git] / ld / ldlang.h
CommitLineData
fcf276c4 1/* ldlang.h - linker command language support
582dd77f 2 Copyright 1991, 92, 93, 94, 95, 1996 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
582dd77f
ILT
99/* Section types specified in a linker script. */
100
101enum section_type
102{
103 normal_section,
104 dsect_section,
105 copy_section,
106 noload_section,
107 info_section,
108 overlay_section
109};
2fa0b342 110
3c8deccc
ILT
111/* This structure holds a list of program headers describing segments
112 in which this section should be placed. */
113
114struct lang_output_section_phdr_list
115{
116 struct lang_output_section_phdr_list *next;
117 const char *name;
118 boolean used;
119};
120
2fa0b342 121typedef struct lang_output_section_statement_struct
fcf276c4
ILT
122{
123 lang_statement_header_type header;
124 union etree_union *addr_tree;
125 lang_statement_list_type children;
126 const char *memspec;
127 union lang_statement_union *next;
128 const char *name;
129
130 boolean processed;
c611e285 131
fcf276c4
ILT
132 asection *bfd_section;
133 int flags; /* Or together of all input sections */
582dd77f 134 enum section_type sectype;
fcf276c4
ILT
135 struct memory_region_struct *region;
136 size_t block_value;
137 fill_type fill;
138
139 int subsection_alignment; /* alignment of components */
140 int section_alignment; /* alignment of start of section */
141
3c8deccc
ILT
142 union etree_union *load_base;
143
144 struct lang_output_section_phdr_list *phdrs;
fcf276c4 145} lang_output_section_statement_type;
2fa0b342
DHW
146
147
fcf276c4
ILT
148typedef struct
149{
2fa0b342
DHW
150 lang_statement_header_type header;
151} lang_common_statement_type;
152
fcf276c4
ILT
153typedef struct
154{
2fa0b342
DHW
155 lang_statement_header_type header;
156} lang_object_symbols_statement_type;
157
fcf276c4
ILT
158typedef struct
159{
2fa0b342 160 lang_statement_header_type header;
1418c83b 161 fill_type fill;
bfbdc80f
SC
162 int size;
163 asection *output_section;
2fa0b342
DHW
164} lang_fill_statement_type;
165
fcf276c4
ILT
166typedef struct
167{
2fa0b342
DHW
168 lang_statement_header_type header;
169 unsigned int type;
170 union etree_union *exp;
171 bfd_vma value;
172 asection *output_section;
173 bfd_vma output_vma;
174} lang_data_statement_type;
175
60e8a534 176/* Generate a reloc in the output file. */
2fa0b342 177
60e8a534
ILT
178typedef struct
179{
180 lang_statement_header_type header;
181
182 /* Reloc to generate. */
183 bfd_reloc_code_real_type reloc;
2fa0b342 184
60e8a534 185 /* Reloc howto structure. */
943fbd5b 186 reloc_howto_type *howto;
60e8a534
ILT
187
188 /* Section to generate reloc against. Exactly one of section and
189 name must be NULL. */
190 asection *section;
191
192 /* Name of symbol to generate reloc against. Exactly one of section
193 and name must be NULL. */
194 const char *name;
195
196 /* Expression for addend. */
197 union etree_union *addend_exp;
198
199 /* Resolved addend. */
200 bfd_vma addend_value;
201
202 /* Output section where reloc should be performed. */
203 asection *output_section;
204
205 /* VMA within output section. */
206 bfd_vma output_vma;
207} lang_reloc_statement_type;
2fa0b342
DHW
208
209typedef struct lang_input_statement_struct
fcf276c4
ILT
210{
211 lang_statement_header_type header;
212 /* Name of this file. */
213 const char *filename;
214 /* Name to use for the symbol giving address of text start */
215 /* Usually the same as filename, but for a file spec'd with -l
216 this is the -l switch itself rather than the filename. */
217 const char *local_sym_name;
c611e285 218
fcf276c4 219 bfd *the_bfd;
c611e285 220
fcf276c4
ILT
221 boolean closed;
222 file_ptr passive_position;
c611e285 223
fcf276c4
ILT
224 /* Symbol table of the file. */
225 asymbol **asymbols;
226 unsigned int symbol_count;
c611e285 227
fcf276c4
ILT
228 /* Point to the next file - whatever it is, wanders up and down
229 archives */
c611e285 230
fcf276c4
ILT
231 union lang_statement_union *next;
232 /* Point to the next file, but skips archive contents */
233 union lang_statement_union *next_real_file;
c611e285 234
fcf276c4 235 boolean is_archive;
c611e285 236
fcf276c4
ILT
237 /* 1 means search a set of directories for this file. */
238 boolean search_dirs_flag;
c611e285 239
fcf276c4
ILT
240 /* 1 means this is base file of incremental load.
241 Do not load this file's text or data.
242 Also default text_start to after this file's bss. */
c611e285 243
fcf276c4 244 boolean just_syms_flag;
3c8deccc
ILT
245
246 /* Whether to search for this entry as a dynamic archive. */
247 boolean dynamic;
248
249 /* Whether to include the entire contents of an archive. */
250 boolean whole_archive;
251
fcf276c4 252 boolean loaded;
c611e285 253
fcf276c4
ILT
254 /* unsigned int globals_in_this_file;*/
255 const char *target;
256 boolean real;
fcf276c4
ILT
257} lang_input_statement_type;
258
259typedef struct
260{
2fa0b342
DHW
261 lang_statement_header_type header;
262 asection *section;
263 lang_input_statement_type *ifile;
c611e285 264
2fa0b342
DHW
265} lang_input_section_type;
266
267
fcf276c4
ILT
268typedef struct
269{
2fa0b342
DHW
270 lang_statement_header_type header;
271 asection *section;
272 union lang_statement_union *file;
273} lang_afile_asection_pair_statement_type;
274
fcf276c4
ILT
275typedef struct lang_wild_statement_struct
276{
2fa0b342 277 lang_statement_header_type header;
fcf276c4
ILT
278 const char *section_name;
279 const char *filename;
2fa0b342
DHW
280 lang_statement_list_type children;
281} lang_wild_statement_type;
282
fcf276c4
ILT
283typedef struct lang_address_statement_struct
284{
2fa0b342 285 lang_statement_header_type header;
fcf276c4 286 const char *section_name;
2fa0b342
DHW
287 union etree_union *address;
288} lang_address_statement_type;
289
fcf276c4
ILT
290typedef struct
291{
2fa0b342
DHW
292 lang_statement_header_type header;
293 bfd_vma output_offset;
294 size_t size;
295 asection *output_section;
296 fill_type fill;
297} lang_padding_statement_type;
298
943fbd5b
KR
299/* A group statement collects a set of libraries together. The
300 libraries are searched multiple times, until no new undefined
301 symbols are found. The effect is to search a group of libraries as
302 though they were a single library. */
303
304typedef struct
305{
306 lang_statement_header_type header;
307 lang_statement_list_type children;
308} lang_group_statement_type;
309
2fa0b342 310typedef union lang_statement_union
fcf276c4
ILT
311{
312 lang_statement_header_type header;
313 union lang_statement_union *next;
314 lang_wild_statement_type wild_statement;
315 lang_data_statement_type data_statement;
60e8a534 316 lang_reloc_statement_type reloc_statement;
fcf276c4
ILT
317 lang_address_statement_type address_statement;
318 lang_output_section_statement_type output_section_statement;
319 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
320 lang_assignment_statement_type assignment_statement;
321 lang_input_statement_type input_statement;
322 lang_target_statement_type target_statement;
323 lang_output_statement_type output_statement;
324 lang_input_section_type input_section;
325 lang_common_statement_type common_statement;
326 lang_object_symbols_statement_type object_symbols_statement;
327 lang_fill_statement_type fill_statement;
328 lang_padding_statement_type padding_statement;
943fbd5b 329 lang_group_statement_type group_statement;
fcf276c4
ILT
330} lang_statement_union_type;
331
3c8deccc
ILT
332/* This structure holds information about a program header, from the
333 PHDRS command in the linker script. */
334
335struct lang_phdr
336{
337 struct lang_phdr *next;
338 const char *name;
339 unsigned long type;
340 boolean filehdr;
341 boolean phdrs;
342 etree_type *at;
343 etree_type *flags;
344};
345
582dd77f
ILT
346/* This structure is used to hold a list of sections which may not
347 cross reference each other. */
348
349struct lang_nocrossref
350{
351 struct lang_nocrossref *next;
352 const char *name;
353};
354
355/* The list of nocrossref lists. */
356
357struct lang_nocrossrefs
358{
359 struct lang_nocrossrefs *next;
360 struct lang_nocrossref *list;
361};
362
363extern struct lang_nocrossrefs *nocrossref_list;
364
fcf276c4 365extern lang_output_section_statement_type *abs_output_section;
fcf276c4 366extern boolean lang_has_input_file;
fcf276c4
ILT
367extern etree_type *base;
368extern lang_statement_list_type *stat_ptr;
369extern boolean delete_output_file_on_failure;
fcf276c4 370
3c8deccc
ILT
371extern const char *entry_symbol;
372extern boolean entry_from_cmdline;
373
fcf276c4
ILT
374extern void lang_init PARAMS ((void));
375extern struct memory_region_struct *lang_memory_region_lookup
376 PARAMS ((const char *const));
377extern void lang_map PARAMS ((void));
378extern void lang_set_flags PARAMS ((int *, const char *));
379extern void lang_add_output PARAMS ((const char *, int from_script));
380extern void lang_enter_output_section_statement
381 PARAMS ((const char *output_section_statement_name,
382 etree_type * address_exp,
582dd77f 383 enum section_type sectype,
fcf276c4
ILT
384 bfd_vma block_value,
385 etree_type *align,
386 etree_type *subalign,
755f42fe 387 etree_type *));
fcf276c4 388extern void lang_final PARAMS ((void));
fcf276c4
ILT
389extern void lang_process PARAMS ((void));
390extern void lang_section_start PARAMS ((const char *, union etree_union *));
3c8deccc 391extern void lang_add_entry PARAMS ((const char *, boolean));
fcf276c4
ILT
392extern void lang_add_target PARAMS ((const char *));
393extern void lang_add_wild PARAMS ((const char *const , const char *const));
394extern void lang_add_map PARAMS ((const char *));
395extern void lang_add_fill PARAMS ((int));
396extern void lang_add_assignment PARAMS ((union etree_union *));
397extern void lang_add_attribute PARAMS ((enum statement_enum));
398extern void lang_startup PARAMS ((const char *));
399extern void lang_float PARAMS ((enum bfd_boolean));
400extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
401 const char *));
402extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
403extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
404 const char *));
405extern void lang_statement_append PARAMS ((struct statement_list *,
406 union lang_statement_union *,
407 union lang_statement_union **));
943fbd5b
KR
408extern void lang_for_each_input_file
409 PARAMS ((void (*dothis) (lang_input_statement_type *)));
fcf276c4
ILT
410extern void lang_for_each_file
411 PARAMS ((void (*dothis) (lang_input_statement_type *)));
943fbd5b
KR
412extern bfd_vma lang_do_assignments
413 PARAMS ((lang_statement_union_type * s,
414 lang_output_section_statement_type *output_section_statement,
415 fill_type fill,
416 bfd_vma dot));
fcf276c4
ILT
417
418#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
2fa0b342
DHW
419 extern lang_statement_list_type file_chain; \
420 lang_input_statement_type *statement; \
421 for (statement = (lang_input_statement_type *)file_chain.head;\
422 statement != (lang_input_statement_type *)NULL; \
423 statement = (lang_input_statement_type *)statement->next)\
c611e285 424
fcf276c4
ILT
425extern void lang_process PARAMS ((void));
426extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
427extern lang_output_section_statement_type *lang_output_section_find
428 PARAMS ((const char * const));
429extern lang_input_statement_type *lang_add_input_file
430 PARAMS ((const char *name, lang_input_file_enum_type file_type,
431 const char *target));
432extern void lang_add_keepsyms_file PARAMS ((const char *filename));
433extern lang_output_section_statement_type *
434 lang_output_section_statement_lookup PARAMS ((const char * const name));
435extern void ldlang_add_undef PARAMS ((const char *const name));
943fbd5b
KR
436extern void lang_add_output_format PARAMS ((const char *, const char *,
437 const char *, int from_script));
fcf276c4
ILT
438extern void lang_list_init PARAMS ((lang_statement_list_type*));
439extern void lang_add_data PARAMS ((int type, union etree_union *));
60e8a534 440extern void lang_add_reloc
943fbd5b 441 PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
60e8a534 442 asection *section, const char *name, union etree_union *addend));
755f42fe
ILT
443extern void lang_for_each_statement
444 PARAMS ((void (*func) (lang_statement_union_type *)));
fcf276c4 445extern PTR stat_alloc PARAMS ((size_t size));
60e8a534
ILT
446extern bfd_vma lang_size_sections
447 PARAMS ((lang_statement_union_type *s,
448 lang_output_section_statement_type *output_section_statement,
449 lang_statement_union_type **prev, fill_type fill,
450 bfd_vma dot, boolean relax));
943fbd5b
KR
451extern void lang_enter_group PARAMS ((void));
452extern void lang_leave_group PARAMS ((void));
453extern void wild_doit
454 PARAMS ((lang_statement_list_type *ptr, asection *section,
455 lang_output_section_statement_type *output,
456 lang_input_statement_type *file));
3c8deccc
ILT
457extern void lang_new_phdr
458 PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
459 etree_type *));
460extern void lang_section_in_phdr PARAMS ((const char *));
582dd77f 461extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *));
fcf276c4
ILT
462
463#endif
This page took 0.243823 seconds and 4 git commands to generate.