2003-06-03 Michael Snyder <msnyder@redhat.com>
[binutils.git] / bfd / elf-bfd.h
blob1da605502b5a54bdcbeffc314686d34a2aae58b3
1 /* BFD back-end data structures for ELF files.
2 Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 2002, 2003 Free Software Foundation, Inc.
4 Written by Cygnus Support.
6 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
22 #ifndef _LIBELF_H_
23 #define _LIBELF_H_ 1
25 #include "elf/common.h"
26 #include "elf/internal.h"
27 #include "elf/external.h"
28 #include "bfdlink.h"
30 /* The number of entries in a section is its size divided by the size
31 of a single entry. This is normally only applicable to reloc and
32 symbol table sections. */
33 #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
35 /* If size isn't specified as 64 or 32, NAME macro should fail. */
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. */
39 #ifndef NAME
40 #if ARCH_SIZE==64
41 #define NAME(x,y) CONCAT4 (x,64,_,y)
42 #endif
43 #if ARCH_SIZE==32
44 #define NAME(x,y) CONCAT4 (x,32,_,y)
45 #endif
46 #endif
48 #ifndef NAME
49 #define NAME(x,y) CONCAT4 (x,NOSIZE,_,y)
50 #endif
52 #define ElfNAME(X) NAME(Elf,X)
53 #define elfNAME(X) NAME(elf,X)
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. */
60 typedef struct
62 /* The BFD symbol. */
63 asymbol symbol;
64 /* ELF symbol information. */
65 Elf_Internal_Sym internal_elf_sym;
66 /* Backend specific information. */
67 union
69 unsigned int hppa_arg_reloc;
70 PTR mips_extr;
71 PTR any;
73 tc_data;
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;
80 } elf_symbol_type;
82 struct elf_strtab_hash;
83 struct got_entry;
84 struct plt_entry;
86 /* ELF linker hash table entries. */
88 struct elf_link_hash_entry
90 struct bfd_link_hash_entry root;
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;
96 /* Symbol index as a dynamic symbol. Initialized to -1, and remains
97 -1 if this is not a dynamic symbol. */
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.
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. */
108 long dynindx;
110 /* String table index in .dynstr if this is a dynamic symbol. */
111 unsigned long dynstr_index;
113 /* Hash value of the name computed using the ELF hash function. */
114 unsigned long elf_hash_value;
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;
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;
126 /* Version information. */
127 union
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;
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;
144 bfd_boolean *vtable_entries_used;
146 /* Virtual table derivation info. */
147 struct elf_link_hash_entry *vtable_parent;
149 /* If this symbol requires an entry in the global offset table, the
150 processor specific backend uses this field to track usage and
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
160 bfd_signed_vma refcount;
161 bfd_vma offset;
162 struct got_entry *glist;
163 struct plt_entry *plist;
164 } got;
166 /* Same, but tracks a procedure linkage table entry. */
167 union gotplt_union plt;
169 /* Symbol size. */
170 bfd_size_type size;
172 /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
173 char type;
175 /* Symbol st_other value, symbol visibility. */
176 unsigned char other;
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
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
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
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)
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)
237 /* Records local symbols to be emitted in the dynamic symbol table. */
239 struct elf_link_local_dynamic_entry
241 struct elf_link_local_dynamic_entry *next;
243 /* The input bfd this symbol came from. */
244 bfd *input_bfd;
246 /* The index of the local symbol being copied. */
247 long input_indx;
249 /* The index in the outgoing dynamic symbol table. */
250 long dynindx;
252 /* A copy of the input symbol. */
253 Elf_Internal_Sym isym;
256 struct elf_link_loaded_list
258 struct elf_link_loaded_list *next;
259 bfd *abfd;
262 /* Structures used by the eh_frame optimization code. */
263 struct cie_header
265 unsigned int length;
266 unsigned int id;
269 struct cie
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];
288 struct eh_cie_fde
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;
304 struct eh_frame_sec_info
306 unsigned int count;
307 unsigned int alloced;
308 struct eh_cie_fde entry[1];
311 struct eh_frame_array_ent
313 bfd_vma initial_loc;
314 bfd_vma fde;
317 struct eh_frame_hdr_info
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. */
328 bfd_boolean table;
331 /* Cached start, size and alignment of PT_TLS segment. */
332 struct elf_link_tls_segment
334 bfd_vma start;
335 bfd_size_type size;
336 unsigned int align;
339 /* ELF linker hash table. */
341 struct elf_link_hash_table
343 struct bfd_link_hash_table root;
345 /* Whether we have created the special dynamic sections required
346 when linking against or generating a shared object. */
347 bfd_boolean dynamic_sections_created;
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;
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
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;
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;
364 /* The number of symbols found in the link which must be put into
365 the .dynsym section. */
366 bfd_size_type dynsymcount;
368 /* The string table of dynamic symbols, which becomes the .dynstr
369 section. */
370 struct elf_strtab_hash *dynstr;
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;
376 /* A linked list of DT_NEEDED names found in dynamic objects
377 included in the link. */
378 struct bfd_link_needed_list *needed;
380 /* The _GLOBAL_OFFSET_TABLE_ symbol. */
381 struct elf_link_hash_entry *hgot;
383 /* A pointer to information used to link stabs in sections. */
384 PTR stab_info;
386 /* A pointer to information used to merge SEC_MERGE sections. */
387 PTR merge_info;
389 /* Used by eh_frame code when editing .eh_frame. */
390 struct eh_frame_hdr_info eh_info;
392 /* A linked list of local symbols to be added to .dynsym. */
393 struct elf_link_local_dynamic_entry *dynlocal;
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;
399 /* Cached start, size and alignment of PT_TLS segment. */
400 struct elf_link_tls_segment *tls_segment;
402 /* A linked list of BFD's loaded in the link. */
403 struct elf_link_loaded_list *loaded;
406 /* Look up an entry in an ELF linker hash table. */
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)))
413 /* Traverse an ELF linker hash table. */
415 #define elf_link_hash_traverse(table, func, info) \
416 (bfd_link_hash_traverse \
417 (&(table)->root, \
418 (bfd_boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
419 (info)))
421 /* Get the ELF linker hash table from a link_info structure. */
423 #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
425 /* Returns TRUE if the hash table is a struct elf_link_hash_table. */
426 #define is_elf_hash_table(p) \
427 ((p)->hash->type == bfd_link_elf_hash_table)
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
432 struct sym_sec_cache
434 bfd *abfd;
435 unsigned long indx[LOCAL_SYM_CACHE_SIZE];
436 asection *sec[LOCAL_SYM_CACHE_SIZE];
439 /* Constant information held for an ELF backend. */
441 struct 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;
445 /* The size of entries in the .hash section. */
446 unsigned char sizeof_hash_entry;
448 /* The number of internal relocations to allocate per external
449 relocation entry. */
450 unsigned char int_rels_per_ext_rel;
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
455 unsigned char arch_size, log_file_align;
456 unsigned char elfclass, ev_current;
457 int (*write_out_phdrs)
458 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
459 bfd_boolean (*write_shdrs_and_ehdr)
460 PARAMS ((bfd *));
461 void (*write_relocs)
462 PARAMS ((bfd *, asection *, PTR));
463 void (*swap_symbol_in)
464 PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *));
465 void (*swap_symbol_out)
466 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
467 bfd_boolean (*slurp_reloc_table)
468 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
469 long (*slurp_symbol_table)
470 PARAMS ((bfd *, asymbol **, bfd_boolean));
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));
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. */
479 void (*swap_reloc_in)
480 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
482 /* This function is called to swap out a REL relocation. */
483 void (*swap_reloc_out)
484 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
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. */
489 void (*swap_reloca_in)
490 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
492 /* This function is called to swap out a RELA relocation. */
493 void (*swap_reloca_out)
494 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
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)
503 enum elf_reloc_type_class {
504 reloc_class_normal,
505 reloc_class_relative,
506 reloc_class_plt,
507 reloc_class_copy
510 struct elf_reloc_cookie
512 Elf_Internal_Rela *rels, *rel, *relend;
513 Elf_Internal_Sym *locsyms;
514 bfd *abfd;
515 size_t locsymcount;
516 size_t extsymoff;
517 struct elf_link_hash_entry **sym_hashes;
518 bfd_boolean bad_symtab;
521 /* The level of IRIX compatibility we're striving for. */
523 typedef enum {
524 ict_none,
525 ict_irix5,
526 ict_irix6
527 } irix_compat_t;
529 struct elf_backend_data
531 /* The architecture for this backend. */
532 enum bfd_architecture arch;
534 /* The ELF machine code (EM_xxxx) for this backend. */
535 int elf_machine_code;
537 /* The maximum page size for this backend. */
538 bfd_vma maxpagesize;
540 /* A function to translate an ELF RELA relocation to a BFD arelent
541 structure. */
542 void (*elf_info_to_howto)
543 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
545 /* A function to translate an ELF REL relocation to a BFD arelent
546 structure. */
547 void (*elf_info_to_howto_rel)
548 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
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. */
555 bfd_boolean (*elf_backend_sym_is_global)
556 PARAMS ((bfd *, asymbol *));
558 /* The remaining functions are hooks which are called only if they
559 are not NULL. */
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
565 used with caution. If this returns FALSE, the check_format
566 routine will return a bfd_error_wrong_format error. */
567 bfd_boolean (*elf_backend_object_p)
568 PARAMS ((bfd *));
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. */
573 void (*elf_backend_symbol_processing)
574 PARAMS ((bfd *, asymbol *));
576 /* A function to do additional symbol processing after reading the
577 entire ELF symbol table. */
578 bfd_boolean (*elf_backend_symbol_table_processing)
579 PARAMS ((bfd *, elf_symbol_type *, unsigned int));
581 /* A function to set the type of the info field. Processor-specific
582 types should be handled here. */
583 int (*elf_backend_get_symbol_type)
584 PARAMS (( Elf_Internal_Sym *, int));
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. */
590 bfd_boolean (*elf_backend_section_processing)
591 PARAMS ((bfd *, Elf_Internal_Shdr *));
593 /* A function to handle unusual section types when creating BFD
594 sections from ELF sections. */
595 bfd_boolean (*elf_backend_section_from_shdr)
596 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
598 /* A function to convert machine dependent section header flags to
599 BFD internal section header flags. */
600 bfd_boolean (*elf_backend_section_flags)
601 PARAMS ((flagword *, Elf_Internal_Shdr *));
603 /* A function to handle unusual program segment types when creating BFD
604 sections from ELF program segments. */
605 bfd_boolean (*elf_backend_section_from_phdr)
606 PARAMS ((bfd *, Elf_Internal_Phdr *, int));
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. */
611 bfd_boolean (*elf_backend_fake_sections)
612 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
614 /* A function to get the ELF section index for a BFD section. If
615 this returns TRUE, the section was found. If it is a normal ELF
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. */
618 bfd_boolean (*elf_backend_section_from_bfd_section)
619 PARAMS ((bfd *, asection *, int *retval));
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. */
629 bfd_boolean (*elf_add_symbol_hook)
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));
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. */
636 bfd_boolean (*elf_backend_link_output_symbol_hook)
637 PARAMS ((bfd *, struct bfd_link_info *info, const char *,
638 Elf_Internal_Sym *, asection *));
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. */
648 bfd_boolean (*elf_backend_create_dynamic_sections)
649 PARAMS ((bfd *abfd, struct bfd_link_info *info));
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. */
661 bfd_boolean (*check_relocs)
662 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
663 const Elf_Internal_Rela *relocs));
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. */
677 bfd_boolean (*elf_backend_adjust_dynamic_symbol)
678 PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
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. */
684 bfd_boolean (*elf_backend_always_size_sections)
685 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
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. */
697 bfd_boolean (*elf_backend_size_dynamic_sections)
698 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
700 /* The RELOCATE_SECTION function is called by the ELF backend linker
701 to handle the relocations for a section.
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.
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.
712 This function does not have to worry about setting the reloc
713 address or the reloc symbol index.
715 LOCAL_SYMS is a pointer to the swapped in local symbols.
717 LOCAL_SECTIONS is an array giving the section in the input file
718 corresponding to the st_shndx field of each local symbol.
720 The global hash table entry for the global symbols can be found
721 via elf_sym_hashes (input_bfd).
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. */
728 bfd_boolean (*elf_backend_relocate_section)
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));
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. */
741 bfd_boolean (*elf_backend_finish_dynamic_symbol)
742 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
743 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
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. */
749 bfd_boolean (*elf_backend_finish_dynamic_sections)
750 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
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 *));
757 /* A function to do any final processing needed for the ELF file
758 before writing it out. The LINKER argument is TRUE if this BFD
759 was created by the ELF backend linker. */
760 void (*elf_backend_final_write_processing)
761 PARAMS ((bfd *, bfd_boolean linker));
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. */
766 int (*elf_backend_additional_program_headers)
767 PARAMS ((bfd *));
769 /* This function is called to modify an existing segment map in a
770 backend specific fashion. */
771 bfd_boolean (*elf_backend_modify_segment_map)
772 PARAMS ((bfd *));
774 /* This function is called during section gc to discover the section a
775 particular relocation refers to. */
776 asection * (*gc_mark_hook)
777 PARAMS ((asection *sec, struct bfd_link_info *, Elf_Internal_Rela *,
778 struct elf_link_hash_entry *h, Elf_Internal_Sym *));
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. */
783 bfd_boolean (*gc_sweep_hook)
784 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
785 const Elf_Internal_Rela *relocs));
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 *));
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 *));
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. */
803 bfd_boolean (*elf_backend_output_arch_syms)
804 PARAMS ((bfd *, struct bfd_link_info *, PTR,
805 bfd_boolean (*) (PTR, const char *, Elf_Internal_Sym *, asection *)));
807 /* Copy any information related to dynamic linking from a pre-existing
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. */
812 void (*elf_backend_copy_indirect_symbol)
813 PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
814 struct elf_link_hash_entry *));
816 /* Modify any information related to dynamic linking such that the
817 symbol is not exported. */
818 void (*elf_backend_hide_symbol)
819 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
821 /* Emit relocations. Overrides default routine for emitting relocs,
822 except during a relocatable link, or if all relocs are being emitted. */
823 bfd_boolean (*elf_backend_emit_relocs)
824 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
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 *));
831 /* This function, if defined, is called when an NT_PRSTATUS note is found
832 in a core file. */
833 bfd_boolean (*elf_backend_grok_prstatus)
834 PARAMS ((bfd *, Elf_Internal_Note *));
836 /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
837 note is found in a core file. */
838 bfd_boolean (*elf_backend_grok_psinfo)
839 PARAMS ((bfd *, Elf_Internal_Note *));
841 /* Functions to print VMAs. Special code to handle 64 bit ELF files. */
842 void (* elf_backend_sprintf_vma)
843 PARAMS ((bfd *, char *, bfd_vma));
844 void (* elf_backend_fprintf_vma)
845 PARAMS ((bfd *, PTR, bfd_vma));
847 /* This function returns class of a reloc type. */
848 enum elf_reloc_type_class (*elf_backend_reloc_type_class)
849 PARAMS ((const Elf_Internal_Rela *));
851 /* This function, if defined, removes information about discarded functions
852 from other sections which mention them. */
853 bfd_boolean (*elf_backend_discard_info)
854 PARAMS ((bfd *, struct elf_reloc_cookie *, struct bfd_link_info *));
856 /* This function, if defined, signals that the function above has removed
857 the discarded relocations for this section. */
858 bfd_boolean (*elf_backend_ignore_discarded_relocs)
859 PARAMS ((asection *));
861 /* This function, if defined, may write out the given section.
862 Returns TRUE if it did so and FALSE if the caller should. */
863 bfd_boolean (*elf_backend_write_section)
864 PARAMS ((bfd *, asection *, bfd_byte *));
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 *));
871 reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
872 PARAMS ((unsigned int, bfd_boolean));
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;
878 /* This function implements `bfd_elf_bfd_from_remote_memory';
879 see elf.c, elfcode.h. */
880 bfd *(*elf_backend_bfd_from_remote_memory)
881 PARAMS ((bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
882 int (*target_read_memory) (bfd_vma vma, char *myaddr, int len)));
884 /* Alternate EM_xxxx machine codes for this backend. */
885 int elf_machine_alt1;
886 int elf_machine_alt2;
888 const struct elf_size_info *s;
890 /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
891 .got section */
892 bfd_vma got_symbol_offset;
894 /* The size in bytes of the headers for the GOT and PLT. This includes
895 the so-called reserved entries on some systems. */
896 bfd_vma got_header_size;
897 bfd_vma plt_header_size;
899 /* This is TRUE if the linker should act like collect and gather
900 global constructors and destructors by name. This is TRUE for
901 MIPS ELF because the Irix 5 tools can not handle the .init
902 section. */
903 unsigned collect : 1;
905 /* This is TRUE if the linker should ignore changes to the type of a
906 symbol. This is TRUE for MIPS ELF because some Irix 5 objects
907 record undefined functions as STT_OBJECT although the definitions
908 are STT_FUNC. */
909 unsigned type_change_ok : 1;
911 /* Whether the backend may use REL relocations. (Some backends use
912 both REL and RELA relocations, and this flag is set for those
913 backends.) */
914 unsigned may_use_rel_p : 1;
916 /* Whether the backend may use RELA relocations. (Some backends use
917 both REL and RELA relocations, and this flag is set for those
918 backends.) */
919 unsigned may_use_rela_p : 1;
921 /* Whether the default relocation type is RELA. If a backend with
922 this flag set wants REL relocations for a particular section,
923 it must note that explicitly. Similarly, if this flag is clear,
924 and the backend wants RELA relocations for a particular
925 section. */
926 unsigned default_use_rela_p : 1;
928 /* Set if RELA relocations for a relocatable link can be handled by
929 generic code. Backends that set this flag need do nothing in the
930 backend relocate_section routine for relocatable linking. */
931 unsigned rela_normal : 1;
933 /* TRUE if addresses "naturally" sign extend. This is used when
934 swapping in from Elf32 when BFD64. */
935 unsigned sign_extend_vma : 1;
937 unsigned want_got_plt : 1;
938 unsigned plt_readonly : 1;
939 unsigned want_plt_sym : 1;
940 unsigned plt_not_loaded : 1;
941 unsigned plt_alignment : 4;
942 unsigned can_gc_sections : 1;
943 unsigned can_refcount : 1;
944 unsigned want_got_sym : 1;
945 unsigned want_dynbss : 1;
946 /* Targets which do not support physical addressing often require
947 that the p_paddr field in the section header to be set to zero.
948 This field indicates whether this behavior is required. */
949 unsigned want_p_paddr_set_to_zero : 1;
952 /* Information stored for each BFD section in an ELF file. This
953 structure is allocated by elf_new_section_hook. */
955 struct bfd_elf_section_data
957 /* The ELF header for this section. */
958 Elf_Internal_Shdr this_hdr;
960 /* The ELF header for the reloc section associated with this
961 section, if any. */
962 Elf_Internal_Shdr rel_hdr;
964 /* If there is a second reloc section associated with this section,
965 as can happen on Irix 6, this field points to the header. */
966 Elf_Internal_Shdr *rel_hdr2;
968 /* The number of relocations currently assigned to REL_HDR. */
969 unsigned int rel_count;
971 /* The number of relocations currently assigned to REL_HDR2. */
972 unsigned int rel_count2;
974 /* The ELF section number of this section. Only used for an output
975 file. */
976 int this_idx;
978 /* The ELF section number of the reloc section indicated by
979 REL_HDR if any. Only used for an output file. */
980 int rel_idx;
982 /* The ELF section number of the reloc section indicated by
983 REL_HDR2 if any. Only used for an output file. */
984 int rel_idx2;
986 /* Used by the backend linker when generating a shared library to
987 record the dynamic symbol index for a section symbol
988 corresponding to this section. A value of 0 means that there is
989 no dynamic symbol for this section. */
990 int dynindx;
992 /* Used by the backend linker to store the symbol hash table entries
993 associated with relocs against global symbols. */
994 struct elf_link_hash_entry **rel_hashes;
996 /* A pointer to the swapped relocs. If the section uses REL relocs,
997 rather than RELA, all the r_addend fields will be zero. This
998 pointer may be NULL. It is used by the backend linker. */
999 Elf_Internal_Rela *relocs;
1001 /* A pointer to a linked list tracking dynamic relocs copied for
1002 local symbols. */
1003 PTR local_dynrel;
1005 /* A pointer to the bfd section used for dynamic relocs. */
1006 asection *sreloc;
1008 union {
1009 /* Group name, if this section is a member of a group. */
1010 const char *name;
1012 /* Group signature sym, if this is the SHT_GROUP section. */
1013 struct symbol_cache_entry *id;
1014 } group;
1016 /* A linked list of sections in the group. Circular when used by
1017 the linker. */
1018 asection *next_in_group;
1020 /* A pointer used for various section optimizations. */
1021 PTR sec_info;
1024 #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
1025 #define elf_group_name(sec) (elf_section_data(sec)->group.name)
1026 #define elf_group_id(sec) (elf_section_data(sec)->group.id)
1027 #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
1029 /* Return TRUE if section has been discarded. */
1030 #define elf_discarded_section(sec) \
1031 (!bfd_is_abs_section (sec) \
1032 && bfd_is_abs_section ((sec)->output_section) \
1033 && sec->sec_info_type != ELF_INFO_TYPE_MERGE \
1034 && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
1036 #define get_elf_backend_data(abfd) \
1037 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
1039 /* Enumeration to specify the special section. */
1040 typedef enum elf_linker_section_enum
1042 LINKER_SECTION_UNKNOWN, /* not used */
1043 LINKER_SECTION_GOT, /* .got section for global offset pointers */
1044 LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
1045 LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
1046 LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
1047 LINKER_SECTION_MAX /* # of linker sections */
1048 } elf_linker_section_enum_t;
1050 /* Sections created by the linker. */
1052 typedef struct elf_linker_section
1054 char *name; /* name of the section */
1055 char *rel_name; /* name of the associated .rel{,a}. section */
1056 char *bss_name; /* name of a related .bss section */
1057 char *sym_name; /* name of symbol to reference this section */
1058 asection *section; /* pointer to the section */
1059 asection *bss_section; /* pointer to the bss section associated with this */
1060 asection *rel_section; /* pointer to the relocations needed for this section */
1061 struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
1062 bfd_vma initial_size; /* initial size before any linker generated allocations */
1063 bfd_vma sym_offset; /* offset of symbol from beginning of section */
1064 bfd_vma hole_size; /* size of reserved address hole in allocation */
1065 bfd_vma hole_offset; /* current offset for the hole */
1066 bfd_vma max_hole_offset; /* maximum offset for the hole */
1067 elf_linker_section_enum_t which; /* which section this is */
1068 bfd_boolean hole_written_p; /* whether the hole has been initialized */
1069 unsigned int alignment; /* alignment for the section */
1070 flagword flags; /* flags to use to create the section */
1071 } elf_linker_section_t;
1073 /* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
1074 provides allows us to return different pointers, based on different addend's. */
1076 typedef struct elf_linker_section_pointers
1078 struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
1079 bfd_vma offset; /* offset of pointer from beginning of section */
1080 bfd_vma addend; /* addend used */
1081 elf_linker_section_enum_t which; /* which linker section this is */
1082 bfd_boolean written_address_p; /* whether address was written yet */
1083 } elf_linker_section_pointers_t;
1085 /* This struct is used to pass information to routines called via
1086 elf_link_hash_traverse which must return failure. */
1088 struct elf_info_failed
1090 bfd_boolean failed;
1091 struct bfd_link_info *info;
1092 struct bfd_elf_version_tree *verdefs;
1095 /* This structure is used to pass information to
1096 _bfd_elf_link_assign_sym_version. */
1098 struct elf_assign_sym_version_info
1100 /* Output BFD. */
1101 bfd *output_bfd;
1102 /* General link information. */
1103 struct bfd_link_info *info;
1104 /* Version tree. */
1105 struct bfd_elf_version_tree *verdefs;
1106 /* Whether we had a failure. */
1107 bfd_boolean failed;
1110 /* This structure is used to pass information to
1111 _bfd_elf_link_find_version_dependencies. */
1113 struct elf_find_verdep_info
1115 /* Output BFD. */
1116 bfd *output_bfd;
1117 /* General link information. */
1118 struct bfd_link_info *info;
1119 /* The number of dependencies. */
1120 unsigned int vers;
1121 /* Whether we had a failure. */
1122 bfd_boolean failed;
1125 /* Some private data is stashed away for future use using the tdata pointer
1126 in the bfd structure. */
1128 struct elf_obj_tdata
1130 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
1131 Elf_Internal_Shdr **elf_sect_ptr;
1132 Elf_Internal_Phdr *phdr;
1133 struct elf_segment_map *segment_map;
1134 struct elf_strtab_hash *strtab_ptr;
1135 int num_locals;
1136 int num_globals;
1137 unsigned int num_elf_sections; /* elf_sect_ptr size */
1138 int num_section_syms;
1139 asymbol **section_syms; /* STT_SECTION symbols for each section */
1140 Elf_Internal_Shdr symtab_hdr;
1141 Elf_Internal_Shdr shstrtab_hdr;
1142 Elf_Internal_Shdr strtab_hdr;
1143 Elf_Internal_Shdr dynsymtab_hdr;
1144 Elf_Internal_Shdr dynstrtab_hdr;
1145 Elf_Internal_Shdr dynversym_hdr;
1146 Elf_Internal_Shdr dynverref_hdr;
1147 Elf_Internal_Shdr dynverdef_hdr;
1148 Elf_Internal_Shdr symtab_shndx_hdr;
1149 unsigned int symtab_section, shstrtab_section;
1150 unsigned int strtab_section, dynsymtab_section;
1151 unsigned int symtab_shndx_section;
1152 unsigned int dynversym_section, dynverdef_section, dynverref_section;
1153 file_ptr next_file_pos;
1154 #if 0
1155 /* we don't need these inside bfd anymore, and I think
1156 these weren't used outside bfd. */
1157 void *prstatus; /* The raw /proc prstatus structure */
1158 void *prpsinfo; /* The raw /proc prpsinfo structure */
1159 #endif
1160 bfd_vma gp; /* The gp value */
1161 unsigned int gp_size; /* The gp size */
1163 Elf_Internal_Shdr **group_sect_ptr;
1164 int num_group;
1166 /* Information grabbed from an elf core file. */
1167 int core_signal;
1168 int core_pid;
1169 int core_lwpid;
1170 char* core_program;
1171 char* core_command;
1173 /* This is set to TRUE if the object was created by the backend
1174 linker. */
1175 bfd_boolean linker;
1177 /* A mapping from external symbols to entries in the linker hash
1178 table, used when linking. This is indexed by the symbol index
1179 minus the sh_info field of the symbol table header. */
1180 struct elf_link_hash_entry **sym_hashes;
1182 /* Track usage and final offsets of GOT entries for local symbols.
1183 This array is indexed by symbol index. Elements are used
1184 identically to "got" in struct elf_link_hash_entry. */
1185 union
1187 bfd_signed_vma *refcounts;
1188 bfd_vma *offsets;
1189 struct got_entry **ents;
1190 } local_got;
1192 /* A mapping from local symbols to offsets into the various linker
1193 sections added. This is index by the symbol index. */
1194 elf_linker_section_pointers_t **linker_section_pointers;
1196 /* The linker ELF emulation code needs to let the backend ELF linker
1197 know what filename should be used for a dynamic object if the
1198 dynamic object is found using a search. The emulation code then
1199 sometimes needs to know what name was actually used. Until the
1200 file has been added to the linker symbol table, this field holds
1201 the name the linker wants. After it has been added, it holds the
1202 name actually used, which will be the DT_SONAME entry if there is
1203 one. */
1204 const char *dt_name;
1206 /* When a reference in a regular object is resolved by a shared
1207 object is loaded into via the DT_NEEDED entries by the linker
1208 ELF emulation code, we need to add the shared object to the
1209 DT_NEEDED list of the resulting binary to indicate the dependency
1210 as if the -l option is passed to the linker. This field holds the
1211 name of the loaded shared object. */
1212 const char *dt_soname;
1214 /* Irix 5 often screws up the symbol table, sorting local symbols
1215 after global symbols. This flag is set if the symbol table in
1216 this BFD appears to be screwed up. If it is, we ignore the
1217 sh_info field in the symbol table header, and always read all the
1218 symbols. */
1219 bfd_boolean bad_symtab;
1221 /* Records the result of `get_program_header_size'. */
1222 bfd_size_type program_header_size;
1224 /* Used by find_nearest_line entry point. */
1225 PTR line_info;
1227 /* Used by MIPS ELF find_nearest_line entry point. The structure
1228 could be included directly in this one, but there's no point to
1229 wasting the memory just for the infrequently called
1230 find_nearest_line. */
1231 struct mips_elf_find_line *find_line_info;
1233 /* A place to stash dwarf1 info for this bfd. */
1234 struct dwarf1_debug *dwarf1_find_line_info;
1236 /* A place to stash dwarf2 info for this bfd. */
1237 PTR dwarf2_find_line_info;
1239 /* An array of stub sections indexed by symbol number, used by the
1240 MIPS ELF linker. FIXME: We should figure out some way to only
1241 include this field for a MIPS ELF target. */
1242 asection **local_stubs;
1244 /* Used to determine if PT_GNU_EH_FRAME segment header should be
1245 created. */
1246 asection *eh_frame_hdr;
1248 /* Used to determine if the e_flags field has been initialized */
1249 bfd_boolean flags_init;
1251 /* Number of symbol version definitions we are about to emit. */
1252 unsigned int cverdefs;
1254 /* Number of symbol version references we are about to emit. */
1255 unsigned int cverrefs;
1257 /* Symbol version definitions in external objects. */
1258 Elf_Internal_Verdef *verdef;
1260 /* Symbol version references to external objects. */
1261 Elf_Internal_Verneed *verref;
1263 /* Linker sections that we are interested in. */
1264 struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
1266 /* The Irix 5 support uses two virtual sections, which represent
1267 text/data symbols defined in dynamic objects. */
1268 asymbol *elf_data_symbol;
1269 asymbol *elf_text_symbol;
1270 asection *elf_data_section;
1271 asection *elf_text_section;
1274 #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
1275 #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
1276 #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
1277 #define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections)
1278 #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
1279 #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
1280 #define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section)
1281 #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
1282 #define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
1283 #define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
1284 #define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
1285 #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
1286 #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
1287 #define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
1288 #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
1289 #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
1290 #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
1291 #define elf_gp(bfd) (elf_tdata(bfd) -> gp)
1292 #define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
1293 #define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
1294 #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
1295 #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
1296 #define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
1297 #define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
1298 #define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
1299 #define elf_dt_soname(bfd) (elf_tdata(bfd) -> dt_soname)
1300 #define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
1301 #define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
1302 #define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
1304 extern void _bfd_elf_swap_verdef_in
1305 PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
1306 extern void _bfd_elf_swap_verdef_out
1307 PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
1308 extern void _bfd_elf_swap_verdaux_in
1309 PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
1310 extern void _bfd_elf_swap_verdaux_out
1311 PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
1312 extern void _bfd_elf_swap_verneed_in
1313 PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
1314 extern void _bfd_elf_swap_verneed_out
1315 PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
1316 extern void _bfd_elf_swap_vernaux_in
1317 PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
1318 extern void _bfd_elf_swap_vernaux_out
1319 PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
1320 extern void _bfd_elf_swap_versym_in
1321 PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
1322 extern void _bfd_elf_swap_versym_out
1323 PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
1325 extern int _bfd_elf_section_from_bfd_section
1326 PARAMS ((bfd *, asection *));
1327 extern char *bfd_elf_string_from_elf_section
1328 PARAMS ((bfd *, unsigned, unsigned));
1329 extern char *bfd_elf_get_str_section
1330 PARAMS ((bfd *, unsigned));
1331 extern Elf_Internal_Sym *bfd_elf_get_elf_syms
1332 PARAMS ((bfd *, Elf_Internal_Shdr *, size_t, size_t,
1333 Elf_Internal_Sym *, PTR, Elf_External_Sym_Shndx *));
1334 extern const char *bfd_elf_local_sym_name
1335 PARAMS ((bfd *, Elf_Internal_Sym *));
1337 extern bfd_boolean _bfd_elf_copy_private_bfd_data
1338 PARAMS ((bfd *, bfd *));
1339 extern bfd_boolean _bfd_elf_print_private_bfd_data
1340 PARAMS ((bfd *, PTR));
1341 extern void bfd_elf_print_symbol
1342 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
1344 #define elf_string_from_elf_strtab(abfd, strindex) \
1345 bfd_elf_string_from_elf_section(abfd, elf_elfheader(abfd)->e_shstrndx, \
1346 strindex)
1348 #define bfd_elf32_print_symbol bfd_elf_print_symbol
1349 #define bfd_elf64_print_symbol bfd_elf_print_symbol
1351 extern void _bfd_elf_sprintf_vma
1352 PARAMS ((bfd *, char *, bfd_vma));
1353 extern void _bfd_elf_fprintf_vma
1354 PARAMS ((bfd *, PTR, bfd_vma));
1356 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
1357 PARAMS ((const Elf_Internal_Rela *));
1358 extern bfd_vma _bfd_elf_rela_local_sym
1359 PARAMS ((bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *));
1360 extern bfd_vma _bfd_elf_rel_local_sym
1361 PARAMS ((bfd *, Elf_Internal_Sym *, asection **, bfd_vma));
1362 extern bfd_vma _bfd_elf_section_offset
1363 PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_vma));
1365 extern unsigned long bfd_elf_hash
1366 PARAMS ((const char *));
1368 extern bfd_reloc_status_type bfd_elf_generic_reloc
1369 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1370 extern bfd_boolean bfd_elf_mkobject
1371 PARAMS ((bfd *));
1372 extern bfd_boolean bfd_elf_mkcorefile
1373 PARAMS ((bfd *));
1374 extern Elf_Internal_Shdr *bfd_elf_find_section
1375 PARAMS ((bfd *, char *));
1376 extern bfd_boolean _bfd_elf_make_section_from_shdr
1377 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
1378 extern bfd_boolean _bfd_elf_make_section_from_phdr
1379 PARAMS ((bfd *, Elf_Internal_Phdr *, int, const char *));
1380 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
1381 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
1382 extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
1383 PARAMS ((bfd *));
1384 extern void _bfd_elf_link_hash_copy_indirect
1385 PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
1386 struct elf_link_hash_entry *));
1387 extern void _bfd_elf_link_hash_hide_symbol
1388 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
1389 extern bfd_boolean _bfd_elf_link_hash_table_init
1390 PARAMS ((struct elf_link_hash_table *, bfd *,
1391 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
1392 struct bfd_hash_table *,
1393 const char *)));
1394 extern bfd_boolean _bfd_elf_slurp_version_tables
1395 PARAMS ((bfd *));
1396 extern bfd_boolean _bfd_elf_merge_sections
1397 PARAMS ((bfd *, struct bfd_link_info *));
1398 extern bfd_boolean bfd_elf_discard_group
1399 PARAMS ((bfd *, struct sec *));
1400 extern void bfd_elf_set_group_contents
1401 PARAMS ((bfd *, asection *, PTR));
1402 extern void _bfd_elf_link_just_syms
1403 PARAMS ((asection *, struct bfd_link_info *));
1404 extern bfd_boolean _bfd_elf_copy_private_symbol_data
1405 PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
1406 extern bfd_boolean _bfd_elf_copy_private_section_data
1407 PARAMS ((bfd *, asection *, bfd *, asection *));
1408 extern bfd_boolean _bfd_elf_write_object_contents
1409 PARAMS ((bfd *));
1410 extern bfd_boolean _bfd_elf_write_corefile_contents
1411 PARAMS ((bfd *));
1412 extern bfd_boolean _bfd_elf_set_section_contents
1413 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
1414 extern long _bfd_elf_get_symtab_upper_bound
1415 PARAMS ((bfd *));
1416 extern long _bfd_elf_get_symtab
1417 PARAMS ((bfd *, asymbol **));
1418 extern long _bfd_elf_get_dynamic_symtab_upper_bound
1419 PARAMS ((bfd *));
1420 extern long _bfd_elf_canonicalize_dynamic_symtab
1421 PARAMS ((bfd *, asymbol **));
1422 extern long _bfd_elf_get_reloc_upper_bound
1423 PARAMS ((bfd *, sec_ptr));
1424 extern long _bfd_elf_canonicalize_reloc
1425 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
1426 extern long _bfd_elf_get_dynamic_reloc_upper_bound
1427 PARAMS ((bfd *));
1428 extern long _bfd_elf_canonicalize_dynamic_reloc
1429 PARAMS ((bfd *, arelent **, asymbol **));
1430 extern asymbol *_bfd_elf_make_empty_symbol
1431 PARAMS ((bfd *));
1432 extern void _bfd_elf_get_symbol_info
1433 PARAMS ((bfd *, asymbol *, symbol_info *));
1434 extern bfd_boolean _bfd_elf_is_local_label_name
1435 PARAMS ((bfd *, const char *));
1436 extern alent *_bfd_elf_get_lineno
1437 PARAMS ((bfd *, asymbol *));
1438 extern bfd_boolean _bfd_elf_set_arch_mach
1439 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
1440 extern bfd_boolean _bfd_elf_find_nearest_line
1441 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
1442 const char **, unsigned int *));
1443 #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
1444 #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
1445 extern int _bfd_elf_sizeof_headers
1446 PARAMS ((bfd *, bfd_boolean));
1447 extern bfd_boolean _bfd_elf_new_section_hook
1448 PARAMS ((bfd *, asection *));
1449 extern bfd_boolean _bfd_elf_init_reloc_shdr
1450 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean));
1452 /* If the target doesn't have reloc handling written yet: */
1453 extern void _bfd_elf_no_info_to_howto
1454 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
1456 extern bfd_boolean bfd_section_from_shdr
1457 PARAMS ((bfd *, unsigned int shindex));
1458 extern bfd_boolean bfd_section_from_phdr
1459 PARAMS ((bfd *, Elf_Internal_Phdr *, int));
1461 extern int _bfd_elf_symbol_from_bfd_symbol
1462 PARAMS ((bfd *, asymbol **));
1464 extern asection *bfd_section_from_r_symndx
1465 PARAMS ((bfd *, struct sym_sec_cache *, asection *, unsigned long));
1466 extern asection *bfd_section_from_elf_index
1467 PARAMS ((bfd *, unsigned int));
1468 extern struct bfd_strtab_hash *_bfd_elf_stringtab_init
1469 PARAMS ((void));
1471 extern struct elf_strtab_hash * _bfd_elf_strtab_init
1472 PARAMS ((void));
1473 extern void _bfd_elf_strtab_free
1474 PARAMS ((struct elf_strtab_hash *));
1475 extern bfd_size_type _bfd_elf_strtab_add
1476 PARAMS ((struct elf_strtab_hash *, const char *, bfd_boolean));
1477 extern void _bfd_elf_strtab_addref
1478 PARAMS ((struct elf_strtab_hash *, bfd_size_type));
1479 extern void _bfd_elf_strtab_delref
1480 PARAMS ((struct elf_strtab_hash *, bfd_size_type));
1481 extern void _bfd_elf_strtab_clear_all_refs
1482 PARAMS ((struct elf_strtab_hash *));
1483 extern bfd_size_type _bfd_elf_strtab_size
1484 PARAMS ((struct elf_strtab_hash *));
1485 extern bfd_size_type _bfd_elf_strtab_offset
1486 PARAMS ((struct elf_strtab_hash *, bfd_size_type));
1487 extern bfd_boolean _bfd_elf_strtab_emit
1488 PARAMS ((bfd *, struct elf_strtab_hash *));
1489 extern void _bfd_elf_strtab_finalize
1490 PARAMS ((struct elf_strtab_hash *));
1492 extern bfd_boolean _bfd_elf_discard_section_eh_frame
1493 PARAMS ((bfd *, struct bfd_link_info *, asection *,
1494 bfd_boolean (*) (bfd_vma, PTR), struct elf_reloc_cookie *));
1495 extern bfd_boolean _bfd_elf_discard_section_eh_frame_hdr
1496 PARAMS ((bfd *, struct bfd_link_info *));
1497 extern bfd_vma _bfd_elf_eh_frame_section_offset
1498 PARAMS ((bfd *, asection *, bfd_vma));
1499 extern bfd_boolean _bfd_elf_write_section_eh_frame
1500 PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_byte *));
1501 extern bfd_boolean _bfd_elf_write_section_eh_frame_hdr
1502 PARAMS ((bfd *, struct bfd_link_info *));
1503 extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
1504 PARAMS ((struct bfd_link_info *));
1506 extern bfd_boolean _bfd_elf_merge_symbol
1507 PARAMS ((bfd *, struct bfd_link_info *, const char *,
1508 Elf_Internal_Sym *, asection **, bfd_vma *,
1509 struct elf_link_hash_entry **, bfd_boolean *, bfd_boolean *,
1510 bfd_boolean *, bfd_boolean *, bfd_boolean));
1512 extern bfd_boolean _bfd_elf_add_default_symbol
1513 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
1514 const char *, Elf_Internal_Sym *, asection **, bfd_vma *,
1515 bfd_boolean *, bfd_boolean, bfd_boolean));
1517 extern bfd_boolean _bfd_elf_export_symbol
1518 PARAMS ((struct elf_link_hash_entry *, PTR));
1520 extern bfd_boolean _bfd_elf_link_find_version_dependencies
1521 PARAMS ((struct elf_link_hash_entry *, PTR));
1523 extern bfd_boolean _bfd_elf_link_assign_sym_version
1524 PARAMS ((struct elf_link_hash_entry *, PTR));
1526 extern bfd_boolean _bfd_elf_link_record_dynamic_symbol
1527 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
1528 extern long _bfd_elf_link_lookup_local_dynindx
1529 PARAMS ((struct bfd_link_info *, bfd *, long));
1530 extern bfd_boolean _bfd_elf_compute_section_file_positions
1531 PARAMS ((bfd *, struct bfd_link_info *));
1532 extern void _bfd_elf_assign_file_positions_for_relocs
1533 PARAMS ((bfd *));
1534 extern file_ptr _bfd_elf_assign_file_position_for_section
1535 PARAMS ((Elf_Internal_Shdr *, file_ptr, bfd_boolean));
1537 extern bfd_boolean _bfd_elf_validate_reloc
1538 PARAMS ((bfd *, arelent *));
1540 extern bfd_boolean _bfd_elf_link_create_dynamic_sections
1541 PARAMS ((bfd *, struct bfd_link_info *));
1542 extern bfd_boolean _bfd_elf_create_dynamic_sections
1543 PARAMS ((bfd *, struct bfd_link_info *));
1544 extern bfd_boolean _bfd_elf_create_got_section
1545 PARAMS ((bfd *, struct bfd_link_info *));
1546 extern unsigned long _bfd_elf_link_renumber_dynsyms
1547 PARAMS ((bfd *, struct bfd_link_info *));
1549 extern bfd_boolean _bfd_elfcore_make_pseudosection
1550 PARAMS ((bfd *, char *, size_t, ufile_ptr));
1551 extern char *_bfd_elfcore_strndup
1552 PARAMS ((bfd *, char *, size_t));
1554 extern elf_linker_section_t *_bfd_elf_create_linker_section
1555 PARAMS ((bfd *, struct bfd_link_info *, enum elf_linker_section_enum,
1556 elf_linker_section_t *));
1558 extern elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
1559 PARAMS ((elf_linker_section_pointers_t *, bfd_vma,
1560 elf_linker_section_enum_t));
1562 extern bfd_boolean bfd_elf32_create_pointer_linker_section
1563 PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
1564 struct elf_link_hash_entry *, const Elf_Internal_Rela *));
1566 extern bfd_vma bfd_elf32_finish_pointer_linker_section
1567 PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
1568 struct elf_link_hash_entry *, bfd_vma,
1569 const Elf_Internal_Rela *, int));
1571 extern bfd_boolean bfd_elf64_create_pointer_linker_section
1572 PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
1573 struct elf_link_hash_entry *, const Elf_Internal_Rela *));
1575 extern bfd_vma bfd_elf64_finish_pointer_linker_section
1576 PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
1577 struct elf_link_hash_entry *, bfd_vma,
1578 const Elf_Internal_Rela *, int));
1580 extern bfd_boolean _bfd_elf_make_linker_section_rela
1581 PARAMS ((bfd *, elf_linker_section_t *, int));
1583 extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
1584 PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, bfd_boolean));
1586 extern bfd_boolean _bfd_elf_link_size_reloc_section
1587 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
1589 extern bfd_boolean _bfd_elf_link_output_relocs
1590 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
1592 extern bfd_boolean _bfd_elf_fix_symbol_flags
1593 PARAMS ((struct elf_link_hash_entry *, struct elf_info_failed *));
1595 extern bfd_boolean _bfd_elf_adjust_dynamic_symbol
1596 PARAMS ((struct elf_link_hash_entry *, PTR));
1598 extern bfd_boolean _bfd_elf_link_sec_merge_syms
1599 PARAMS ((struct elf_link_hash_entry *, PTR));
1601 extern const bfd_target *bfd_elf32_object_p
1602 PARAMS ((bfd *));
1603 extern const bfd_target *bfd_elf32_core_file_p
1604 PARAMS ((bfd *));
1605 extern char *bfd_elf32_core_file_failing_command
1606 PARAMS ((bfd *));
1607 extern int bfd_elf32_core_file_failing_signal
1608 PARAMS ((bfd *));
1609 extern bfd_boolean bfd_elf32_core_file_matches_executable_p
1610 PARAMS ((bfd *, bfd *));
1612 extern bfd_boolean bfd_elf32_bfd_link_add_symbols
1613 PARAMS ((bfd *, struct bfd_link_info *));
1614 extern bfd_boolean bfd_elf32_bfd_final_link
1615 PARAMS ((bfd *, struct bfd_link_info *));
1617 extern void bfd_elf32_swap_symbol_in
1618 PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *));
1619 extern void bfd_elf32_swap_symbol_out
1620 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
1621 extern void bfd_elf32_swap_reloc_in
1622 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
1623 extern void bfd_elf32_swap_reloc_out
1624 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
1625 extern void bfd_elf32_swap_reloca_in
1626 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
1627 extern void bfd_elf32_swap_reloca_out
1628 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
1629 extern void bfd_elf32_swap_phdr_in
1630 PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
1631 extern void bfd_elf32_swap_phdr_out
1632 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
1633 extern void bfd_elf32_swap_dyn_in
1634 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1635 extern void bfd_elf32_swap_dyn_out
1636 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
1637 extern long bfd_elf32_slurp_symbol_table
1638 PARAMS ((bfd *, asymbol **, bfd_boolean));
1639 extern bfd_boolean bfd_elf32_write_shdrs_and_ehdr
1640 PARAMS ((bfd *));
1641 extern int bfd_elf32_write_out_phdrs
1642 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
1643 extern void bfd_elf32_write_relocs
1644 PARAMS ((bfd *, asection *, PTR));
1645 extern bfd_boolean bfd_elf32_slurp_reloc_table
1646 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
1647 extern bfd_boolean bfd_elf32_add_dynamic_entry
1648 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
1650 extern const bfd_target *bfd_elf64_object_p
1651 PARAMS ((bfd *));
1652 extern const bfd_target *bfd_elf64_core_file_p
1653 PARAMS ((bfd *));
1654 extern char *bfd_elf64_core_file_failing_command
1655 PARAMS ((bfd *));
1656 extern int bfd_elf64_core_file_failing_signal
1657 PARAMS ((bfd *));
1658 extern bfd_boolean bfd_elf64_core_file_matches_executable_p
1659 PARAMS ((bfd *, bfd *));
1660 extern bfd_boolean bfd_elf64_bfd_link_add_symbols
1661 PARAMS ((bfd *, struct bfd_link_info *));
1662 extern bfd_boolean bfd_elf64_bfd_final_link
1663 PARAMS ((bfd *, struct bfd_link_info *));
1665 extern void bfd_elf64_swap_symbol_in
1666 PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *));
1667 extern void bfd_elf64_swap_symbol_out
1668 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
1669 extern void bfd_elf64_swap_reloc_in
1670 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
1671 extern void bfd_elf64_swap_reloc_out
1672 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
1673 extern void bfd_elf64_swap_reloca_in
1674 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
1675 extern void bfd_elf64_swap_reloca_out
1676 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
1677 extern void bfd_elf64_swap_phdr_in
1678 PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
1679 extern void bfd_elf64_swap_phdr_out
1680 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
1681 extern void bfd_elf64_swap_dyn_in
1682 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1683 extern void bfd_elf64_swap_dyn_out
1684 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
1685 extern long bfd_elf64_slurp_symbol_table
1686 PARAMS ((bfd *, asymbol **, bfd_boolean));
1687 extern bfd_boolean bfd_elf64_write_shdrs_and_ehdr
1688 PARAMS ((bfd *));
1689 extern int bfd_elf64_write_out_phdrs
1690 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
1691 extern void bfd_elf64_write_relocs
1692 PARAMS ((bfd *, asection *, PTR));
1693 extern bfd_boolean bfd_elf64_slurp_reloc_table
1694 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
1695 extern bfd_boolean bfd_elf64_add_dynamic_entry
1696 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
1698 #define bfd_elf32_link_record_dynamic_symbol \
1699 _bfd_elf_link_record_dynamic_symbol
1700 #define bfd_elf64_link_record_dynamic_symbol \
1701 _bfd_elf_link_record_dynamic_symbol
1703 extern int elf_link_record_local_dynamic_symbol
1704 PARAMS ((struct bfd_link_info *, bfd *, long));
1705 #define _bfd_elf32_link_record_local_dynamic_symbol \
1706 elf_link_record_local_dynamic_symbol
1707 #define _bfd_elf64_link_record_local_dynamic_symbol \
1708 elf_link_record_local_dynamic_symbol
1710 extern bfd_boolean _bfd_elf_close_and_cleanup
1711 PARAMS ((bfd *));
1712 extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
1713 PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
1714 asection *, bfd *, char **));
1716 extern bfd_boolean _bfd_elf32_gc_sections
1717 PARAMS ((bfd *, struct bfd_link_info *));
1718 extern bfd_boolean _bfd_elf32_gc_common_finalize_got_offsets
1719 PARAMS ((bfd *, struct bfd_link_info *));
1720 extern bfd_boolean _bfd_elf32_gc_common_final_link
1721 PARAMS ((bfd *, struct bfd_link_info *));
1722 extern bfd_boolean _bfd_elf32_gc_record_vtinherit
1723 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1724 extern bfd_boolean _bfd_elf32_gc_record_vtentry
1725 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1727 extern bfd_boolean _bfd_elf64_gc_sections
1728 PARAMS ((bfd *, struct bfd_link_info *));
1729 extern bfd_boolean _bfd_elf64_gc_common_finalize_got_offsets
1730 PARAMS ((bfd *, struct bfd_link_info *));
1731 extern bfd_boolean _bfd_elf64_gc_common_final_link
1732 PARAMS ((bfd *, struct bfd_link_info *));
1733 extern bfd_boolean _bfd_elf64_gc_record_vtinherit
1734 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1735 extern bfd_boolean _bfd_elf64_gc_record_vtentry
1736 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1738 extern bfd_boolean _bfd_elf32_reloc_symbol_deleted_p
1739 PARAMS ((bfd_vma, PTR));
1740 extern bfd_boolean _bfd_elf64_reloc_symbol_deleted_p
1741 PARAMS ((bfd_vma, PTR));
1743 /* Exported interface for writing elf corefile notes. */
1744 extern char *elfcore_write_note
1745 PARAMS ((bfd *, char *, int *, const char *, int, const PTR, int));
1746 extern char *elfcore_write_prpsinfo
1747 PARAMS ((bfd *, char *, int *, const char *, const char *));
1748 extern char *elfcore_write_prstatus
1749 PARAMS ((bfd *, char *, int *, long, int, const PTR));
1750 extern char * elfcore_write_pstatus
1751 PARAMS ((bfd *, char *, int *, long, int, const PTR));
1752 extern char *elfcore_write_prfpreg
1753 PARAMS ((bfd *, char *, int *, const PTR, int));
1754 extern char *elfcore_write_prxfpreg
1755 PARAMS ((bfd *, char *, int *, const PTR, int));
1756 extern char *elfcore_write_lwpstatus
1757 PARAMS ((bfd *, char *, int *, long, int, const PTR));
1759 extern bfd *_bfd_elf32_bfd_from_remote_memory
1760 PARAMS ((bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
1761 int (*target_read_memory) (bfd_vma, char *, int)));
1762 extern bfd *_bfd_elf64_bfd_from_remote_memory
1763 PARAMS ((bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
1764 int (*target_read_memory) (bfd_vma, char *, int)));
1766 /* SH ELF specific routine. */
1768 extern bfd_boolean _sh_elf_set_mach_from_flags
1769 PARAMS ((bfd *));
1771 #endif /* _LIBELF_H_ */