* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Ensure no copy relocs
[deliverable/binutils-gdb.git] / ld / ldlang.h
CommitLineData
252b5132 1/* ldlang.h - linker command language support
a2b64bed 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
cf888e70 3 2001, 2002, 2003
aa8804e4 4 Free Software Foundation, Inc.
5cc18311 5
252b5132 6 This file is part of GLD, the Gnu Linker.
5cc18311 7
252b5132
RH
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
e3dc8847 10 the Free Software Foundation; either version 2, or (at your option)
252b5132 11 any later version.
5cc18311 12
252b5132
RH
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
5cc18311 17
252b5132
RH
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 02111-1307, USA. */
22
23#ifndef LDLANG_H
24#define LDLANG_H
25
89cdebba 26typedef enum {
252b5132
RH
27 lang_input_file_is_l_enum,
28 lang_input_file_is_symbols_only_enum,
29 lang_input_file_is_marker_enum,
30 lang_input_file_is_fake_enum,
31 lang_input_file_is_search_file_enum,
32 lang_input_file_is_file_enum
33} lang_input_file_enum_type;
34
2c382fb6
AM
35struct _fill_type {
36 size_t size;
37 unsigned char data[1];
38};
89cdebba
KH
39
40typedef struct statement_list {
252b5132
RH
41 union lang_statement_union *head;
42 union lang_statement_union **tail;
43} lang_statement_list_type;
44
89cdebba 45typedef struct memory_region_struct {
252b5132
RH
46 char *name;
47 struct memory_region_struct *next;
48 bfd_vma origin;
49 bfd_size_type length;
50 bfd_vma current;
51 bfd_size_type old_length;
52 flagword flags;
53 flagword not_flags;
b34976b6 54 bfd_boolean had_full_message;
89cdebba
KH
55} lang_memory_region_type;
56
57typedef struct lang_statement_header_struct {
58 union lang_statement_union *next;
59 enum statement_enum {
60 lang_output_section_statement_enum,
61 lang_assignment_statement_enum,
62 lang_input_statement_enum,
63 lang_address_statement_enum,
64 lang_wild_statement_enum,
65 lang_input_section_enum,
66 lang_object_symbols_statement_enum,
67 lang_fill_statement_enum,
68 lang_data_statement_enum,
69 lang_reloc_statement_enum,
70 lang_target_statement_enum,
71 lang_output_statement_enum,
72 lang_padding_statement_enum,
73 lang_group_statement_enum,
74
75 lang_afile_asection_pair_statement_enum,
76 lang_constructors_statement_enum
77 } type;
252b5132
RH
78} lang_statement_header_type;
79
89cdebba 80typedef struct {
252b5132
RH
81 lang_statement_header_type header;
82 union etree_union *exp;
83} lang_assignment_statement_type;
84
89cdebba 85typedef struct lang_target_statement_struct {
252b5132
RH
86 lang_statement_header_type header;
87 const char *target;
88} lang_target_statement_type;
89
89cdebba 90typedef struct lang_output_statement_struct {
252b5132
RH
91 lang_statement_header_type header;
92 const char *name;
93} lang_output_statement_type;
94
95/* Section types specified in a linker script. */
96
89cdebba 97enum section_type {
252b5132
RH
98 normal_section,
99 dsect_section,
100 copy_section,
101 noload_section,
102 info_section,
103 overlay_section
104};
105
106/* This structure holds a list of program headers describing segments
107 in which this section should be placed. */
108
89cdebba 109struct lang_output_section_phdr_list {
252b5132
RH
110 struct lang_output_section_phdr_list *next;
111 const char *name;
b34976b6 112 bfd_boolean used;
252b5132
RH
113};
114
89cdebba 115typedef struct lang_output_section_statement_struct {
252b5132
RH
116 lang_statement_header_type header;
117 union etree_union *addr_tree;
118 lang_statement_list_type children;
119 const char *memspec;
120 union lang_statement_union *next;
121 const char *name;
122
b34976b6 123 bfd_boolean processed;
5cc18311 124
252b5132
RH
125 asection *bfd_section;
126 flagword flags; /* Or together of all input sections */
127 enum section_type sectype;
128 struct memory_region_struct *region;
562d3460 129 struct memory_region_struct *lma_region;
252b5132 130 size_t block_value;
2c382fb6 131 fill_type *fill;
252b5132 132
89cdebba
KH
133 int subsection_alignment; /* alignment of components */
134 int section_alignment; /* alignment of start of section */
252b5132
RH
135
136 union etree_union *load_base;
137
9f88b410
RS
138 /* If non-null, an expression to evaluate after setting the section's
139 size. The expression is evaluated inside REGION (above) with '.'
140 set to the end of the section. Used in the last overlay section
141 to move '.' past all the overlaid sections. */
142 union etree_union *update_dot_tree;
143
252b5132
RH
144 struct lang_output_section_phdr_list *phdrs;
145} lang_output_section_statement_type;
146
89cdebba 147typedef struct {
252b5132
RH
148 lang_statement_header_type header;
149} lang_common_statement_type;
150
89cdebba 151typedef struct {
252b5132
RH
152 lang_statement_header_type header;
153} lang_object_symbols_statement_type;
154
89cdebba 155typedef struct {
252b5132 156 lang_statement_header_type header;
2c382fb6 157 fill_type *fill;
252b5132
RH
158 int size;
159 asection *output_section;
160} lang_fill_statement_type;
161
89cdebba 162typedef struct {
252b5132
RH
163 lang_statement_header_type header;
164 unsigned int type;
89cdebba 165 union etree_union *exp;
252b5132
RH
166 bfd_vma value;
167 asection *output_section;
168 bfd_vma output_vma;
169} lang_data_statement_type;
170
171/* Generate a reloc in the output file. */
172
89cdebba 173typedef struct {
252b5132
RH
174 lang_statement_header_type header;
175
176 /* Reloc to generate. */
177 bfd_reloc_code_real_type reloc;
178
179 /* Reloc howto structure. */
180 reloc_howto_type *howto;
181
182 /* Section to generate reloc against. Exactly one of section and
183 name must be NULL. */
184 asection *section;
185
186 /* Name of symbol to generate reloc against. Exactly one of section
187 and name must be NULL. */
188 const char *name;
189
190 /* Expression for addend. */
191 union etree_union *addend_exp;
192
193 /* Resolved addend. */
194 bfd_vma addend_value;
195
196 /* Output section where reloc should be performed. */
197 asection *output_section;
198
199 /* VMA within output section. */
200 bfd_vma output_vma;
201} lang_reloc_statement_type;
202
89cdebba 203typedef struct lang_input_statement_struct {
252b5132
RH
204 lang_statement_header_type header;
205 /* Name of this file. */
206 const char *filename;
207 /* Name to use for the symbol giving address of text start */
208 /* Usually the same as filename, but for a file spec'd with -l
209 this is the -l switch itself rather than the filename. */
210 const char *local_sym_name;
5cc18311 211
252b5132 212 bfd *the_bfd;
5cc18311 213
b34976b6 214 bfd_boolean closed;
252b5132 215 file_ptr passive_position;
5cc18311 216
252b5132
RH
217 /* Symbol table of the file. */
218 asymbol **asymbols;
219 unsigned int symbol_count;
5cc18311 220
252b5132
RH
221 /* Point to the next file - whatever it is, wanders up and down
222 archives */
5cc18311 223
89cdebba 224 union lang_statement_union *next;
252b5132 225 /* Point to the next file, but skips archive contents */
89cdebba 226 union lang_statement_union *next_real_file;
5cc18311 227
b34976b6 228 bfd_boolean is_archive;
5cc18311 229
252b5132 230 /* 1 means search a set of directories for this file. */
b34976b6 231 bfd_boolean search_dirs_flag;
5cc18311 232
e3f2db7f
AO
233 /* 1 means this was found in a search directory marked as sysrooted,
234 if search_dirs_flag is false, otherwise, that it should be
235 searched in ld_sysroot before any other location, as long as it
236 starts with a slash. */
237 bfd_boolean sysrooted;
238
252b5132
RH
239 /* 1 means this is base file of incremental load.
240 Do not load this file's text or data.
5cc18311
KH
241 Also default text_start to after this file's bss. */
242
b34976b6 243 bfd_boolean just_syms_flag;
252b5132
RH
244
245 /* Whether to search for this entry as a dynamic archive. */
b34976b6 246 bfd_boolean dynamic;
252b5132
RH
247
248 /* Whether to include the entire contents of an archive. */
b34976b6 249 bfd_boolean whole_archive;
252b5132 250
b34976b6 251 bfd_boolean loaded;
5cc18311 252
89cdebba
KH
253#if 0
254 unsigned int globals_in_this_file;
255#endif
252b5132 256 const char *target;
b34976b6 257 bfd_boolean real;
252b5132
RH
258} lang_input_statement_type;
259
89cdebba 260typedef struct {
252b5132
RH
261 lang_statement_header_type header;
262 asection *section;
263 lang_input_statement_type *ifile;
252b5132 264
5cc18311 265} lang_input_section_type;
252b5132 266
89cdebba 267typedef struct {
252b5132
RH
268 lang_statement_header_type header;
269 asection *section;
270 union lang_statement_union *file;
271} lang_afile_asection_pair_statement_type;
272
89cdebba 273typedef struct lang_wild_statement_struct {
252b5132 274 lang_statement_header_type header;
252b5132 275 const char *filename;
b34976b6 276 bfd_boolean filenames_sorted;
b6bf44ba 277 struct wildcard_list *section_list;
b34976b6 278 bfd_boolean keep_sections;
252b5132
RH
279 lang_statement_list_type children;
280} lang_wild_statement_type;
281
89cdebba 282typedef struct lang_address_statement_struct {
252b5132 283 lang_statement_header_type header;
89cdebba
KH
284 const char *section_name;
285 union etree_union *address;
252b5132
RH
286} lang_address_statement_type;
287
89cdebba 288typedef struct {
252b5132
RH
289 lang_statement_header_type header;
290 bfd_vma output_offset;
291 size_t size;
292 asection *output_section;
2c382fb6 293 fill_type *fill;
252b5132
RH
294} lang_padding_statement_type;
295
296/* A group statement collects a set of libraries together. The
297 libraries are searched multiple times, until no new undefined
298 symbols are found. The effect is to search a group of libraries as
299 though they were a single library. */
300
89cdebba 301typedef struct {
252b5132
RH
302 lang_statement_header_type header;
303 lang_statement_list_type children;
304} lang_group_statement_type;
305
89cdebba 306typedef union lang_statement_union {
252b5132 307 lang_statement_header_type header;
252b5132
RH
308 lang_wild_statement_type wild_statement;
309 lang_data_statement_type data_statement;
310 lang_reloc_statement_type reloc_statement;
311 lang_address_statement_type address_statement;
312 lang_output_section_statement_type output_section_statement;
313 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
314 lang_assignment_statement_type assignment_statement;
315 lang_input_statement_type input_statement;
316 lang_target_statement_type target_statement;
317 lang_output_statement_type output_statement;
318 lang_input_section_type input_section;
319 lang_common_statement_type common_statement;
320 lang_object_symbols_statement_type object_symbols_statement;
321 lang_fill_statement_type fill_statement;
322 lang_padding_statement_type padding_statement;
323 lang_group_statement_type group_statement;
324} lang_statement_union_type;
325
326/* This structure holds information about a program header, from the
327 PHDRS command in the linker script. */
328
89cdebba 329struct lang_phdr {
252b5132
RH
330 struct lang_phdr *next;
331 const char *name;
332 unsigned long type;
b34976b6
AM
333 bfd_boolean filehdr;
334 bfd_boolean phdrs;
252b5132
RH
335 etree_type *at;
336 etree_type *flags;
337};
338
339/* This structure is used to hold a list of sections which may not
340 cross reference each other. */
341
89cdebba 342struct lang_nocrossref {
252b5132
RH
343 struct lang_nocrossref *next;
344 const char *name;
345};
346
347/* The list of nocrossref lists. */
348
89cdebba 349struct lang_nocrossrefs {
252b5132
RH
350 struct lang_nocrossrefs *next;
351 struct lang_nocrossref *list;
352};
353
354extern struct lang_nocrossrefs *nocrossref_list;
355
577a0623
AM
356/* This structure is used to hold a list of input section names which
357 will not match an output section in the linker script. */
358
359struct unique_sections {
360 struct unique_sections *next;
361 const char *name;
362};
363
364extern struct unique_sections *unique_section_list;
365
252b5132 366extern lang_output_section_statement_type *abs_output_section;
aea4bd9d 367extern lang_statement_list_type lang_output_section_statement;
b34976b6 368extern bfd_boolean lang_has_input_file;
252b5132
RH
369extern etree_type *base;
370extern lang_statement_list_type *stat_ptr;
b34976b6 371extern bfd_boolean delete_output_file_on_failure;
252b5132 372
e3e942e9 373extern struct bfd_sym_chain entry_symbol;
1e281515 374extern const char *entry_section;
b34976b6 375extern bfd_boolean entry_from_cmdline;
b71e2778 376extern lang_statement_list_type file_chain;
252b5132 377
f53154de 378extern void lang_init
1579bae1 379 (void);
252b5132 380extern struct memory_region_struct *lang_memory_region_lookup
1579bae1 381 (const char *const);
252b5132 382extern struct memory_region_struct *lang_memory_region_default
1579bae1 383 (asection *);
f53154de 384extern void lang_map
1579bae1 385 (void);
f53154de 386extern void lang_set_flags
1579bae1 387 (lang_memory_region_type *, const char *, int);
f53154de 388extern void lang_add_output
1579bae1 389 (const char *, int from_script);
aea4bd9d 390extern lang_output_section_statement_type *lang_enter_output_section_statement
1579bae1
AM
391 (const char *output_section_statement_name,
392 etree_type *address_exp,
393 enum section_type sectype,
394 bfd_vma block_value,
395 etree_type *align,
396 etree_type *subalign,
397 etree_type *);
f53154de 398extern void lang_final
1579bae1 399 (void);
f53154de 400extern void lang_process
1579bae1 401 (void);
f53154de 402extern void lang_section_start
1579bae1 403 (const char *, union etree_union *);
f53154de 404extern void lang_add_entry
1579bae1 405 (const char *, bfd_boolean);
f53154de 406extern void lang_add_target
1579bae1 407 (const char *);
252b5132 408extern void lang_add_wild
1579bae1 409 (struct wildcard_spec *, struct wildcard_list *, bfd_boolean);
f53154de 410extern void lang_add_map
1579bae1 411 (const char *);
f53154de 412extern void lang_add_fill
1579bae1
AM
413 (fill_type *);
414extern lang_assignment_statement_type *lang_add_assignment
415 (union etree_union *);
f53154de 416extern void lang_add_attribute
1579bae1 417 (enum statement_enum);
f53154de 418extern void lang_startup
1579bae1 419 (const char *);
f53154de 420extern void lang_float
1579bae1 421 (bfd_boolean);
252b5132 422extern void lang_leave_output_section_statement
1579bae1
AM
423 (fill_type *, const char *, struct lang_output_section_phdr_list *,
424 const char *);
f53154de 425extern void lang_abs_symbol_at_end_of
1579bae1 426 (const char *, const char *);
f53154de 427extern void lang_abs_symbol_at_beginning_of
1579bae1 428 (const char *, const char *);
f53154de 429extern void lang_statement_append
1579bae1
AM
430 (struct statement_list *, union lang_statement_union *,
431 union lang_statement_union **);
252b5132 432extern void lang_for_each_input_file
1579bae1 433 (void (*dothis) (lang_input_statement_type *));
252b5132 434extern void lang_for_each_file
1579bae1 435 (void (*dothis) (lang_input_statement_type *));
f53154de 436extern void lang_reset_memory_regions
1579bae1 437 (void);
252b5132 438extern bfd_vma lang_do_assignments
1579bae1
AM
439 (lang_statement_union_type *, lang_output_section_statement_type *,
440 fill_type *, bfd_vma);
252b5132 441
f53154de
AM
442#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
443 lang_input_statement_type *statement; \
444 for (statement = (lang_input_statement_type *) file_chain.head; \
445 statement != (lang_input_statement_type *) NULL; \
446 statement = (lang_input_statement_type *) statement->next) \
5cc18311 447
f53154de 448extern void lang_process
1579bae1 449 (void);
f53154de 450extern void ldlang_add_file
1579bae1 451 (lang_input_statement_type *);
252b5132 452extern lang_output_section_statement_type *lang_output_section_find
1579bae1 453 (const char * const);
252b5132 454extern lang_input_statement_type *lang_add_input_file
1579bae1 455 (const char *, lang_input_file_enum_type, const char *);
f53154de 456extern void lang_add_keepsyms_file
1579bae1 457 (const char *);
252b5132 458extern lang_output_section_statement_type *
f53154de 459 lang_output_section_statement_lookup
1579bae1 460 (const char *const);
f53154de 461extern void ldlang_add_undef
1579bae1 462 (const char *const);
f53154de 463extern void lang_add_output_format
1579bae1 464 (const char *, const char *, const char *, int);
f53154de 465extern void lang_list_init
1579bae1 466 (lang_statement_list_type *);
f53154de 467extern void lang_add_data
1579bae1 468 (int type, union etree_union *);
252b5132 469extern void lang_add_reloc
1579bae1
AM
470 (bfd_reloc_code_real_type, reloc_howto_type *, asection *, const char *,
471 union etree_union *);
252b5132 472extern void lang_for_each_statement
1579bae1
AM
473 (void (*) (lang_statement_union_type *));
474extern void *stat_alloc
475 (size_t);
f53154de 476extern void dprint_statement
1579bae1 477 (lang_statement_union_type *, int);
252b5132 478extern bfd_vma lang_size_sections
1579bae1
AM
479 (lang_statement_union_type *, lang_output_section_statement_type *,
480 lang_statement_union_type **, fill_type *, bfd_vma, bfd_boolean *,
481 bfd_boolean);
f53154de 482extern void lang_enter_group
1579bae1 483 (void);
f53154de 484extern void lang_leave_group
1579bae1 485 (void);
39dcfe18 486extern void lang_add_section
1579bae1
AM
487 (lang_statement_list_type *, asection *,
488 lang_output_section_statement_type *, lang_input_statement_type *);
252b5132 489extern void lang_new_phdr
1579bae1
AM
490 (const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
491 etree_type *);
f53154de 492extern void lang_add_nocrossref
1579bae1 493 (struct lang_nocrossref *);
f53154de 494extern void lang_enter_overlay
1579bae1 495 (etree_type *);
f53154de 496extern void lang_enter_overlay_section
1579bae1 497 (const char *);
252b5132 498extern void lang_leave_overlay_section
1579bae1 499 (fill_type *, struct lang_output_section_phdr_list *);
252b5132 500extern void lang_leave_overlay
1579bae1
AM
501 (etree_type *, int, fill_type *, const char *,
502 struct lang_output_section_phdr_list *, const char *);
252b5132
RH
503
504extern struct bfd_elf_version_tree *lang_elf_version_info;
505
313e35ee 506extern struct bfd_elf_version_expr *lang_new_vers_pattern
1579bae1 507 (struct bfd_elf_version_expr *, const char *, const char *);
252b5132 508extern struct bfd_elf_version_tree *lang_new_vers_node
1579bae1 509 (struct bfd_elf_version_expr *, struct bfd_elf_version_expr *);
252b5132 510extern struct bfd_elf_version_deps *lang_add_vers_depend
1579bae1 511 (struct bfd_elf_version_deps *, const char *);
252b5132 512extern void lang_register_vers_node
1579bae1 513 (const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
f53154de 514bfd_boolean unique_section_p
1579bae1 515 (const char *);
f53154de 516extern void lang_add_unique
1579bae1 517 (const char *);
f53154de 518extern const char *lang_get_output_target
1579bae1 519 (void);
252b5132
RH
520
521#endif
This page took 0.198004 seconds and 4 git commands to generate.