2003-05-19 Roland McGrath <roland@redhat.com>
[deliverable/binutils-gdb.git] / bfd / elf-bfd.h
CommitLineData
252b5132 1/* BFD back-end data structures for ELF files.
e5094212 2 Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
f0abc2a1 3 2002, 2003 Free Software Foundation, Inc.
252b5132
RH
4 Written by Cygnus Support.
5
5e8d7549 6 This file is part of BFD, the Binary File Descriptor library.
252b5132 7
5e8d7549
NC
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
252b5132 12
5e8d7549
NC
13 This program 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.
252b5132 17
5e8d7549
NC
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
252b5132
RH
21
22#ifndef _LIBELF_H_
23#define _LIBELF_H_ 1
24
25#include "elf/common.h"
26#include "elf/internal.h"
27#include "elf/external.h"
28#include "bfdlink.h"
29
d9bc7a44 30/* The number of entries in a section is its size divided by the size
51b64d56 31 of a single entry. This is normally only applicable to reloc and
d9bc7a44
NC
32 symbol table sections. */
33#define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
34
252b5132 35/* If size isn't specified as 64 or 32, NAME macro should fail. */
e43d48cc
AM
36/* Do not "beautify" the CONCAT* macro args. Traditional C will not
37 remove whitespace added here, and thus will fail to concatenate
38 the tokens. */
252b5132
RH
39#ifndef NAME
40#if ARCH_SIZE==64
e43d48cc 41#define NAME(x,y) CONCAT4 (x,64,_,y)
252b5132
RH
42#endif
43#if ARCH_SIZE==32
e43d48cc 44#define NAME(x,y) CONCAT4 (x,32,_,y)
252b5132
RH
45#endif
46#endif
47
48#ifndef NAME
e43d48cc 49#define NAME(x,y) CONCAT4 (x,NOSIZE,_,y)
252b5132
RH
50#endif
51
52#define ElfNAME(X) NAME(Elf,X)
53#define elfNAME(X) NAME(elf,X)
54
55/* Information held for an ELF symbol. The first field is the
56 corresponding asymbol. Every symbol is an ELF file is actually a
57 pointer to this structure, although it is often handled as a
58 pointer to an asymbol. */
59
60typedef struct
61{
62 /* The BFD symbol. */
63 asymbol symbol;
64 /* ELF symbol information. */
65 Elf_Internal_Sym internal_elf_sym;
66 /* Backend specific information. */
67 union
68 {
69 unsigned int hppa_arg_reloc;
70 PTR mips_extr;
71 PTR any;
72 }
73 tc_data;
74
75 /* Version information. This is from an Elf_Internal_Versym
76 structure in a SHT_GNU_versym section. It is zero if there is no
77 version information. */
78 unsigned short version;
79
80} elf_symbol_type;
81\f
2b0f7ef9 82struct elf_strtab_hash;
5cab59f6
AM
83struct got_entry;
84struct plt_entry;
2b0f7ef9 85
252b5132
RH
86/* ELF linker hash table entries. */
87
88struct elf_link_hash_entry
89{
90 struct bfd_link_hash_entry root;
91
92 /* Symbol index in output file. This is initialized to -1. It is
93 set to -2 if the symbol is used by a reloc. */
94 long indx;
95
252b5132
RH
96 /* Symbol index as a dynamic symbol. Initialized to -1, and remains
97 -1 if this is not a dynamic symbol. */
30b30c21
RH
98 /* ??? Note that this is consistently used as a synonym for tests
99 against whether we can perform various simplifying transformations
100 to the code. (E.g. changing a pc-relative jump to a PLT entry
101 into a pc-relative jump to the target function.) That test, which
102 is often relatively complex, and someplaces wrong or incomplete,
103 should really be replaced by a predicate in elflink.c.
104
105 End result: this field -1 does not indicate that the symbol is
106 not in the dynamic symbol table, but rather that the symbol is
107 not visible outside this DSO. */
252b5132
RH
108 long dynindx;
109
110 /* String table index in .dynstr if this is a dynamic symbol. */
111 unsigned long dynstr_index;
112
a90b9fca
AM
113 /* Hash value of the name computed using the ELF hash function. */
114 unsigned long elf_hash_value;
115
252b5132
RH
116 /* If this is a weak defined symbol from a dynamic object, this
117 field points to a defined symbol with the same value, if there is
118 one. Otherwise it is NULL. */
119 struct elf_link_hash_entry *weakdef;
120
252b5132
RH
121 /* If this symbol is used in the linker created sections, the processor
122 specific backend uses this field to map the field into the offset
123 from the beginning of the section. */
124 struct elf_linker_section_pointers *linker_section_pointer;
125
126 /* Version information. */
127 union
128 {
129 /* This field is used for a symbol which is not defined in a
130 regular object. It points to the version information read in
131 from the dynamic object. */
132 Elf_Internal_Verdef *verdef;
133 /* This field is used for a symbol which is defined in a regular
134 object. It is set up in size_dynamic_sections. It points to
135 the version information we should write out for this symbol. */
136 struct bfd_elf_version_tree *vertree;
137 } verinfo;
138
139 /* Virtual table entry use information. This array is nominally of size
140 size/sizeof(target_void_pointer), though we have to be able to assume
141 and track a size while the symbol is still undefined. It is indexed
142 via offset/sizeof(target_void_pointer). */
143 size_t vtable_entries_size;
b34976b6 144 bfd_boolean *vtable_entries_used;
252b5132
RH
145
146 /* Virtual table derivation info. */
147 struct elf_link_hash_entry *vtable_parent;
148
a90b9fca
AM
149 /* If this symbol requires an entry in the global offset table, the
150 processor specific backend uses this field to track usage and
5cab59f6
AM
151 final offset. Two schemes are supported: The first assumes that
152 a symbol may only have one GOT entry, and uses REFCOUNT until
153 size_dynamic_sections, at which point the contents of the .got is
154 fixed. Afterward, if OFFSET is -1, then the symbol does not
155 require a global offset table entry. The second scheme allows
156 multiple GOT entries per symbol, managed via a linked list
157 pointed to by GLIST. */
158 union gotplt_union
a90b9fca
AM
159 {
160 bfd_signed_vma refcount;
161 bfd_vma offset;
5cab59f6
AM
162 struct got_entry *glist;
163 struct plt_entry *plist;
a90b9fca
AM
164 } got;
165
166 /* Same, but tracks a procedure linkage table entry. */
5cab59f6 167 union gotplt_union plt;
a90b9fca
AM
168
169 /* Symbol size. */
170 bfd_size_type size;
171
252b5132
RH
172 /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
173 char type;
174
9b234ee9 175 /* Symbol st_other value, symbol visibility. */
252b5132
RH
176 unsigned char other;
177
252b5132
RH
178 /* Some flags; legal values follow. */
179 unsigned short elf_link_hash_flags;
180 /* Symbol is referenced by a non-shared object. */
181#define ELF_LINK_HASH_REF_REGULAR 01
182 /* Symbol is defined by a non-shared object. */
183#define ELF_LINK_HASH_DEF_REGULAR 02
184 /* Symbol is referenced by a shared object. */
185#define ELF_LINK_HASH_REF_DYNAMIC 04
186 /* Symbol is defined by a shared object. */
187#define ELF_LINK_HASH_DEF_DYNAMIC 010
188 /* Symbol has a non-weak reference from a non-shared object. */
189#define ELF_LINK_HASH_REF_REGULAR_NONWEAK 020
190 /* Dynamic symbol has been adjustd. */
191#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 040
192 /* Symbol needs a copy reloc. */
193#define ELF_LINK_HASH_NEEDS_COPY 0100
194 /* Symbol needs a procedure linkage table entry. */
195#define ELF_LINK_HASH_NEEDS_PLT 0200
196 /* Symbol appears in a non-ELF input file. */
197#define ELF_LINK_NON_ELF 0400
198 /* Symbol should be marked as hidden in the version information. */
199#define ELF_LINK_HIDDEN 01000
200 /* Symbol was forced to local scope due to a version script file. */
201#define ELF_LINK_FORCED_LOCAL 02000
202 /* Symbol was marked during garbage collection. */
203#define ELF_LINK_HASH_MARK 04000
7843f00e
ILT
204 /* Symbol is referenced by a non-GOT/non-PLT relocation. This is
205 not currently set by all the backends. */
206#define ELF_LINK_NON_GOT_REF 010000
1b1fe8fe
L
207 /* Symbol has a definition in a shared object. */
208#define ELF_LINK_DYNAMIC_DEF 020000
209 /* Symbol is weak in all shared objects. */
210#define ELF_LINK_DYNAMIC_WEAK 040000
252b5132
RH
211};
212
586119b3
AM
213/* Will references to this symbol always reference the symbol
214 in this object? STV_PROTECTED is excluded from the visibility test
215 here so that function pointer comparisons work properly. Since
216 function symbols not defined in an app are set to their .plt entry,
217 it's necessary for shared libs to also reference the .plt even
218 though the symbol is really local to the shared lib. */
219#define SYMBOL_REFERENCES_LOCAL(INFO, H) \
220 ((! (INFO)->shared \
221 || (INFO)->symbolic \
222 || (H)->dynindx == -1 \
223 || ELF_ST_VISIBILITY ((H)->other) == STV_INTERNAL \
224 || ELF_ST_VISIBILITY ((H)->other) == STV_HIDDEN \
225 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0) \
226 && ((H)->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
227
228/* Will _calls_ to this symbol always call the version in this object? */
229#define SYMBOL_CALLS_LOCAL(INFO, H) \
230 ((! (INFO)->shared \
231 || (INFO)->symbolic \
232 || (H)->dynindx == -1 \
233 || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT \
234 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0) \
235 && ((H)->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
236
30b30c21
RH
237/* Records local symbols to be emitted in the dynamic symbol table. */
238
239struct elf_link_local_dynamic_entry
240{
241 struct elf_link_local_dynamic_entry *next;
242
243 /* The input bfd this symbol came from. */
244 bfd *input_bfd;
245
246 /* The index of the local symbol being copied. */
247 long input_indx;
248
249 /* The index in the outgoing dynamic symbol table. */
250 long dynindx;
3e932841 251
30b30c21
RH
252 /* A copy of the input symbol. */
253 Elf_Internal_Sym isym;
254};
255
f5d44ba0
AM
256struct elf_link_loaded_list
257{
258 struct elf_link_loaded_list *next;
259 bfd *abfd;
260};
261
126495ed
AM
262/* Structures used by the eh_frame optimization code. */
263struct cie_header
264{
265 unsigned int length;
266 unsigned int id;
267};
268
269struct cie
270{
271 struct cie_header hdr;
272 unsigned char version;
273 unsigned char augmentation[20];
274 unsigned int code_align;
275 int data_align;
276 unsigned int ra_column;
277 unsigned int augmentation_size;
278 struct elf_link_hash_entry *personality;
279 unsigned char per_encoding;
280 unsigned char lsda_encoding;
281 unsigned char fde_encoding;
282 unsigned char initial_insn_length;
283 unsigned char make_relative;
284 unsigned char make_lsda_relative;
285 unsigned char initial_instructions[50];
286};
287
288struct eh_cie_fde
289{
290 unsigned int offset;
291 unsigned int size;
292 asection *sec;
293 unsigned int new_offset;
294 unsigned char fde_encoding;
295 unsigned char lsda_encoding;
296 unsigned char lsda_offset;
297 unsigned char cie : 1;
298 unsigned char removed : 1;
299 unsigned char make_relative : 1;
300 unsigned char make_lsda_relative : 1;
301 unsigned char per_encoding_relative : 1;
302};
303
304struct eh_frame_sec_info
305{
306 unsigned int count;
307 unsigned int alloced;
308 struct eh_cie_fde entry[1];
309};
310
311struct eh_frame_array_ent
312{
313 bfd_vma initial_loc;
314 bfd_vma fde;
315};
316
317struct eh_frame_hdr_info
318{
319 struct cie last_cie;
320 asection *last_cie_sec;
321 asection *hdr_sec;
322 unsigned int last_cie_offset;
323 unsigned int fde_count, array_count;
324 struct eh_frame_array_ent *array;
325 /* TRUE if .eh_frame_hdr should contain the sorted search table.
326 We build it if we successfully read all .eh_frame input sections
327 and recognize them. */
b34976b6 328 bfd_boolean table;
126495ed
AM
329};
330
13ae64f3
JJ
331/* Cached start, size and alignment of PT_TLS segment. */
332struct elf_link_tls_segment
333{
334 bfd_vma start;
335 bfd_size_type size;
336 unsigned int align;
337};
338
252b5132
RH
339/* ELF linker hash table. */
340
341struct elf_link_hash_table
342{
343 struct bfd_link_hash_table root;
51b64d56 344
252b5132
RH
345 /* Whether we have created the special dynamic sections required
346 when linking against or generating a shared object. */
b34976b6 347 bfd_boolean dynamic_sections_created;
51b64d56 348
252b5132
RH
349 /* The BFD used to hold special sections created by the linker.
350 This will be the first BFD found which requires these sections to
351 be created. */
352 bfd *dynobj;
51b64d56
AM
353
354 /* The value to use when initialising got.refcount/offset and
355 plt.refcount/offset in an elf_link_hash_entry. Set to zero when
5cab59f6
AM
356 the values are refcounts. Set to init_offset in
357 size_dynamic_sections when the values may be offsets. */
358 union gotplt_union init_refcount;
359
360 /* The value to use for got.refcount/offset and plt.refcount/offset
361 when the values may be offsets. Normally (bfd_vma) -1. */
362 union gotplt_union init_offset;
51b64d56 363
252b5132
RH
364 /* The number of symbols found in the link which must be put into
365 the .dynsym section. */
366 bfd_size_type dynsymcount;
51b64d56 367
252b5132
RH
368 /* The string table of dynamic symbols, which becomes the .dynstr
369 section. */
2b0f7ef9 370 struct elf_strtab_hash *dynstr;
51b64d56 371
252b5132
RH
372 /* The number of buckets in the hash table in the .hash section.
373 This is based on the number of dynamic symbols. */
374 bfd_size_type bucketcount;
51b64d56 375
252b5132
RH
376 /* A linked list of DT_NEEDED names found in dynamic objects
377 included in the link. */
378 struct bfd_link_needed_list *needed;
51b64d56 379
252b5132
RH
380 /* The _GLOBAL_OFFSET_TABLE_ symbol. */
381 struct elf_link_hash_entry *hgot;
51b64d56 382
252b5132
RH
383 /* A pointer to information used to link stabs in sections. */
384 PTR stab_info;
51b64d56 385
f5fa8ca2
JJ
386 /* A pointer to information used to merge SEC_MERGE sections. */
387 PTR merge_info;
51b64d56 388
126495ed
AM
389 /* Used by eh_frame code when editing .eh_frame. */
390 struct eh_frame_hdr_info eh_info;
391
30b30c21
RH
392 /* A linked list of local symbols to be added to .dynsym. */
393 struct elf_link_local_dynamic_entry *dynlocal;
51b64d56 394
a963dc6a
L
395 /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
396 objects included in the link. */
397 struct bfd_link_needed_list *runpath;
13ae64f3
JJ
398
399 /* Cached start, size and alignment of PT_TLS segment. */
400 struct elf_link_tls_segment *tls_segment;
f5d44ba0
AM
401
402 /* A linked list of BFD's loaded in the link. */
403 struct elf_link_loaded_list *loaded;
252b5132
RH
404};
405
406/* Look up an entry in an ELF linker hash table. */
407
408#define elf_link_hash_lookup(table, string, create, copy, follow) \
409 ((struct elf_link_hash_entry *) \
410 bfd_link_hash_lookup (&(table)->root, (string), (create), \
411 (copy), (follow)))
412
413/* Traverse an ELF linker hash table. */
414
415#define elf_link_hash_traverse(table, func, info) \
416 (bfd_link_hash_traverse \
417 (&(table)->root, \
b34976b6 418 (bfd_boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
252b5132
RH
419 (info)))
420
421/* Get the ELF linker hash table from a link_info structure. */
422
423#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
8ea2e4bd 424
b34976b6 425/* Returns TRUE if the hash table is a struct elf_link_hash_table. */
8ea2e4bd
NC
426#define is_elf_hash_table(p) \
427 ((p)->hash->type == bfd_link_elf_hash_table)
ec338859
AM
428
429/* Used by bfd_section_from_r_symndx to cache a small number of local
430 symbol to section mappings. */
431#define LOCAL_SYM_CACHE_SIZE 32
432struct sym_sec_cache
433{
434 bfd *abfd;
435 unsigned long indx[LOCAL_SYM_CACHE_SIZE];
436 asection *sec[LOCAL_SYM_CACHE_SIZE];
437};
252b5132
RH
438\f
439/* Constant information held for an ELF backend. */
440
441struct elf_size_info {
442 unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
443 unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
444
c7ac6ff8
MM
445 /* The size of entries in the .hash section. */
446 unsigned char sizeof_hash_entry;
447
448 /* The number of internal relocations to allocate per external
449 relocation entry. */
450 unsigned char int_rels_per_ext_rel;
947216bf
AM
451 /* We use some fixed size arrays. This should be large enough to
452 handle all back-ends. */
453#define MAX_INT_RELS_PER_EXT_REL 3
c7ac6ff8 454
45d6a902 455 unsigned char arch_size, log_file_align;
252b5132 456 unsigned char elfclass, ev_current;
dc810e39
AM
457 int (*write_out_phdrs)
458 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
b34976b6 459 bfd_boolean (*write_shdrs_and_ehdr)
dc810e39
AM
460 PARAMS ((bfd *));
461 void (*write_relocs)
462 PARAMS ((bfd *, asection *, PTR));
73ff0d56 463 void (*swap_symbol_in)
f8ecb12b 464 PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *));
dc810e39 465 void (*swap_symbol_out)
9ad5cbcf 466 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
b34976b6
AM
467 bfd_boolean (*slurp_reloc_table)
468 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
dc810e39 469 long (*slurp_symbol_table)
b34976b6 470 PARAMS ((bfd *, asymbol **, bfd_boolean));
dc810e39
AM
471 void (*swap_dyn_in)
472 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
473 void (*swap_dyn_out)
474 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
c7ac6ff8 475
947216bf
AM
476 /* This function is called to swap in a REL relocation. If an
477 external relocation corresponds to more than one internal
478 relocation, then all relocations are swapped in at once. */
c7ac6ff8 479 void (*swap_reloc_in)
947216bf 480 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
c7ac6ff8 481
947216bf 482 /* This function is called to swap out a REL relocation. */
c7ac6ff8 483 void (*swap_reloc_out)
947216bf 484 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
c7ac6ff8 485
947216bf
AM
486 /* This function is called to swap in a RELA relocation. If an
487 external relocation corresponds to more than one internal
488 relocation, then all relocations are swapped in at once. */
c7ac6ff8
MM
489 void (*swap_reloca_in)
490 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
491
947216bf 492 /* This function is called to swap out a RELA relocation. */
c7ac6ff8
MM
493 void (*swap_reloca_out)
494 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
252b5132
RH
495};
496
497#define elf_symbol_from(ABFD,S) \
498 (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
499 && (S)->the_bfd->tdata.elf_obj_data != 0) \
500 ? (elf_symbol_type *) (S) \
501 : 0)
502
db6751f2
JJ
503enum elf_reloc_type_class {
504 reloc_class_normal,
505 reloc_class_relative,
506 reloc_class_plt,
507 reloc_class_copy
508};
509
73d074b4
DJ
510struct elf_reloc_cookie
511{
512 Elf_Internal_Rela *rels, *rel, *relend;
6cdc0ccc 513 Elf_Internal_Sym *locsyms;
73d074b4
DJ
514 bfd *abfd;
515 size_t locsymcount;
516 size_t extsymoff;
517 struct elf_link_hash_entry **sym_hashes;
b34976b6 518 bfd_boolean bad_symtab;
73d074b4
DJ
519};
520
c6e90b02
TS
521/* The level of IRIX compatibility we're striving for. */
522
523typedef enum {
524 ict_none,
525 ict_irix5,
526 ict_irix6
527} irix_compat_t;
528
252b5132
RH
529struct elf_backend_data
530{
252b5132
RH
531 /* The architecture for this backend. */
532 enum bfd_architecture arch;
533
534 /* The ELF machine code (EM_xxxx) for this backend. */
535 int elf_machine_code;
536
537 /* The maximum page size for this backend. */
538 bfd_vma maxpagesize;
539
252b5132
RH
540 /* A function to translate an ELF RELA relocation to a BFD arelent
541 structure. */
dc810e39
AM
542 void (*elf_info_to_howto)
543 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
252b5132
RH
544
545 /* A function to translate an ELF REL relocation to a BFD arelent
546 structure. */
dc810e39 547 void (*elf_info_to_howto_rel)
947216bf 548 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
252b5132
RH
549
550 /* A function to determine whether a symbol is global when
551 partitioning the symbol table into local and global symbols.
552 This should be NULL for most targets, in which case the correct
553 thing will be done. MIPS ELF, at least on the Irix 5, has
554 special requirements. */
b34976b6 555 bfd_boolean (*elf_backend_sym_is_global)
dc810e39 556 PARAMS ((bfd *, asymbol *));
252b5132
RH
557
558 /* The remaining functions are hooks which are called only if they
559 are not NULL. */
560
561 /* A function to permit a backend specific check on whether a
562 particular BFD format is relevant for an object file, and to
563 permit the backend to set any global information it wishes. When
564 this is called elf_elfheader is set, but anything else should be
b34976b6 565 used with caution. If this returns FALSE, the check_format
252b5132 566 routine will return a bfd_error_wrong_format error. */
b34976b6 567 bfd_boolean (*elf_backend_object_p)
dc810e39 568 PARAMS ((bfd *));
252b5132
RH
569
570 /* A function to do additional symbol processing when reading the
571 ELF symbol table. This is where any processor-specific special
572 section indices are handled. */
dc810e39
AM
573 void (*elf_backend_symbol_processing)
574 PARAMS ((bfd *, asymbol *));
252b5132
RH
575
576 /* A function to do additional symbol processing after reading the
577 entire ELF symbol table. */
b34976b6 578 bfd_boolean (*elf_backend_symbol_table_processing)
dc810e39 579 PARAMS ((bfd *, elf_symbol_type *, unsigned int));
252b5132
RH
580
581 /* A function to set the type of the info field. Processor-specific
3e932841 582 types should be handled here. */
dc810e39
AM
583 int (*elf_backend_get_symbol_type)
584 PARAMS (( Elf_Internal_Sym *, int));
60bcf0fa 585
252b5132
RH
586 /* A function to do additional processing on the ELF section header
587 just before writing it out. This is used to set the flags and
588 type fields for some sections, or to actually write out data for
589 unusual sections. */
b34976b6 590 bfd_boolean (*elf_backend_section_processing)
947216bf 591 PARAMS ((bfd *, Elf_Internal_Shdr *));
252b5132
RH
592
593 /* A function to handle unusual section types when creating BFD
594 sections from ELF sections. */
b34976b6 595 bfd_boolean (*elf_backend_section_from_shdr)
947216bf 596 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
252b5132 597
fa152c49
JW
598 /* A function to convert machine dependent section header flags to
599 BFD internal section header flags. */
b34976b6 600 bfd_boolean (*elf_backend_section_flags)
947216bf 601 PARAMS ((flagword *, Elf_Internal_Shdr *));
fa152c49 602
20cfcaae 603 /* A function to handle unusual program segment types when creating BFD
3e932841 604 sections from ELF program segments. */
b34976b6 605 bfd_boolean (*elf_backend_section_from_phdr)
947216bf 606 PARAMS ((bfd *, Elf_Internal_Phdr *, int));
20cfcaae 607
252b5132
RH
608 /* A function to set up the ELF section header for a BFD section in
609 preparation for writing it out. This is where the flags and type
610 fields are set for unusual sections. */
b34976b6 611 bfd_boolean (*elf_backend_fake_sections)
947216bf 612 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
252b5132
RH
613
614 /* A function to get the ELF section index for a BFD section. If
b34976b6 615 this returns TRUE, the section was found. If it is a normal ELF
252b5132
RH
616 section, *RETVAL should be left unchanged. If it is not a normal
617 ELF section *RETVAL should be set to the SHN_xxxx index. */
b34976b6 618 bfd_boolean (*elf_backend_section_from_bfd_section)
af746e92 619 PARAMS ((bfd *, asection *, int *retval));
252b5132
RH
620
621 /* If this field is not NULL, it is called by the add_symbols phase
622 of a link just before adding a symbol to the global linker hash
623 table. It may modify any of the fields as it wishes. If *NAME
624 is set to NULL, the symbol will be skipped rather than being
625 added to the hash table. This function is responsible for
626 handling all processor dependent symbol bindings and section
627 indices, and must set at least *FLAGS and *SEC for each processor
628 dependent case; failure to do so will cause a link error. */
b34976b6 629 bfd_boolean (*elf_add_symbol_hook)
252b5132
RH
630 PARAMS ((bfd *abfd, struct bfd_link_info *info,
631 const Elf_Internal_Sym *, const char **name,
632 flagword *flags, asection **sec, bfd_vma *value));
633
634 /* If this field is not NULL, it is called by the elf_link_output_sym
635 phase of a link for each symbol which will appear in the object file. */
b34976b6 636 bfd_boolean (*elf_backend_link_output_symbol_hook)
252b5132
RH
637 PARAMS ((bfd *, struct bfd_link_info *info, const char *,
638 Elf_Internal_Sym *, asection *));
639
640 /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
641 linker the first time it encounters a dynamic object in the link.
642 This function must create any sections required for dynamic
643 linking. The ABFD argument is a dynamic object. The .interp,
644 .dynamic, .dynsym, .dynstr, and .hash functions have already been
645 created, and this function may modify the section flags if
646 desired. This function will normally create the .got and .plt
647 sections, but different backends have different requirements. */
b34976b6 648 bfd_boolean (*elf_backend_create_dynamic_sections)
252b5132
RH
649 PARAMS ((bfd *abfd, struct bfd_link_info *info));
650
651 /* The CHECK_RELOCS function is called by the add_symbols phase of
652 the ELF backend linker. It is called once for each section with
653 relocs of an object file, just after the symbols for the object
654 file have been added to the global linker hash table. The
655 function must look through the relocs and do any special handling
656 required. This generally means allocating space in the global
657 offset table, and perhaps allocating space for a reloc. The
658 relocs are always passed as Rela structures; if the section
659 actually uses Rel structures, the r_addend field will always be
660 zero. */
b34976b6 661 bfd_boolean (*check_relocs)
252b5132
RH
662 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
663 const Elf_Internal_Rela *relocs));
664
665 /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
666 linker for every symbol which is defined by a dynamic object and
667 referenced by a regular object. This is called after all the
668 input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
669 function has been called. The hash table entry should be
670 bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
671 defined in a section from a dynamic object. Dynamic object
672 sections are not included in the final link, and this function is
673 responsible for changing the value to something which the rest of
674 the link can deal with. This will normally involve adding an
675 entry to the .plt or .got or some such section, and setting the
676 symbol to point to that. */
b34976b6 677 bfd_boolean (*elf_backend_adjust_dynamic_symbol)
252b5132
RH
678 PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
679
680 /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
681 after all the linker input files have been seen but before the
682 section sizes have been set. This is called after
683 ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
b34976b6 684 bfd_boolean (*elf_backend_always_size_sections)
252b5132
RH
685 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
686
687 /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
688 linker after all the linker input files have been seen but before
689 the sections sizes have been set. This is called after
690 ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
691 It is only called when linking against a dynamic object. It must
692 set the sizes of the dynamic sections, and may fill in their
693 contents as well. The generic ELF linker can handle the .dynsym,
694 .dynstr and .hash sections. This function must handle the
695 .interp section and any sections created by the
696 CREATE_DYNAMIC_SECTIONS entry point. */
b34976b6 697 bfd_boolean (*elf_backend_size_dynamic_sections)
252b5132
RH
698 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
699
700 /* The RELOCATE_SECTION function is called by the ELF backend linker
701 to handle the relocations for a section.
702
703 The relocs are always passed as Rela structures; if the section
704 actually uses Rel structures, the r_addend field will always be
705 zero.
706
707 This function is responsible for adjust the section contents as
708 necessary, and (if using Rela relocs and generating a
709 relocateable output file) adjusting the reloc addend as
710 necessary.
711
712 This function does not have to worry about setting the reloc
713 address or the reloc symbol index.
714
715 LOCAL_SYMS is a pointer to the swapped in local symbols.
716
717 LOCAL_SECTIONS is an array giving the section in the input file
718 corresponding to the st_shndx field of each local symbol.
719
720 The global hash table entry for the global symbols can be found
721 via elf_sym_hashes (input_bfd).
722
723 When generating relocateable output, this function must handle
724 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
725 going to be the section symbol corresponding to the output
726 section, which means that the addend must be adjusted
727 accordingly. */
b34976b6 728 bfd_boolean (*elf_backend_relocate_section)
252b5132
RH
729 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
730 bfd *input_bfd, asection *input_section, bfd_byte *contents,
731 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
732 asection **local_sections));
733
734 /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
735 linker just before it writes a symbol out to the .dynsym section.
736 The processor backend may make any required adjustment to the
737 symbol. It may also take the opportunity to set contents of the
738 dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
739 all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
740 on those symbols which are defined by a dynamic object. */
b34976b6 741 bfd_boolean (*elf_backend_finish_dynamic_symbol)
252b5132
RH
742 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
743 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
744
745 /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
746 linker just before it writes all the dynamic sections out to the
747 output file. The FINISH_DYNAMIC_SYMBOL will have been called on
748 all dynamic symbols. */
b34976b6 749 bfd_boolean (*elf_backend_finish_dynamic_sections)
252b5132
RH
750 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
751
752 /* A function to do any beginning processing needed for the ELF file
753 before building the ELF headers and computing file positions. */
754 void (*elf_backend_begin_write_processing)
755 PARAMS ((bfd *, struct bfd_link_info *));
756
757 /* A function to do any final processing needed for the ELF file
b34976b6 758 before writing it out. The LINKER argument is TRUE if this BFD
252b5132
RH
759 was created by the ELF backend linker. */
760 void (*elf_backend_final_write_processing)
b34976b6 761 PARAMS ((bfd *, bfd_boolean linker));
252b5132
RH
762
763 /* This function is called by get_program_header_size. It should
764 return the number of additional program segments which this BFD
765 will need. It should return -1 on error. */
dc810e39
AM
766 int (*elf_backend_additional_program_headers)
767 PARAMS ((bfd *));
252b5132
RH
768
769 /* This function is called to modify an existing segment map in a
770 backend specific fashion. */
b34976b6 771 bfd_boolean (*elf_backend_modify_segment_map)
dc810e39 772 PARAMS ((bfd *));
252b5132
RH
773
774 /* This function is called during section gc to discover the section a
1e2f5b6e 775 particular relocation refers to. */
252b5132 776 asection * (*gc_mark_hook)
1e2f5b6e 777 PARAMS ((asection *sec, struct bfd_link_info *, Elf_Internal_Rela *,
252b5132
RH
778 struct elf_link_hash_entry *h, Elf_Internal_Sym *));
779
780 /* This function, if defined, is called during the sweep phase of gc
781 in order that a backend might update any data structures it might
782 be maintaining. */
b34976b6 783 bfd_boolean (*gc_sweep_hook)
252b5132
RH
784 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
785 const Elf_Internal_Rela *relocs));
786
e6c51ed4
NC
787 /* This function, if defined, is called after the ELF headers have
788 been created. This allows for things like the OS and ABI versions
789 to be changed. */
790 void (*elf_backend_post_process_headers)
791 PARAMS ((bfd *, struct bfd_link_info *));
792
587ff49e
RH
793 /* This function, if defined, prints a symbol to file and returns the
794 name of the symbol to be printed. It should return NULL to fall
795 back to default symbol printing. */
796 const char *(*elf_backend_print_symbol_all)
797 PARAMS ((bfd *, PTR, asymbol *));
798
799 /* This function, if defined, is called after all local symbols and
800 global symbols converted to locals are emited into the symtab
801 section. It allows the backend to emit special global symbols
802 not handled in the hash table. */
b34976b6 803 bfd_boolean (*elf_backend_output_arch_syms)
587ff49e 804 PARAMS ((bfd *, struct bfd_link_info *, PTR,
b34976b6 805 bfd_boolean (*) (PTR, const char *, Elf_Internal_Sym *, asection *)));
587ff49e 806
d4c88bbb 807 /* Copy any information related to dynamic linking from a pre-existing
0a991dfe
AM
808 symbol to a newly created symbol. Also called to copy flags and
809 other back-end info to a weakdef, in which case the symbol is not
810 newly created and plt/got refcounts and dynamic indices should not
811 be copied. */
c61b8717 812 void (*elf_backend_copy_indirect_symbol)
b48fa14c
AM
813 PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
814 struct elf_link_hash_entry *));
c61b8717
RH
815
816 /* Modify any information related to dynamic linking such that the
817 symbol is not exported. */
818 void (*elf_backend_hide_symbol)
b34976b6 819 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
c61b8717 820
9317eacc
CM
821 /* Emit relocations. Overrides default routine for emitting relocs,
822 except during a relocatable link, or if all relocs are being emitted. */
b34976b6 823 bfd_boolean (*elf_backend_emit_relocs)
9317eacc
CM
824 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
825
826 /* Count relocations. Not called for relocatable links
827 or if all relocs are being preserved in the output. */
828 unsigned int (*elf_backend_count_relocs)
829 PARAMS ((asection *, Elf_Internal_Rela *));
830
bb0082d6
AM
831 /* This function, if defined, is called when an NT_PRSTATUS note is found
832 in a core file. */
b34976b6 833 bfd_boolean (*elf_backend_grok_prstatus)
dc810e39 834 PARAMS ((bfd *, Elf_Internal_Note *));
bb0082d6
AM
835
836 /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
837 note is found in a core file. */
b34976b6 838 bfd_boolean (*elf_backend_grok_psinfo)
dc810e39 839 PARAMS ((bfd *, Elf_Internal_Note *));
bb0082d6 840
db6751f2 841 /* Functions to print VMAs. Special code to handle 64 bit ELF files. */
dc810e39
AM
842 void (* elf_backend_sprintf_vma)
843 PARAMS ((bfd *, char *, bfd_vma));
844 void (* elf_backend_fprintf_vma)
845 PARAMS ((bfd *, PTR, bfd_vma));
4e771d61 846
db6751f2 847 /* This function returns class of a reloc type. */
f51e552e
AM
848 enum elf_reloc_type_class (*elf_backend_reloc_type_class)
849 PARAMS ((const Elf_Internal_Rela *));
db6751f2 850
73d074b4
DJ
851 /* This function, if defined, removes information about discarded functions
852 from other sections which mention them. */
b34976b6 853 bfd_boolean (*elf_backend_discard_info)
73d074b4
DJ
854 PARAMS ((bfd *, struct elf_reloc_cookie *, struct bfd_link_info *));
855
856 /* This function, if defined, signals that the function above has removed
857 the discarded relocations for this section. */
b34976b6 858 bfd_boolean (*elf_backend_ignore_discarded_relocs)
73d074b4
DJ
859 PARAMS ((asection *));
860
861 /* This function, if defined, may write out the given section.
b34976b6
AM
862 Returns TRUE if it did so and FALSE if the caller should. */
863 bfd_boolean (*elf_backend_write_section)
73d074b4
DJ
864 PARAMS ((bfd *, asection *, bfd_byte *));
865
c6e90b02
TS
866 /* The level of IRIX compatibility we're striving for.
867 MIPS ELF specific function. */
868 irix_compat_t (*elf_backend_mips_irix_compat)
869 PARAMS ((bfd *));
870
871 reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
b34976b6 872 PARAMS ((unsigned int, bfd_boolean));
c6e90b02 873
252b5132
RH
874 /* The swapping table to use when dealing with ECOFF information.
875 Used for the MIPS ELF .mdebug section. */
876 const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
877
878 /* Alternate EM_xxxx machine codes for this backend. */
879 int elf_machine_alt1;
880 int elf_machine_alt2;
881
882 const struct elf_size_info *s;
883
884 /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
885 .got section */
886 bfd_vma got_symbol_offset;
887
888 /* The size in bytes of the headers for the GOT and PLT. This includes
889 the so-called reserved entries on some systems. */
890 bfd_vma got_header_size;
891 bfd_vma plt_header_size;
892
b34976b6
AM
893 /* This is TRUE if the linker should act like collect and gather
894 global constructors and destructors by name. This is TRUE for
86dc0f79
RH
895 MIPS ELF because the Irix 5 tools can not handle the .init
896 section. */
897 unsigned collect : 1;
898
b34976b6
AM
899 /* This is TRUE if the linker should ignore changes to the type of a
900 symbol. This is TRUE for MIPS ELF because some Irix 5 objects
86dc0f79
RH
901 record undefined functions as STT_OBJECT although the definitions
902 are STT_FUNC. */
903 unsigned type_change_ok : 1;
904
bf572ba0
MM
905 /* Whether the backend may use REL relocations. (Some backends use
906 both REL and RELA relocations, and this flag is set for those
907 backends.) */
908 unsigned may_use_rel_p : 1;
60bcf0fa 909
bf572ba0
MM
910 /* Whether the backend may use RELA relocations. (Some backends use
911 both REL and RELA relocations, and this flag is set for those
912 backends.) */
913 unsigned may_use_rela_p : 1;
914
915 /* Whether the default relocation type is RELA. If a backend with
916 this flag set wants REL relocations for a particular section,
917 it must note that explicitly. Similarly, if this flag is clear,
60bcf0fa
NC
918 and the backend wants RELA relocations for a particular
919 section. */
bf572ba0
MM
920 unsigned default_use_rela_p : 1;
921
b491616a
AM
922 /* Set if RELA relocations for a relocatable link can be handled by
923 generic code. Backends that set this flag need do nothing in the
924 backend relocate_section routine for relocatable linking. */
925 unsigned rela_normal : 1;
926
b34976b6 927 /* TRUE if addresses "naturally" sign extend. This is used when
86dc0f79
RH
928 swapping in from Elf32 when BFD64. */
929 unsigned sign_extend_vma : 1;
930
252b5132
RH
931 unsigned want_got_plt : 1;
932 unsigned plt_readonly : 1;
933 unsigned want_plt_sym : 1;
934 unsigned plt_not_loaded : 1;
935 unsigned plt_alignment : 4;
936 unsigned can_gc_sections : 1;
51b64d56 937 unsigned can_refcount : 1;
2517a57f 938 unsigned want_got_sym : 1;
3018b441 939 unsigned want_dynbss : 1;
5e8d7549
NC
940 /* Targets which do not support physical addressing often require
941 that the p_paddr field in the section header to be set to zero.
942 This field indicates whether this behavior is required. */
943 unsigned want_p_paddr_set_to_zero : 1;
252b5132
RH
944};
945
946/* Information stored for each BFD section in an ELF file. This
947 structure is allocated by elf_new_section_hook. */
948
949struct bfd_elf_section_data
950{
951 /* The ELF header for this section. */
952 Elf_Internal_Shdr this_hdr;
0c715baa 953
252b5132
RH
954 /* The ELF header for the reloc section associated with this
955 section, if any. */
956 Elf_Internal_Shdr rel_hdr;
0c715baa 957
252b5132
RH
958 /* If there is a second reloc section associated with this section,
959 as can happen on Irix 6, this field points to the header. */
960 Elf_Internal_Shdr *rel_hdr2;
0c715baa 961
23bc299b
MM
962 /* The number of relocations currently assigned to REL_HDR. */
963 unsigned int rel_count;
0c715baa 964
23bc299b
MM
965 /* The number of relocations currently assigned to REL_HDR2. */
966 unsigned int rel_count2;
0c715baa 967
252b5132
RH
968 /* The ELF section number of this section. Only used for an output
969 file. */
970 int this_idx;
0c715baa 971
23bc299b
MM
972 /* The ELF section number of the reloc section indicated by
973 REL_HDR if any. Only used for an output file. */
252b5132 974 int rel_idx;
0c715baa 975
23bc299b
MM
976 /* The ELF section number of the reloc section indicated by
977 REL_HDR2 if any. Only used for an output file. */
978 int rel_idx2;
0c715baa 979
f0abc2a1
AM
980 /* Used by the backend linker when generating a shared library to
981 record the dynamic symbol index for a section symbol
982 corresponding to this section. A value of 0 means that there is
983 no dynamic symbol for this section. */
984 int dynindx;
985
252b5132
RH
986 /* Used by the backend linker to store the symbol hash table entries
987 associated with relocs against global symbols. */
988 struct elf_link_hash_entry **rel_hashes;
0c715baa 989
252b5132
RH
990 /* A pointer to the swapped relocs. If the section uses REL relocs,
991 rather than RELA, all the r_addend fields will be zero. This
992 pointer may be NULL. It is used by the backend linker. */
993 Elf_Internal_Rela *relocs;
0c715baa 994
f0abc2a1
AM
995 /* A pointer to a linked list tracking dynamic relocs copied for
996 local symbols. */
997 PTR local_dynrel;
0c715baa 998
f0abc2a1
AM
999 /* A pointer to the bfd section used for dynamic relocs. */
1000 asection *sreloc;
0c715baa 1001
1126897b
AM
1002 union {
1003 /* Group name, if this section is a member of a group. */
1004 const char *name;
1005
1006 /* Group signature sym, if this is the SHT_GROUP section. */
1007 struct symbol_cache_entry *id;
1008 } group;
dbb410c3
AM
1009
1010 /* A linked list of sections in the group. Circular when used by
1011 the linker. */
1012 asection *next_in_group;
1013
f0abc2a1
AM
1014 /* A pointer used for various section optimizations. */
1015 PTR sec_info;
252b5132
RH
1016};
1017
1018#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
1126897b
AM
1019#define elf_group_name(sec) (elf_section_data(sec)->group.name)
1020#define elf_group_id(sec) (elf_section_data(sec)->group.id)
945906ff 1021#define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
252b5132 1022
b34976b6 1023/* Return TRUE if section has been discarded. */
68bfbfcc
AM
1024#define elf_discarded_section(sec) \
1025 (!bfd_is_abs_section (sec) \
1026 && bfd_is_abs_section ((sec)->output_section) \
1027 && sec->sec_info_type != ELF_INFO_TYPE_MERGE \
1028 && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
ed4de5e2 1029
252b5132
RH
1030#define get_elf_backend_data(abfd) \
1031 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
1032
1033/* Enumeration to specify the special section. */
1034typedef enum elf_linker_section_enum
1035{
1036 LINKER_SECTION_UNKNOWN, /* not used */
1037 LINKER_SECTION_GOT, /* .got section for global offset pointers */
1038 LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
1039 LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
1040 LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
1041 LINKER_SECTION_MAX /* # of linker sections */
1042} elf_linker_section_enum_t;
1043
1044/* Sections created by the linker. */
1045
1046typedef struct elf_linker_section
1047{
1048 char *name; /* name of the section */
1049 char *rel_name; /* name of the associated .rel{,a}. section */
1050 char *bss_name; /* name of a related .bss section */
1051 char *sym_name; /* name of symbol to reference this section */
1052 asection *section; /* pointer to the section */
1053 asection *bss_section; /* pointer to the bss section associated with this */
1054 asection *rel_section; /* pointer to the relocations needed for this section */
1055 struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
1056 bfd_vma initial_size; /* initial size before any linker generated allocations */
1057 bfd_vma sym_offset; /* offset of symbol from beginning of section */
1058 bfd_vma hole_size; /* size of reserved address hole in allocation */
1059 bfd_vma hole_offset; /* current offset for the hole */
1060 bfd_vma max_hole_offset; /* maximum offset for the hole */
1061 elf_linker_section_enum_t which; /* which section this is */
b34976b6 1062 bfd_boolean hole_written_p; /* whether the hole has been initialized */
252b5132
RH
1063 unsigned int alignment; /* alignment for the section */
1064 flagword flags; /* flags to use to create the section */
1065} elf_linker_section_t;
1066
1067/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
1068 provides allows us to return different pointers, based on different addend's. */
1069
1070typedef struct elf_linker_section_pointers
1071{
1072 struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
1073 bfd_vma offset; /* offset of pointer from beginning of section */
dc810e39 1074 bfd_vma addend; /* addend used */
252b5132 1075 elf_linker_section_enum_t which; /* which linker section this is */
b34976b6 1076 bfd_boolean written_address_p; /* whether address was written yet */
252b5132
RH
1077} elf_linker_section_pointers_t;
1078
45d6a902
AM
1079/* This struct is used to pass information to routines called via
1080 elf_link_hash_traverse which must return failure. */
1081
1082struct elf_info_failed
1083{
1084 bfd_boolean failed;
1085 struct bfd_link_info *info;
1086 struct bfd_elf_version_tree *verdefs;
1087};
1088
1089/* This structure is used to pass information to
1090 _bfd_elf_link_assign_sym_version. */
1091
1092struct elf_assign_sym_version_info
1093{
1094 /* Output BFD. */
1095 bfd *output_bfd;
1096 /* General link information. */
1097 struct bfd_link_info *info;
1098 /* Version tree. */
1099 struct bfd_elf_version_tree *verdefs;
1100 /* Whether we had a failure. */
1101 bfd_boolean failed;
1102};
1103
1104/* This structure is used to pass information to
1105 _bfd_elf_link_find_version_dependencies. */
1106
1107struct elf_find_verdep_info
1108{
1109 /* Output BFD. */
1110 bfd *output_bfd;
1111 /* General link information. */
1112 struct bfd_link_info *info;
1113 /* The number of dependencies. */
1114 unsigned int vers;
1115 /* Whether we had a failure. */
1116 bfd_boolean failed;
1117};
1118
252b5132
RH
1119/* Some private data is stashed away for future use using the tdata pointer
1120 in the bfd structure. */
1121
1122struct elf_obj_tdata
1123{
1124 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
1125 Elf_Internal_Shdr **elf_sect_ptr;
1126 Elf_Internal_Phdr *phdr;
1127 struct elf_segment_map *segment_map;
2b0f7ef9 1128 struct elf_strtab_hash *strtab_ptr;
252b5132
RH
1129 int num_locals;
1130 int num_globals;
9ad5cbcf 1131 unsigned int num_elf_sections; /* elf_sect_ptr size */
4e89ac30 1132 int num_section_syms;
252b5132
RH
1133 asymbol **section_syms; /* STT_SECTION symbols for each section */
1134 Elf_Internal_Shdr symtab_hdr;
1135 Elf_Internal_Shdr shstrtab_hdr;
1136 Elf_Internal_Shdr strtab_hdr;
1137 Elf_Internal_Shdr dynsymtab_hdr;
1138 Elf_Internal_Shdr dynstrtab_hdr;
1139 Elf_Internal_Shdr dynversym_hdr;
1140 Elf_Internal_Shdr dynverref_hdr;
1141 Elf_Internal_Shdr dynverdef_hdr;
9ad5cbcf 1142 Elf_Internal_Shdr symtab_shndx_hdr;
252b5132
RH
1143 unsigned int symtab_section, shstrtab_section;
1144 unsigned int strtab_section, dynsymtab_section;
9ad5cbcf 1145 unsigned int symtab_shndx_section;
252b5132
RH
1146 unsigned int dynversym_section, dynverdef_section, dynverref_section;
1147 file_ptr next_file_pos;
1148#if 0
1149 /* we don't need these inside bfd anymore, and I think
3e932841 1150 these weren't used outside bfd. */
252b5132
RH
1151 void *prstatus; /* The raw /proc prstatus structure */
1152 void *prpsinfo; /* The raw /proc prpsinfo structure */
1153#endif
dbb410c3
AM
1154 bfd_vma gp; /* The gp value */
1155 unsigned int gp_size; /* The gp size */
1156
1157 Elf_Internal_Shdr **group_sect_ptr;
1158 int num_group;
252b5132 1159
3e932841 1160 /* Information grabbed from an elf core file. */
252b5132
RH
1161 int core_signal;
1162 int core_pid;
1163 int core_lwpid;
1164 char* core_program;
1165 char* core_command;
1166
b34976b6 1167 /* This is set to TRUE if the object was created by the backend
252b5132 1168 linker. */
b34976b6 1169 bfd_boolean linker;
252b5132
RH
1170
1171 /* A mapping from external symbols to entries in the linker hash
1172 table, used when linking. This is indexed by the symbol index
1173 minus the sh_info field of the symbol table header. */
1174 struct elf_link_hash_entry **sym_hashes;
1175
5cab59f6
AM
1176 /* Track usage and final offsets of GOT entries for local symbols.
1177 This array is indexed by symbol index. Elements are used
1178 identically to "got" in struct elf_link_hash_entry. */
252b5132
RH
1179 union
1180 {
1181 bfd_signed_vma *refcounts;
1182 bfd_vma *offsets;
5cab59f6 1183 struct got_entry **ents;
252b5132
RH
1184 } local_got;
1185
1186 /* A mapping from local symbols to offsets into the various linker
1187 sections added. This is index by the symbol index. */
1188 elf_linker_section_pointers_t **linker_section_pointers;
1189
1190 /* The linker ELF emulation code needs to let the backend ELF linker
1191 know what filename should be used for a dynamic object if the
1192 dynamic object is found using a search. The emulation code then
1193 sometimes needs to know what name was actually used. Until the
1194 file has been added to the linker symbol table, this field holds
1195 the name the linker wants. After it has been added, it holds the
1196 name actually used, which will be the DT_SONAME entry if there is
1197 one. */
1198 const char *dt_name;
1199
74816898
L
1200 /* When a reference in a regular object is resolved by a shared
1201 object is loaded into via the DT_NEEDED entries by the linker
1202 ELF emulation code, we need to add the shared object to the
1203 DT_NEEDED list of the resulting binary to indicate the dependency
1204 as if the -l option is passed to the linker. This field holds the
3e932841 1205 name of the loaded shared object. */
74816898
L
1206 const char *dt_soname;
1207
252b5132
RH
1208 /* Irix 5 often screws up the symbol table, sorting local symbols
1209 after global symbols. This flag is set if the symbol table in
1210 this BFD appears to be screwed up. If it is, we ignore the
1211 sh_info field in the symbol table header, and always read all the
1212 symbols. */
b34976b6 1213 bfd_boolean bad_symtab;
252b5132
RH
1214
1215 /* Records the result of `get_program_header_size'. */
1216 bfd_size_type program_header_size;
1217
1218 /* Used by find_nearest_line entry point. */
1219 PTR line_info;
1220
1221 /* Used by MIPS ELF find_nearest_line entry point. The structure
1222 could be included directly in this one, but there's no point to
1223 wasting the memory just for the infrequently called
1224 find_nearest_line. */
1225 struct mips_elf_find_line *find_line_info;
1226
3e932841 1227 /* A place to stash dwarf1 info for this bfd. */
252b5132
RH
1228 struct dwarf1_debug *dwarf1_find_line_info;
1229
3e932841 1230 /* A place to stash dwarf2 info for this bfd. */
51db3708 1231 PTR dwarf2_find_line_info;
252b5132
RH
1232
1233 /* An array of stub sections indexed by symbol number, used by the
1234 MIPS ELF linker. FIXME: We should figure out some way to only
1235 include this field for a MIPS ELF target. */
1236 asection **local_stubs;
1237
65765700
JJ
1238 /* Used to determine if PT_GNU_EH_FRAME segment header should be
1239 created. */
126495ed
AM
1240 asection *eh_frame_hdr;
1241
1242 /* Used to determine if the e_flags field has been initialized */
b34976b6 1243 bfd_boolean flags_init;
65765700 1244
252b5132
RH
1245 /* Number of symbol version definitions we are about to emit. */
1246 unsigned int cverdefs;
1247
1248 /* Number of symbol version references we are about to emit. */
1249 unsigned int cverrefs;
1250
1251 /* Symbol version definitions in external objects. */
1252 Elf_Internal_Verdef *verdef;
1253
1254 /* Symbol version references to external objects. */
1255 Elf_Internal_Verneed *verref;
1256
1257 /* Linker sections that we are interested in. */
1258 struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
b305ef96
UC
1259
1260 /* The Irix 5 support uses two virtual sections, which represent
1261 text/data symbols defined in dynamic objects. */
1262 asymbol *elf_data_symbol;
1263 asymbol *elf_text_symbol;
1264 asection *elf_data_section;
1265 asection *elf_text_section;
252b5132
RH
1266};
1267
1268#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
1269#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
1270#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
9ad5cbcf 1271#define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections)
252b5132
RH
1272#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
1273#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
9ad5cbcf 1274#define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section)
252b5132
RH
1275#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
1276#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
1277#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
1278#define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
1279#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
1280#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
1281#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
4e89ac30 1282#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
252b5132
RH
1283#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
1284#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
1285#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
1286#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
1287#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
1288#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
1289#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
5cab59f6 1290#define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
252b5132
RH
1291#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
1292#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
74816898 1293#define elf_dt_soname(bfd) (elf_tdata(bfd) -> dt_soname)
252b5132
RH
1294#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
1295#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
1296#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
1297\f
1298extern void _bfd_elf_swap_verdef_in
1299 PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
1300extern void _bfd_elf_swap_verdef_out
1301 PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
1302extern void _bfd_elf_swap_verdaux_in
1303 PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
1304extern void _bfd_elf_swap_verdaux_out
1305 PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
1306extern void _bfd_elf_swap_verneed_in
1307 PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
1308extern void _bfd_elf_swap_verneed_out
1309 PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
1310extern void _bfd_elf_swap_vernaux_in
1311 PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
1312extern void _bfd_elf_swap_vernaux_out
1313 PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
1314extern void _bfd_elf_swap_versym_in
1315 PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
1316extern void _bfd_elf_swap_versym_out
1317 PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
1318
dc810e39
AM
1319extern int _bfd_elf_section_from_bfd_section
1320 PARAMS ((bfd *, asection *));
252b5132
RH
1321extern char *bfd_elf_string_from_elf_section
1322 PARAMS ((bfd *, unsigned, unsigned));
dc810e39
AM
1323extern char *bfd_elf_get_str_section
1324 PARAMS ((bfd *, unsigned));
6cdc0ccc
AM
1325extern Elf_Internal_Sym *bfd_elf_get_elf_syms
1326 PARAMS ((bfd *, Elf_Internal_Shdr *, size_t, size_t,
1327 Elf_Internal_Sym *, PTR, Elf_External_Sym_Shndx *));
5cab59f6
AM
1328extern const char *bfd_elf_local_sym_name
1329 PARAMS ((bfd *, Elf_Internal_Sym *));
252b5132 1330
b34976b6 1331extern bfd_boolean _bfd_elf_copy_private_bfd_data
2d502050 1332 PARAMS ((bfd *, bfd *));
b34976b6 1333extern bfd_boolean _bfd_elf_print_private_bfd_data
dc810e39
AM
1334 PARAMS ((bfd *, PTR));
1335extern void bfd_elf_print_symbol
1336 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
1337
1338#define elf_string_from_elf_strtab(abfd, strindex) \
1339 bfd_elf_string_from_elf_section(abfd, elf_elfheader(abfd)->e_shstrndx, \
1340 strindex)
252b5132
RH
1341
1342#define bfd_elf32_print_symbol bfd_elf_print_symbol
1343#define bfd_elf64_print_symbol bfd_elf_print_symbol
1344
dc810e39
AM
1345extern void _bfd_elf_sprintf_vma
1346 PARAMS ((bfd *, char *, bfd_vma));
1347extern void _bfd_elf_fprintf_vma
1348 PARAMS ((bfd *, PTR, bfd_vma));
d69bb69b 1349
dc810e39 1350extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
f51e552e 1351 PARAMS ((const Elf_Internal_Rela *));
f8df10f4
JJ
1352extern bfd_vma _bfd_elf_rela_local_sym
1353 PARAMS ((bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *));
c629eae0
JJ
1354extern bfd_vma _bfd_elf_rel_local_sym
1355 PARAMS ((bfd *, Elf_Internal_Sym *, asection **, bfd_vma));
1356extern bfd_vma _bfd_elf_section_offset
1357 PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_vma));
db6751f2 1358
dc810e39
AM
1359extern unsigned long bfd_elf_hash
1360 PARAMS ((const char *));
252b5132 1361
dc810e39
AM
1362extern bfd_reloc_status_type bfd_elf_generic_reloc
1363 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
b34976b6 1364extern bfd_boolean bfd_elf_mkobject
dc810e39 1365 PARAMS ((bfd *));
b34976b6 1366extern bfd_boolean bfd_elf_mkcorefile
dc810e39
AM
1367 PARAMS ((bfd *));
1368extern Elf_Internal_Shdr *bfd_elf_find_section
1369 PARAMS ((bfd *, char *));
b34976b6 1370extern bfd_boolean _bfd_elf_make_section_from_shdr
dc810e39 1371 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
b34976b6 1372extern bfd_boolean _bfd_elf_make_section_from_phdr
dc810e39 1373 PARAMS ((bfd *, Elf_Internal_Phdr *, int, const char *));
252b5132
RH
1374extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
1375 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
1376extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
1377 PARAMS ((bfd *));
c61b8717 1378extern void _bfd_elf_link_hash_copy_indirect
b48fa14c
AM
1379 PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
1380 struct elf_link_hash_entry *));
c61b8717 1381extern void _bfd_elf_link_hash_hide_symbol
b34976b6
AM
1382 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
1383extern bfd_boolean _bfd_elf_link_hash_table_init
252b5132
RH
1384 PARAMS ((struct elf_link_hash_table *, bfd *,
1385 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
1386 struct bfd_hash_table *,
1387 const char *)));
b34976b6 1388extern bfd_boolean _bfd_elf_slurp_version_tables
dc810e39 1389 PARAMS ((bfd *));
b34976b6 1390extern bfd_boolean _bfd_elf_merge_sections
8550eb6e 1391 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1392extern bfd_boolean bfd_elf_discard_group
e61463e1 1393 PARAMS ((bfd *, struct sec *));
1126897b
AM
1394extern void bfd_elf_set_group_contents
1395 PARAMS ((bfd *, asection *, PTR));
2d653fc7
AM
1396extern void _bfd_elf_link_just_syms
1397 PARAMS ((asection *, struct bfd_link_info *));
b34976b6 1398extern bfd_boolean _bfd_elf_copy_private_symbol_data
252b5132 1399 PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
b34976b6 1400extern bfd_boolean _bfd_elf_copy_private_section_data
252b5132 1401 PARAMS ((bfd *, asection *, bfd *, asection *));
b34976b6 1402extern bfd_boolean _bfd_elf_write_object_contents
dc810e39 1403 PARAMS ((bfd *));
b34976b6 1404extern bfd_boolean _bfd_elf_write_corefile_contents
dc810e39 1405 PARAMS ((bfd *));
b34976b6 1406extern bfd_boolean _bfd_elf_set_section_contents
dc810e39
AM
1407 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
1408extern long _bfd_elf_get_symtab_upper_bound
1409 PARAMS ((bfd *));
1410extern long _bfd_elf_get_symtab
1411 PARAMS ((bfd *, asymbol **));
1412extern long _bfd_elf_get_dynamic_symtab_upper_bound
1413 PARAMS ((bfd *));
1414extern long _bfd_elf_canonicalize_dynamic_symtab
1415 PARAMS ((bfd *, asymbol **));
1416extern long _bfd_elf_get_reloc_upper_bound
1417 PARAMS ((bfd *, sec_ptr));
1418extern long _bfd_elf_canonicalize_reloc
1419 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
1420extern long _bfd_elf_get_dynamic_reloc_upper_bound
1421 PARAMS ((bfd *));
1422extern long _bfd_elf_canonicalize_dynamic_reloc
1423 PARAMS ((bfd *, arelent **, asymbol **));
1424extern asymbol *_bfd_elf_make_empty_symbol
1425 PARAMS ((bfd *));
1426extern void _bfd_elf_get_symbol_info
1427 PARAMS ((bfd *, asymbol *, symbol_info *));
b34976b6 1428extern bfd_boolean _bfd_elf_is_local_label_name
dc810e39
AM
1429 PARAMS ((bfd *, const char *));
1430extern alent *_bfd_elf_get_lineno
1431 PARAMS ((bfd *, asymbol *));
b34976b6 1432extern bfd_boolean _bfd_elf_set_arch_mach
dc810e39 1433 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
b34976b6 1434extern bfd_boolean _bfd_elf_find_nearest_line
dc810e39
AM
1435 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
1436 const char **, unsigned int *));
252b5132
RH
1437#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
1438#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
dc810e39 1439extern int _bfd_elf_sizeof_headers
b34976b6
AM
1440 PARAMS ((bfd *, bfd_boolean));
1441extern bfd_boolean _bfd_elf_new_section_hook
dc810e39 1442 PARAMS ((bfd *, asection *));
b34976b6
AM
1443extern bfd_boolean _bfd_elf_init_reloc_shdr
1444 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean));
252b5132
RH
1445
1446/* If the target doesn't have reloc handling written yet: */
dc810e39
AM
1447extern void _bfd_elf_no_info_to_howto
1448 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
1449
b34976b6 1450extern bfd_boolean bfd_section_from_shdr
dc810e39 1451 PARAMS ((bfd *, unsigned int shindex));
b34976b6 1452extern bfd_boolean bfd_section_from_phdr
dc810e39
AM
1453 PARAMS ((bfd *, Elf_Internal_Phdr *, int));
1454
1455extern int _bfd_elf_symbol_from_bfd_symbol
1456 PARAMS ((bfd *, asymbol **));
1457
ec338859
AM
1458extern asection *bfd_section_from_r_symndx
1459 PARAMS ((bfd *, struct sym_sec_cache *, asection *, unsigned long));
dc810e39
AM
1460extern asection *bfd_section_from_elf_index
1461 PARAMS ((bfd *, unsigned int));
dc810e39
AM
1462extern struct bfd_strtab_hash *_bfd_elf_stringtab_init
1463 PARAMS ((void));
2b0f7ef9
JJ
1464
1465extern struct elf_strtab_hash * _bfd_elf_strtab_init
1466 PARAMS ((void));
1467extern void _bfd_elf_strtab_free
1468 PARAMS ((struct elf_strtab_hash *));
1469extern bfd_size_type _bfd_elf_strtab_add
b34976b6 1470 PARAMS ((struct elf_strtab_hash *, const char *, bfd_boolean));
2b0f7ef9
JJ
1471extern void _bfd_elf_strtab_addref
1472 PARAMS ((struct elf_strtab_hash *, bfd_size_type));
1473extern void _bfd_elf_strtab_delref
1474 PARAMS ((struct elf_strtab_hash *, bfd_size_type));
1475extern void _bfd_elf_strtab_clear_all_refs
1476 PARAMS ((struct elf_strtab_hash *));
1477extern bfd_size_type _bfd_elf_strtab_size
1478 PARAMS ((struct elf_strtab_hash *));
1479extern bfd_size_type _bfd_elf_strtab_offset
1480 PARAMS ((struct elf_strtab_hash *, bfd_size_type));
b34976b6 1481extern bfd_boolean _bfd_elf_strtab_emit
2b0f7ef9
JJ
1482 PARAMS ((bfd *, struct elf_strtab_hash *));
1483extern void _bfd_elf_strtab_finalize
1484 PARAMS ((struct elf_strtab_hash *));
1485
b34976b6 1486extern bfd_boolean _bfd_elf_discard_section_eh_frame
126495ed 1487 PARAMS ((bfd *, struct bfd_link_info *, asection *,
b34976b6
AM
1488 bfd_boolean (*) (bfd_vma, PTR), struct elf_reloc_cookie *));
1489extern bfd_boolean _bfd_elf_discard_section_eh_frame_hdr
126495ed 1490 PARAMS ((bfd *, struct bfd_link_info *));
65765700
JJ
1491extern bfd_vma _bfd_elf_eh_frame_section_offset
1492 PARAMS ((bfd *, asection *, bfd_vma));
b34976b6 1493extern bfd_boolean _bfd_elf_write_section_eh_frame
126495ed 1494 PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_byte *));
b34976b6 1495extern bfd_boolean _bfd_elf_write_section_eh_frame_hdr
126495ed 1496 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1497extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
68f69152 1498 PARAMS ((struct bfd_link_info *));
65765700 1499
45d6a902
AM
1500extern bfd_boolean _bfd_elf_merge_symbol
1501 PARAMS ((bfd *, struct bfd_link_info *, const char *,
1502 Elf_Internal_Sym *, asection **, bfd_vma *,
1503 struct elf_link_hash_entry **, bfd_boolean *, bfd_boolean *,
1504 bfd_boolean *, bfd_boolean *, bfd_boolean));
1505
1506extern bfd_boolean _bfd_elf_add_default_symbol
1507 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
1508 const char *, Elf_Internal_Sym *, asection **, bfd_vma *,
1509 bfd_boolean *, bfd_boolean, bfd_boolean));
1510
1511extern bfd_boolean _bfd_elf_export_symbol
1512 PARAMS ((struct elf_link_hash_entry *, PTR));
1513
1514extern bfd_boolean _bfd_elf_link_find_version_dependencies
1515 PARAMS ((struct elf_link_hash_entry *, PTR));
1516
1517extern bfd_boolean _bfd_elf_link_assign_sym_version
1518 PARAMS ((struct elf_link_hash_entry *, PTR));
1519
b34976b6 1520extern bfd_boolean _bfd_elf_link_record_dynamic_symbol
dc810e39
AM
1521 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
1522extern long _bfd_elf_link_lookup_local_dynindx
1523 PARAMS ((struct bfd_link_info *, bfd *, long));
b34976b6 1524extern bfd_boolean _bfd_elf_compute_section_file_positions
dc810e39
AM
1525 PARAMS ((bfd *, struct bfd_link_info *));
1526extern void _bfd_elf_assign_file_positions_for_relocs
1527 PARAMS ((bfd *));
1528extern file_ptr _bfd_elf_assign_file_position_for_section
b34976b6 1529 PARAMS ((Elf_Internal_Shdr *, file_ptr, bfd_boolean));
dc810e39 1530
b34976b6 1531extern bfd_boolean _bfd_elf_validate_reloc
dc810e39
AM
1532 PARAMS ((bfd *, arelent *));
1533
45d6a902
AM
1534extern bfd_boolean _bfd_elf_link_create_dynamic_sections
1535 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1536extern bfd_boolean _bfd_elf_create_dynamic_sections
dc810e39 1537 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1538extern bfd_boolean _bfd_elf_create_got_section
dc810e39
AM
1539 PARAMS ((bfd *, struct bfd_link_info *));
1540extern unsigned long _bfd_elf_link_renumber_dynsyms
1541 PARAMS ((bfd *, struct bfd_link_info *));
1542
b34976b6 1543extern bfd_boolean _bfd_elfcore_make_pseudosection
dc810e39
AM
1544 PARAMS ((bfd *, char *, size_t, ufile_ptr));
1545extern char *_bfd_elfcore_strndup
1546 PARAMS ((bfd *, char *, size_t));
1547
1548extern elf_linker_section_t *_bfd_elf_create_linker_section
1549 PARAMS ((bfd *, struct bfd_link_info *, enum elf_linker_section_enum,
1550 elf_linker_section_t *));
1551
1552extern elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
1553 PARAMS ((elf_linker_section_pointers_t *, bfd_vma,
1554 elf_linker_section_enum_t));
1555
b34976b6 1556extern bfd_boolean bfd_elf32_create_pointer_linker_section
dc810e39 1557 PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
947216bf 1558 struct elf_link_hash_entry *, const Elf_Internal_Rela *));
dc810e39
AM
1559
1560extern bfd_vma bfd_elf32_finish_pointer_linker_section
1561 PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
1562 struct elf_link_hash_entry *, bfd_vma,
947216bf 1563 const Elf_Internal_Rela *, int));
dc810e39 1564
b34976b6 1565extern bfd_boolean bfd_elf64_create_pointer_linker_section
dc810e39 1566 PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
947216bf 1567 struct elf_link_hash_entry *, const Elf_Internal_Rela *));
dc810e39
AM
1568
1569extern bfd_vma bfd_elf64_finish_pointer_linker_section
1570 PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
1571 struct elf_link_hash_entry *, bfd_vma,
947216bf 1572 const Elf_Internal_Rela *, int));
dc810e39 1573
b34976b6 1574extern bfd_boolean _bfd_elf_make_linker_section_rela
dc810e39
AM
1575 PARAMS ((bfd *, elf_linker_section_t *, int));
1576
45d6a902
AM
1577extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
1578 PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, bfd_boolean));
1579
1580extern bfd_boolean _bfd_elf_link_size_reloc_section
1581 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
1582
1583extern bfd_boolean _bfd_elf_link_output_relocs
1584 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
1585
1586extern bfd_boolean _bfd_elf_fix_symbol_flags
1587 PARAMS ((struct elf_link_hash_entry *, struct elf_info_failed *));
1588
1589extern bfd_boolean _bfd_elf_adjust_dynamic_symbol
1590 PARAMS ((struct elf_link_hash_entry *, PTR));
1591
1592extern bfd_boolean _bfd_elf_link_sec_merge_syms
1593 PARAMS ((struct elf_link_hash_entry *, PTR));
1594
dc810e39
AM
1595extern const bfd_target *bfd_elf32_object_p
1596 PARAMS ((bfd *));
1597extern const bfd_target *bfd_elf32_core_file_p
1598 PARAMS ((bfd *));
1599extern char *bfd_elf32_core_file_failing_command
1600 PARAMS ((bfd *));
1601extern int bfd_elf32_core_file_failing_signal
1602 PARAMS ((bfd *));
b34976b6 1603extern bfd_boolean bfd_elf32_core_file_matches_executable_p
dc810e39 1604 PARAMS ((bfd *, bfd *));
252b5132 1605
b34976b6 1606extern bfd_boolean bfd_elf32_bfd_link_add_symbols
252b5132 1607 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1608extern bfd_boolean bfd_elf32_bfd_final_link
252b5132
RH
1609 PARAMS ((bfd *, struct bfd_link_info *));
1610
1611extern void bfd_elf32_swap_symbol_in
f8ecb12b 1612 PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *));
252b5132 1613extern void bfd_elf32_swap_symbol_out
9ad5cbcf 1614 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
252b5132 1615extern void bfd_elf32_swap_reloc_in
947216bf 1616 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
252b5132 1617extern void bfd_elf32_swap_reloc_out
947216bf 1618 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
252b5132 1619extern void bfd_elf32_swap_reloca_in
947216bf 1620 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
252b5132 1621extern void bfd_elf32_swap_reloca_out
947216bf 1622 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
252b5132
RH
1623extern void bfd_elf32_swap_phdr_in
1624 PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
1625extern void bfd_elf32_swap_phdr_out
1626 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
1627extern void bfd_elf32_swap_dyn_in
1628 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1629extern void bfd_elf32_swap_dyn_out
c7ac6ff8 1630 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
252b5132 1631extern long bfd_elf32_slurp_symbol_table
b34976b6
AM
1632 PARAMS ((bfd *, asymbol **, bfd_boolean));
1633extern bfd_boolean bfd_elf32_write_shdrs_and_ehdr
dc810e39 1634 PARAMS ((bfd *));
252b5132 1635extern int bfd_elf32_write_out_phdrs
dc810e39 1636 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
b9f66672
JL
1637extern void bfd_elf32_write_relocs
1638 PARAMS ((bfd *, asection *, PTR));
b34976b6
AM
1639extern bfd_boolean bfd_elf32_slurp_reloc_table
1640 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
1641extern bfd_boolean bfd_elf32_add_dynamic_entry
252b5132 1642 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
252b5132 1643
dc810e39
AM
1644extern const bfd_target *bfd_elf64_object_p
1645 PARAMS ((bfd *));
1646extern const bfd_target *bfd_elf64_core_file_p
1647 PARAMS ((bfd *));
1648extern char *bfd_elf64_core_file_failing_command
1649 PARAMS ((bfd *));
1650extern int bfd_elf64_core_file_failing_signal
1651 PARAMS ((bfd *));
b34976b6 1652extern bfd_boolean bfd_elf64_core_file_matches_executable_p
dc810e39 1653 PARAMS ((bfd *, bfd *));
b34976b6 1654extern bfd_boolean bfd_elf64_bfd_link_add_symbols
252b5132 1655 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1656extern bfd_boolean bfd_elf64_bfd_final_link
252b5132
RH
1657 PARAMS ((bfd *, struct bfd_link_info *));
1658
1659extern void bfd_elf64_swap_symbol_in
f8ecb12b 1660 PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *));
252b5132 1661extern void bfd_elf64_swap_symbol_out
9ad5cbcf 1662 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
252b5132 1663extern void bfd_elf64_swap_reloc_in
947216bf 1664 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
252b5132 1665extern void bfd_elf64_swap_reloc_out
947216bf 1666 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
252b5132 1667extern void bfd_elf64_swap_reloca_in
947216bf 1668 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
252b5132 1669extern void bfd_elf64_swap_reloca_out
947216bf 1670 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
252b5132
RH
1671extern void bfd_elf64_swap_phdr_in
1672 PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
1673extern void bfd_elf64_swap_phdr_out
1674 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
1675extern void bfd_elf64_swap_dyn_in
1676 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1677extern void bfd_elf64_swap_dyn_out
c7ac6ff8 1678 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
252b5132 1679extern long bfd_elf64_slurp_symbol_table
b34976b6
AM
1680 PARAMS ((bfd *, asymbol **, bfd_boolean));
1681extern bfd_boolean bfd_elf64_write_shdrs_and_ehdr
dc810e39 1682 PARAMS ((bfd *));
252b5132 1683extern int bfd_elf64_write_out_phdrs
dc810e39 1684 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
b9f66672
JL
1685extern void bfd_elf64_write_relocs
1686 PARAMS ((bfd *, asection *, PTR));
b34976b6
AM
1687extern bfd_boolean bfd_elf64_slurp_reloc_table
1688 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
1689extern bfd_boolean bfd_elf64_add_dynamic_entry
252b5132 1690 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
252b5132 1691
30b30c21
RH
1692#define bfd_elf32_link_record_dynamic_symbol \
1693 _bfd_elf_link_record_dynamic_symbol
1694#define bfd_elf64_link_record_dynamic_symbol \
1695 _bfd_elf_link_record_dynamic_symbol
1696
8c58d23b 1697extern int elf_link_record_local_dynamic_symbol
30b30c21 1698 PARAMS ((struct bfd_link_info *, bfd *, long));
8c58d23b
AM
1699#define _bfd_elf32_link_record_local_dynamic_symbol \
1700 elf_link_record_local_dynamic_symbol
1701#define _bfd_elf64_link_record_local_dynamic_symbol \
1702 elf_link_record_local_dynamic_symbol
252b5132 1703
b34976b6 1704extern bfd_boolean _bfd_elf_close_and_cleanup
dc810e39 1705 PARAMS ((bfd *));
252b5132
RH
1706extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
1707 PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
1708 asection *, bfd *, char **));
1709
b34976b6 1710extern bfd_boolean _bfd_elf32_gc_sections
dc810e39 1711 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1712extern bfd_boolean _bfd_elf32_gc_common_finalize_got_offsets
dc810e39 1713 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1714extern bfd_boolean _bfd_elf32_gc_common_final_link
252b5132 1715 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1716extern bfd_boolean _bfd_elf32_gc_record_vtinherit
252b5132 1717 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
b34976b6 1718extern bfd_boolean _bfd_elf32_gc_record_vtentry
252b5132
RH
1719 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1720
b34976b6 1721extern bfd_boolean _bfd_elf64_gc_sections
252b5132 1722 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1723extern bfd_boolean _bfd_elf64_gc_common_finalize_got_offsets
dc810e39 1724 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1725extern bfd_boolean _bfd_elf64_gc_common_final_link
dc810e39 1726 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 1727extern bfd_boolean _bfd_elf64_gc_record_vtinherit
252b5132 1728 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
b34976b6 1729extern bfd_boolean _bfd_elf64_gc_record_vtentry
252b5132
RH
1730 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1731
b34976b6 1732extern bfd_boolean _bfd_elf32_reloc_symbol_deleted_p
73d074b4 1733 PARAMS ((bfd_vma, PTR));
b34976b6 1734extern bfd_boolean _bfd_elf64_reloc_symbol_deleted_p
73d074b4
DJ
1735 PARAMS ((bfd_vma, PTR));
1736
7c76fa91 1737/* Exported interface for writing elf corefile notes. */
d4c88bbb
AM
1738extern char *elfcore_write_note
1739 PARAMS ((bfd *, char *, int *, const char *, int, const PTR, int));
1740extern char *elfcore_write_prpsinfo
1741 PARAMS ((bfd *, char *, int *, const char *, const char *));
1742extern char *elfcore_write_prstatus
1743 PARAMS ((bfd *, char *, int *, long, int, const PTR));
1744extern char * elfcore_write_pstatus
1745 PARAMS ((bfd *, char *, int *, long, int, const PTR));
1746extern char *elfcore_write_prfpreg
1747 PARAMS ((bfd *, char *, int *, const PTR, int));
1748extern char *elfcore_write_prxfpreg
1749 PARAMS ((bfd *, char *, int *, const PTR, int));
1750extern char *elfcore_write_lwpstatus
1751 PARAMS ((bfd *, char *, int *, long, int, const PTR));
7c76fa91 1752
d4845d57
JR
1753/* SH ELF specific routine. */
1754
b34976b6 1755extern bfd_boolean _sh_elf_set_mach_from_flags
dc810e39 1756 PARAMS ((bfd *));
d4845d57 1757
252b5132 1758#endif /* _LIBELF_H_ */
This page took 0.368598 seconds and 4 git commands to generate.