elf-bfd.h revision 77298
133965Sjdp/* BFD back-end data structures for ELF files.
260484Sobrien   Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000 Free Software
360484Sobrien   Foundation, Inc.
433965Sjdp   Written by Cygnus Support.
533965Sjdp
633965SjdpThis file is part of BFD, the Binary File Descriptor library.
733965Sjdp
833965SjdpThis program is free software; you can redistribute it and/or modify
933965Sjdpit under the terms of the GNU General Public License as published by
1033965Sjdpthe Free Software Foundation; either version 2 of the License, or
1133965Sjdp(at your option) any later version.
1233965Sjdp
1333965SjdpThis program is distributed in the hope that it will be useful,
1433965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of
1533965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1633965SjdpGNU General Public License for more details.
1733965Sjdp
1833965SjdpYou should have received a copy of the GNU General Public License
1933965Sjdpalong with this program; if not, write to the Free Software
2033965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2133965Sjdp
2233965Sjdp#ifndef _LIBELF_H_
2333965Sjdp#define _LIBELF_H_ 1
2433965Sjdp
2533965Sjdp#include "elf/common.h"
2633965Sjdp#include "elf/internal.h"
2733965Sjdp#include "elf/external.h"
2833965Sjdp#include "bfdlink.h"
2933965Sjdp
3033965Sjdp/* If size isn't specified as 64 or 32, NAME macro should fail.  */
3133965Sjdp#ifndef NAME
3233965Sjdp#if ARCH_SIZE==64
3333965Sjdp#define NAME(x,y) CAT4(x,64,_,y)
3433965Sjdp#endif
3533965Sjdp#if ARCH_SIZE==32
3633965Sjdp#define NAME(x,y) CAT4(x,32,_,y)
3733965Sjdp#endif
3833965Sjdp#endif
3933965Sjdp
4033965Sjdp#ifndef NAME
4133965Sjdp#define NAME(x,y) CAT4(x,NOSIZE,_,y)
4233965Sjdp#endif
4333965Sjdp
4433965Sjdp#define ElfNAME(X)	NAME(Elf,X)
4533965Sjdp#define elfNAME(X)	NAME(elf,X)
4633965Sjdp
4733965Sjdp/* Information held for an ELF symbol.  The first field is the
4833965Sjdp   corresponding asymbol.  Every symbol is an ELF file is actually a
4933965Sjdp   pointer to this structure, although it is often handled as a
5033965Sjdp   pointer to an asymbol.  */
5133965Sjdp
5233965Sjdptypedef struct
5333965Sjdp{
5433965Sjdp  /* The BFD symbol.  */
5533965Sjdp  asymbol symbol;
5633965Sjdp  /* ELF symbol information.  */
5733965Sjdp  Elf_Internal_Sym internal_elf_sym;
5833965Sjdp  /* Backend specific information.  */
5933965Sjdp  union
6033965Sjdp    {
6133965Sjdp      unsigned int hppa_arg_reloc;
6233965Sjdp      PTR mips_extr;
6333965Sjdp      PTR any;
6433965Sjdp    }
6533965Sjdp  tc_data;
6633965Sjdp
6733965Sjdp  /* Version information.  This is from an Elf_Internal_Versym
6833965Sjdp     structure in a SHT_GNU_versym section.  It is zero if there is no
6933965Sjdp     version information.  */
7033965Sjdp  unsigned short version;
7133965Sjdp
7233965Sjdp} elf_symbol_type;
7333965Sjdp
7433965Sjdp/* ELF linker hash table entries.  */
7533965Sjdp
7633965Sjdpstruct elf_link_hash_entry
7733965Sjdp{
7833965Sjdp  struct bfd_link_hash_entry root;
7933965Sjdp
8033965Sjdp  /* Symbol index in output file.  This is initialized to -1.  It is
8133965Sjdp     set to -2 if the symbol is used by a reloc.  */
8233965Sjdp  long indx;
8333965Sjdp
8433965Sjdp  /* Symbol size.  */
8533965Sjdp  bfd_size_type size;
8633965Sjdp
8733965Sjdp  /* Symbol index as a dynamic symbol.  Initialized to -1, and remains
8833965Sjdp     -1 if this is not a dynamic symbol.  */
8960484Sobrien  /* ??? Note that this is consistently used as a synonym for tests
9060484Sobrien     against whether we can perform various simplifying transformations
9160484Sobrien     to the code.  (E.g. changing a pc-relative jump to a PLT entry
9260484Sobrien     into a pc-relative jump to the target function.)  That test, which
9360484Sobrien     is often relatively complex, and someplaces wrong or incomplete,
9460484Sobrien     should really be replaced by a predicate in elflink.c.
9560484Sobrien
9660484Sobrien     End result: this field -1 does not indicate that the symbol is
9760484Sobrien     not in the dynamic symbol table, but rather that the symbol is
9860484Sobrien     not visible outside this DSO.  */
9933965Sjdp  long dynindx;
10033965Sjdp
10133965Sjdp  /* String table index in .dynstr if this is a dynamic symbol.  */
10233965Sjdp  unsigned long dynstr_index;
10333965Sjdp
10433965Sjdp  /* If this is a weak defined symbol from a dynamic object, this
10533965Sjdp     field points to a defined symbol with the same value, if there is
10633965Sjdp     one.  Otherwise it is NULL.  */
10733965Sjdp  struct elf_link_hash_entry *weakdef;
10833965Sjdp
10933965Sjdp  /* If this symbol requires an entry in the global offset table, the
11060484Sobrien     processor specific backend uses this field to track usage and
11160484Sobrien     final offset.  We use a union and two names primarily to document
11260484Sobrien     the intent of any particular piece of code.  The field should be
11360484Sobrien     used as a count until size_dynamic_sections, at which point the
11460484Sobrien     contents of the .got is fixed.  Afterward, if this field is -1,
11560484Sobrien     then the symbol does not require a global offset table entry.  */
11660484Sobrien  union
11760484Sobrien    {
11860484Sobrien      bfd_signed_vma refcount;
11960484Sobrien      bfd_vma offset;
12060484Sobrien    } got;
12133965Sjdp
12260484Sobrien  /* Same, but tracks a procedure linkage table entry.  */
12360484Sobrien  union
12460484Sobrien    {
12560484Sobrien      bfd_signed_vma refcount;
12660484Sobrien      bfd_vma offset;
12760484Sobrien    } plt;
12833965Sjdp
12933965Sjdp  /* If this symbol is used in the linker created sections, the processor
13033965Sjdp     specific backend uses this field to map the field into the offset
13133965Sjdp     from the beginning of the section.  */
13233965Sjdp  struct elf_linker_section_pointers *linker_section_pointer;
13333965Sjdp
13433965Sjdp  /* Version information.  */
13533965Sjdp  union
13633965Sjdp  {
13733965Sjdp    /* This field is used for a symbol which is not defined in a
13833965Sjdp       regular object.  It points to the version information read in
13933965Sjdp       from the dynamic object.  */
14033965Sjdp    Elf_Internal_Verdef *verdef;
14133965Sjdp    /* This field is used for a symbol which is defined in a regular
14233965Sjdp       object.  It is set up in size_dynamic_sections.  It points to
14333965Sjdp       the version information we should write out for this symbol.  */
14433965Sjdp    struct bfd_elf_version_tree *vertree;
14533965Sjdp  } verinfo;
14633965Sjdp
14760484Sobrien  /* Virtual table entry use information.  This array is nominally of size
14860484Sobrien     size/sizeof(target_void_pointer), though we have to be able to assume
14960484Sobrien     and track a size while the symbol is still undefined.  It is indexed
15060484Sobrien     via offset/sizeof(target_void_pointer).  */
15160484Sobrien  size_t vtable_entries_size;
15260484Sobrien  boolean *vtable_entries_used;
15360484Sobrien
15460484Sobrien  /* Virtual table derivation info.  */
15560484Sobrien  struct elf_link_hash_entry *vtable_parent;
15660484Sobrien
15733965Sjdp  /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.).  */
15833965Sjdp  char type;
15933965Sjdp
16060484Sobrien  /* Symbol st_other value, symbol visibility.  */
16133965Sjdp  unsigned char other;
16233965Sjdp
16360484Sobrien  /* Hash value of the name computed using the ELF hash function.  */
16460484Sobrien  unsigned long elf_hash_value;
16560484Sobrien
16633965Sjdp  /* Some flags; legal values follow.  */
16733965Sjdp  unsigned short elf_link_hash_flags;
16833965Sjdp  /* Symbol is referenced by a non-shared object.  */
16933965Sjdp#define ELF_LINK_HASH_REF_REGULAR 01
17033965Sjdp  /* Symbol is defined by a non-shared object.  */
17133965Sjdp#define ELF_LINK_HASH_DEF_REGULAR 02
17233965Sjdp  /* Symbol is referenced by a shared object.  */
17333965Sjdp#define ELF_LINK_HASH_REF_DYNAMIC 04
17433965Sjdp  /* Symbol is defined by a shared object.  */
17533965Sjdp#define ELF_LINK_HASH_DEF_DYNAMIC 010
17660484Sobrien  /* Symbol has a non-weak reference from a non-shared object.  */
17760484Sobrien#define ELF_LINK_HASH_REF_REGULAR_NONWEAK 020
17833965Sjdp  /* Dynamic symbol has been adjustd.  */
17960484Sobrien#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 040
18033965Sjdp  /* Symbol needs a copy reloc.  */
18160484Sobrien#define ELF_LINK_HASH_NEEDS_COPY 0100
18233965Sjdp  /* Symbol needs a procedure linkage table entry.  */
18360484Sobrien#define ELF_LINK_HASH_NEEDS_PLT 0200
18433965Sjdp  /* Symbol appears in a non-ELF input file.  */
18560484Sobrien#define ELF_LINK_NON_ELF 0400
18633965Sjdp  /* Symbol should be marked as hidden in the version information.  */
18760484Sobrien#define ELF_LINK_HIDDEN 01000
18833965Sjdp  /* Symbol was forced to local scope due to a version script file.  */
18960484Sobrien#define ELF_LINK_FORCED_LOCAL 02000
19060484Sobrien  /* Symbol was marked during garbage collection.  */
19160484Sobrien#define ELF_LINK_HASH_MARK 04000
19260484Sobrien  /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
19360484Sobrien     not currently set by all the backends.  */
19460484Sobrien#define ELF_LINK_NON_GOT_REF 010000
19533965Sjdp};
19633965Sjdp
19760484Sobrien/* Records local symbols to be emitted in the dynamic symbol table.  */
19860484Sobrien
19960484Sobrienstruct elf_link_local_dynamic_entry
20060484Sobrien{
20160484Sobrien  struct elf_link_local_dynamic_entry *next;
20260484Sobrien
20360484Sobrien  /* The input bfd this symbol came from.  */
20460484Sobrien  bfd *input_bfd;
20560484Sobrien
20660484Sobrien  /* The index of the local symbol being copied.  */
20760484Sobrien  long input_indx;
20860484Sobrien
20960484Sobrien  /* The index in the outgoing dynamic symbol table.  */
21060484Sobrien  long dynindx;
21177298Sobrien
21260484Sobrien  /* A copy of the input symbol.  */
21360484Sobrien  Elf_Internal_Sym isym;
21460484Sobrien};
21560484Sobrien
21633965Sjdp/* ELF linker hash table.  */
21733965Sjdp
21833965Sjdpstruct elf_link_hash_table
21933965Sjdp{
22033965Sjdp  struct bfd_link_hash_table root;
22133965Sjdp  /* Whether we have created the special dynamic sections required
22233965Sjdp     when linking against or generating a shared object.  */
22333965Sjdp  boolean dynamic_sections_created;
22433965Sjdp  /* The BFD used to hold special sections created by the linker.
22533965Sjdp     This will be the first BFD found which requires these sections to
22633965Sjdp     be created.  */
22733965Sjdp  bfd *dynobj;
22833965Sjdp  /* The number of symbols found in the link which must be put into
22933965Sjdp     the .dynsym section.  */
23033965Sjdp  bfd_size_type dynsymcount;
23133965Sjdp  /* The string table of dynamic symbols, which becomes the .dynstr
23233965Sjdp     section.  */
23333965Sjdp  struct bfd_strtab_hash *dynstr;
23433965Sjdp  /* The number of buckets in the hash table in the .hash section.
23533965Sjdp     This is based on the number of dynamic symbols.  */
23633965Sjdp  bfd_size_type bucketcount;
23733965Sjdp  /* A linked list of DT_NEEDED names found in dynamic objects
23833965Sjdp     included in the link.  */
23933965Sjdp  struct bfd_link_needed_list *needed;
24033965Sjdp  /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
24133965Sjdp  struct elf_link_hash_entry *hgot;
24233965Sjdp  /* A pointer to information used to link stabs in sections.  */
24333965Sjdp  PTR stab_info;
24460484Sobrien  /* A linked list of local symbols to be added to .dynsym.  */
24560484Sobrien  struct elf_link_local_dynamic_entry *dynlocal;
24677298Sobrien  /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
24777298Sobrien     objects included in the link.  */
24877298Sobrien  struct bfd_link_needed_list *runpath;
24933965Sjdp};
25033965Sjdp
25133965Sjdp/* Look up an entry in an ELF linker hash table.  */
25233965Sjdp
25333965Sjdp#define elf_link_hash_lookup(table, string, create, copy, follow)	\
25433965Sjdp  ((struct elf_link_hash_entry *)					\
25533965Sjdp   bfd_link_hash_lookup (&(table)->root, (string), (create),		\
25633965Sjdp			 (copy), (follow)))
25733965Sjdp
25833965Sjdp/* Traverse an ELF linker hash table.  */
25933965Sjdp
26033965Sjdp#define elf_link_hash_traverse(table, func, info)			\
26133965Sjdp  (bfd_link_hash_traverse						\
26233965Sjdp   (&(table)->root,							\
26333965Sjdp    (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func),	\
26433965Sjdp    (info)))
26533965Sjdp
26633965Sjdp/* Get the ELF linker hash table from a link_info structure.  */
26733965Sjdp
26833965Sjdp#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
26933965Sjdp
27033965Sjdp/* Constant information held for an ELF backend.  */
27133965Sjdp
27233965Sjdpstruct elf_size_info {
27333965Sjdp  unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
27433965Sjdp  unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
27533965Sjdp
27660484Sobrien  /* The size of entries in the .hash section.  */
27760484Sobrien  unsigned char sizeof_hash_entry;
27860484Sobrien
27960484Sobrien  /* The number of internal relocations to allocate per external
28060484Sobrien     relocation entry.  */
28160484Sobrien  unsigned char int_rels_per_ext_rel;
28260484Sobrien
28333965Sjdp  unsigned char arch_size, file_align;
28433965Sjdp  unsigned char elfclass, ev_current;
28533965Sjdp  int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
28633965Sjdp  boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
28733965Sjdp  void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
28833965Sjdp  void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
28933965Sjdp  boolean (*slurp_reloc_table)
29033965Sjdp    PARAMS ((bfd *, asection *, asymbol **, boolean));
29133965Sjdp  long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
29233965Sjdp  void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
29360484Sobrien  void (*swap_dyn_out) PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
29460484Sobrien
29560484Sobrien  /* This function, if defined, is called to swap in a REL
29660484Sobrien     relocation.  If an external relocation corresponds to more than
29760484Sobrien     one internal relocation, then all relocations are swapped in at
29860484Sobrien     once.  */
29960484Sobrien  void (*swap_reloc_in)
30060484Sobrien    PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
30160484Sobrien
30260484Sobrien  /* This function, if defined, is called to swap out a REL
30360484Sobrien     relocation.  */
30460484Sobrien  void (*swap_reloc_out)
30560484Sobrien    PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
30660484Sobrien
30760484Sobrien  /* This function, if defined, is called to swap in a RELA
30860484Sobrien     relocation.  If an external relocation corresponds to more than
30960484Sobrien     one internal relocation, then all relocations are swapped in at
31060484Sobrien     once.  */
31160484Sobrien  void (*swap_reloca_in)
31260484Sobrien    PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
31360484Sobrien
31460484Sobrien  /* This function, if defined, is called to swap out a RELA
31560484Sobrien     relocation.  */
31660484Sobrien  void (*swap_reloca_out)
31760484Sobrien    PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
31860484Sobrien
31933965Sjdp};
32033965Sjdp
32133965Sjdp#define elf_symbol_from(ABFD,S) \
32233965Sjdp	(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
32333965Sjdp	  && (S)->the_bfd->tdata.elf_obj_data != 0) \
32433965Sjdp	 ? (elf_symbol_type *) (S) \
32533965Sjdp	 : 0)
32633965Sjdp
32733965Sjdpstruct elf_backend_data
32833965Sjdp{
32933965Sjdp  /* The architecture for this backend.  */
33033965Sjdp  enum bfd_architecture arch;
33133965Sjdp
33233965Sjdp  /* The ELF machine code (EM_xxxx) for this backend.  */
33333965Sjdp  int elf_machine_code;
33433965Sjdp
33533965Sjdp  /* The maximum page size for this backend.  */
33633965Sjdp  bfd_vma maxpagesize;
33733965Sjdp
33833965Sjdp  /* A function to translate an ELF RELA relocation to a BFD arelent
33933965Sjdp     structure.  */
34033965Sjdp  void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
34133965Sjdp				     Elf_Internal_Rela *));
34233965Sjdp
34333965Sjdp  /* A function to translate an ELF REL relocation to a BFD arelent
34433965Sjdp     structure.  */
34533965Sjdp  void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
34633965Sjdp					 Elf_Internal_Rel *));
34733965Sjdp
34833965Sjdp  /* A function to determine whether a symbol is global when
34933965Sjdp     partitioning the symbol table into local and global symbols.
35033965Sjdp     This should be NULL for most targets, in which case the correct
35133965Sjdp     thing will be done.  MIPS ELF, at least on the Irix 5, has
35233965Sjdp     special requirements.  */
35333965Sjdp  boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
35433965Sjdp
35533965Sjdp  /* The remaining functions are hooks which are called only if they
35633965Sjdp     are not NULL.  */
35733965Sjdp
35833965Sjdp  /* A function to permit a backend specific check on whether a
35933965Sjdp     particular BFD format is relevant for an object file, and to
36033965Sjdp     permit the backend to set any global information it wishes.  When
36133965Sjdp     this is called elf_elfheader is set, but anything else should be
36233965Sjdp     used with caution.  If this returns false, the check_format
36333965Sjdp     routine will return a bfd_error_wrong_format error.  */
36433965Sjdp  boolean (*elf_backend_object_p) PARAMS ((bfd *));
36533965Sjdp
36633965Sjdp  /* A function to do additional symbol processing when reading the
36733965Sjdp     ELF symbol table.  This is where any processor-specific special
36833965Sjdp     section indices are handled.  */
36933965Sjdp  void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
37033965Sjdp
37133965Sjdp  /* A function to do additional symbol processing after reading the
37233965Sjdp     entire ELF symbol table.  */
37333965Sjdp  boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
37433965Sjdp							  elf_symbol_type *,
37533965Sjdp							  unsigned int));
37633965Sjdp
37760484Sobrien   /* A function to set the type of the info field.  Processor-specific
37877298Sobrien     types should be handled here.  */
37977298Sobrien  int (*elf_backend_get_symbol_type) PARAMS (( Elf_Internal_Sym *, int));
38077298Sobrien
38133965Sjdp  /* A function to do additional processing on the ELF section header
38233965Sjdp     just before writing it out.  This is used to set the flags and
38333965Sjdp     type fields for some sections, or to actually write out data for
38433965Sjdp     unusual sections.  */
38533965Sjdp  boolean (*elf_backend_section_processing) PARAMS ((bfd *,
38633965Sjdp						     Elf32_Internal_Shdr *));
38733965Sjdp
38833965Sjdp  /* A function to handle unusual section types when creating BFD
38933965Sjdp     sections from ELF sections.  */
39033965Sjdp  boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
39133965Sjdp						    Elf32_Internal_Shdr *,
39233965Sjdp						    char *));
39333965Sjdp
39477298Sobrien  /* A function to convert machine dependent section header flags to
39577298Sobrien     BFD internal section header flags.  */
39677298Sobrien  boolean (*elf_backend_section_flags) PARAMS ((flagword *,
39777298Sobrien						Elf32_Internal_Shdr *));
39877298Sobrien
39960484Sobrien  /* A function to handle unusual program segment types when creating BFD
40077298Sobrien     sections from ELF program segments.  */
40160484Sobrien  boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *,
40260484Sobrien						    Elf32_Internal_Phdr *,
40360484Sobrien						    int));
40460484Sobrien
40533965Sjdp  /* A function to set up the ELF section header for a BFD section in
40633965Sjdp     preparation for writing it out.  This is where the flags and type
40733965Sjdp     fields are set for unusual sections.  */
40833965Sjdp  boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
40933965Sjdp						asection *));
41033965Sjdp
41133965Sjdp  /* A function to get the ELF section index for a BFD section.  If
41233965Sjdp     this returns true, the section was found.  If it is a normal ELF
41333965Sjdp     section, *RETVAL should be left unchanged.  If it is not a normal
41433965Sjdp     ELF section *RETVAL should be set to the SHN_xxxx index.  */
41533965Sjdp  boolean (*elf_backend_section_from_bfd_section)
41633965Sjdp    PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
41733965Sjdp
41833965Sjdp  /* If this field is not NULL, it is called by the add_symbols phase
41933965Sjdp     of a link just before adding a symbol to the global linker hash
42033965Sjdp     table.  It may modify any of the fields as it wishes.  If *NAME
42133965Sjdp     is set to NULL, the symbol will be skipped rather than being
42233965Sjdp     added to the hash table.  This function is responsible for
42333965Sjdp     handling all processor dependent symbol bindings and section
42433965Sjdp     indices, and must set at least *FLAGS and *SEC for each processor
42533965Sjdp     dependent case; failure to do so will cause a link error.  */
42633965Sjdp  boolean (*elf_add_symbol_hook)
42733965Sjdp    PARAMS ((bfd *abfd, struct bfd_link_info *info,
42833965Sjdp	     const Elf_Internal_Sym *, const char **name,
42933965Sjdp	     flagword *flags, asection **sec, bfd_vma *value));
43033965Sjdp
43133965Sjdp  /* If this field is not NULL, it is called by the elf_link_output_sym
43233965Sjdp     phase of a link for each symbol which will appear in the object file.  */
43333965Sjdp  boolean (*elf_backend_link_output_symbol_hook)
43433965Sjdp    PARAMS ((bfd *, struct bfd_link_info *info, const char *,
43533965Sjdp	     Elf_Internal_Sym *, asection *));
43633965Sjdp
43733965Sjdp  /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
43833965Sjdp     linker the first time it encounters a dynamic object in the link.
43933965Sjdp     This function must create any sections required for dynamic
44033965Sjdp     linking.  The ABFD argument is a dynamic object.  The .interp,
44133965Sjdp     .dynamic, .dynsym, .dynstr, and .hash functions have already been
44233965Sjdp     created, and this function may modify the section flags if
44333965Sjdp     desired.  This function will normally create the .got and .plt
44433965Sjdp     sections, but different backends have different requirements.  */
44533965Sjdp  boolean (*elf_backend_create_dynamic_sections)
44633965Sjdp    PARAMS ((bfd *abfd, struct bfd_link_info *info));
44733965Sjdp
44833965Sjdp  /* The CHECK_RELOCS function is called by the add_symbols phase of
44933965Sjdp     the ELF backend linker.  It is called once for each section with
45033965Sjdp     relocs of an object file, just after the symbols for the object
45133965Sjdp     file have been added to the global linker hash table.  The
45233965Sjdp     function must look through the relocs and do any special handling
45333965Sjdp     required.  This generally means allocating space in the global
45433965Sjdp     offset table, and perhaps allocating space for a reloc.  The
45533965Sjdp     relocs are always passed as Rela structures; if the section
45633965Sjdp     actually uses Rel structures, the r_addend field will always be
45733965Sjdp     zero.  */
45833965Sjdp  boolean (*check_relocs)
45933965Sjdp    PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
46033965Sjdp	     const Elf_Internal_Rela *relocs));
46133965Sjdp
46233965Sjdp  /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
46333965Sjdp     linker for every symbol which is defined by a dynamic object and
46433965Sjdp     referenced by a regular object.  This is called after all the
46533965Sjdp     input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
46633965Sjdp     function has been called.  The hash table entry should be
46733965Sjdp     bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
46833965Sjdp     defined in a section from a dynamic object.  Dynamic object
46933965Sjdp     sections are not included in the final link, and this function is
47033965Sjdp     responsible for changing the value to something which the rest of
47133965Sjdp     the link can deal with.  This will normally involve adding an
47233965Sjdp     entry to the .plt or .got or some such section, and setting the
47333965Sjdp     symbol to point to that.  */
47433965Sjdp  boolean (*elf_backend_adjust_dynamic_symbol)
47533965Sjdp    PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
47633965Sjdp
47733965Sjdp  /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
47833965Sjdp     after all the linker input files have been seen but before the
47933965Sjdp     section sizes have been set.  This is called after
48033965Sjdp     ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS.  */
48133965Sjdp  boolean (*elf_backend_always_size_sections)
48233965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
48333965Sjdp
48433965Sjdp  /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
48533965Sjdp     linker after all the linker input files have been seen but before
48633965Sjdp     the sections sizes have been set.  This is called after
48733965Sjdp     ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
48833965Sjdp     It is only called when linking against a dynamic object.  It must
48933965Sjdp     set the sizes of the dynamic sections, and may fill in their
49033965Sjdp     contents as well.  The generic ELF linker can handle the .dynsym,
49133965Sjdp     .dynstr and .hash sections.  This function must handle the
49233965Sjdp     .interp section and any sections created by the
49333965Sjdp     CREATE_DYNAMIC_SECTIONS entry point.  */
49433965Sjdp  boolean (*elf_backend_size_dynamic_sections)
49533965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
49633965Sjdp
49733965Sjdp  /* The RELOCATE_SECTION function is called by the ELF backend linker
49833965Sjdp     to handle the relocations for a section.
49933965Sjdp
50033965Sjdp     The relocs are always passed as Rela structures; if the section
50133965Sjdp     actually uses Rel structures, the r_addend field will always be
50233965Sjdp     zero.
50333965Sjdp
50433965Sjdp     This function is responsible for adjust the section contents as
50533965Sjdp     necessary, and (if using Rela relocs and generating a
50633965Sjdp     relocateable output file) adjusting the reloc addend as
50733965Sjdp     necessary.
50833965Sjdp
50933965Sjdp     This function does not have to worry about setting the reloc
51033965Sjdp     address or the reloc symbol index.
51133965Sjdp
51233965Sjdp     LOCAL_SYMS is a pointer to the swapped in local symbols.
51333965Sjdp
51433965Sjdp     LOCAL_SECTIONS is an array giving the section in the input file
51533965Sjdp     corresponding to the st_shndx field of each local symbol.
51633965Sjdp
51733965Sjdp     The global hash table entry for the global symbols can be found
51833965Sjdp     via elf_sym_hashes (input_bfd).
51933965Sjdp
52033965Sjdp     When generating relocateable output, this function must handle
52133965Sjdp     STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
52233965Sjdp     going to be the section symbol corresponding to the output
52333965Sjdp     section, which means that the addend must be adjusted
52433965Sjdp     accordingly.  */
52533965Sjdp  boolean (*elf_backend_relocate_section)
52633965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
52733965Sjdp	     bfd *input_bfd, asection *input_section, bfd_byte *contents,
52833965Sjdp	     Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
52933965Sjdp	     asection **local_sections));
53033965Sjdp
53133965Sjdp  /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
53233965Sjdp     linker just before it writes a symbol out to the .dynsym section.
53333965Sjdp     The processor backend may make any required adjustment to the
53433965Sjdp     symbol.  It may also take the opportunity to set contents of the
53533965Sjdp     dynamic sections.  Note that FINISH_DYNAMIC_SYMBOL is called on
53633965Sjdp     all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
53733965Sjdp     on those symbols which are defined by a dynamic object.  */
53833965Sjdp  boolean (*elf_backend_finish_dynamic_symbol)
53933965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
54033965Sjdp	     struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
54133965Sjdp
54233965Sjdp  /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
54333965Sjdp     linker just before it writes all the dynamic sections out to the
54433965Sjdp     output file.  The FINISH_DYNAMIC_SYMBOL will have been called on
54533965Sjdp     all dynamic symbols.  */
54633965Sjdp  boolean (*elf_backend_finish_dynamic_sections)
54733965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
54833965Sjdp
54933965Sjdp  /* A function to do any beginning processing needed for the ELF file
55033965Sjdp     before building the ELF headers and computing file positions.  */
55133965Sjdp  void (*elf_backend_begin_write_processing)
55233965Sjdp    PARAMS ((bfd *, struct bfd_link_info *));
55333965Sjdp
55433965Sjdp  /* A function to do any final processing needed for the ELF file
55533965Sjdp     before writing it out.  The LINKER argument is true if this BFD
55633965Sjdp     was created by the ELF backend linker.  */
55733965Sjdp  void (*elf_backend_final_write_processing)
55833965Sjdp    PARAMS ((bfd *, boolean linker));
55933965Sjdp
56033965Sjdp  /* This function is called by get_program_header_size.  It should
56133965Sjdp     return the number of additional program segments which this BFD
56233965Sjdp     will need.  It should return -1 on error.  */
56333965Sjdp  int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
56433965Sjdp
56533965Sjdp  /* This function is called to modify an existing segment map in a
56633965Sjdp     backend specific fashion.  */
56733965Sjdp  boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
56833965Sjdp
56960484Sobrien  /* This function is called during section gc to discover the section a
57060484Sobrien     particular relocation refers to.  It need not be defined for hosts
57160484Sobrien     that have no queer relocation types.  */
57260484Sobrien  asection * (*gc_mark_hook)
57360484Sobrien    PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
57460484Sobrien	     struct elf_link_hash_entry *h, Elf_Internal_Sym *));
57560484Sobrien
57660484Sobrien  /* This function, if defined, is called during the sweep phase of gc
57760484Sobrien     in order that a backend might update any data structures it might
57860484Sobrien     be maintaining.  */
57960484Sobrien  boolean (*gc_sweep_hook)
58060484Sobrien    PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
58160484Sobrien	     const Elf_Internal_Rela *relocs));
58260484Sobrien
58360484Sobrien  /* This function, if defined, is called after the ELF headers have
58460484Sobrien     been created.  This allows for things like the OS and ABI versions
58560484Sobrien     to be changed.  */
58660484Sobrien  void (*elf_backend_post_process_headers)
58760484Sobrien    PARAMS ((bfd *, struct bfd_link_info *));
58860484Sobrien
58960484Sobrien  /* This function, if defined, prints a symbol to file and returns the
59060484Sobrien     name of the symbol to be printed.  It should return NULL to fall
59160484Sobrien     back to default symbol printing.  */
59260484Sobrien  const char *(*elf_backend_print_symbol_all)
59360484Sobrien    PARAMS ((bfd *, PTR, asymbol *));
59460484Sobrien
59560484Sobrien  /* This function, if defined, is called after all local symbols and
59660484Sobrien     global symbols converted to locals are emited into the symtab
59760484Sobrien     section.  It allows the backend to emit special global symbols
59860484Sobrien     not handled in the hash table.  */
59960484Sobrien  boolean (*elf_backend_output_arch_syms)
60060484Sobrien    PARAMS ((bfd *, struct bfd_link_info *, PTR,
60160484Sobrien	    boolean (*) PARAMS ((PTR, const char *,
60260484Sobrien             Elf_Internal_Sym *, asection *))));
60360484Sobrien
60460484Sobrien  /* Copy any information related to dynamic linking from a pre-existing
60560484Sobrien     symbol IND to a newly created symbol DIR.  */
60660484Sobrien  void (*elf_backend_copy_indirect_symbol)
60760484Sobrien    PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
60860484Sobrien
60960484Sobrien  /* Modify any information related to dynamic linking such that the
61060484Sobrien     symbol is not exported.  */
61160484Sobrien  void (*elf_backend_hide_symbol)
61277298Sobrien    PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
61360484Sobrien
61433965Sjdp  /* The swapping table to use when dealing with ECOFF information.
61533965Sjdp     Used for the MIPS ELF .mdebug section.  */
61633965Sjdp  const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
61733965Sjdp
61833965Sjdp  /* Alternate EM_xxxx machine codes for this backend.  */
61933965Sjdp  int elf_machine_alt1;
62033965Sjdp  int elf_machine_alt2;
62133965Sjdp
62233965Sjdp  const struct elf_size_info *s;
62333965Sjdp
62438889Sjdp  /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
62538889Sjdp     .got section */
62638889Sjdp  bfd_vma got_symbol_offset;
62738889Sjdp
62860484Sobrien  /* The size in bytes of the headers for the GOT and PLT.  This includes
62960484Sobrien     the so-called reserved entries on some systems.  */
63060484Sobrien  bfd_vma got_header_size;
63160484Sobrien  bfd_vma plt_header_size;
63260484Sobrien
63360484Sobrien  /* This is true if the linker should act like collect and gather
63460484Sobrien     global constructors and destructors by name.  This is true for
63560484Sobrien     MIPS ELF because the Irix 5 tools can not handle the .init
63660484Sobrien     section.  */
63760484Sobrien  unsigned collect : 1;
63860484Sobrien
63960484Sobrien  /* This is true if the linker should ignore changes to the type of a
64060484Sobrien     symbol.  This is true for MIPS ELF because some Irix 5 objects
64160484Sobrien     record undefined functions as STT_OBJECT although the definitions
64260484Sobrien     are STT_FUNC.  */
64360484Sobrien  unsigned type_change_ok : 1;
64460484Sobrien
64560484Sobrien  /* Whether the backend may use REL relocations.  (Some backends use
64660484Sobrien     both REL and RELA relocations, and this flag is set for those
64760484Sobrien     backends.)  */
64860484Sobrien  unsigned may_use_rel_p : 1;
64977298Sobrien
65060484Sobrien  /* Whether the backend may use RELA relocations.  (Some backends use
65160484Sobrien     both REL and RELA relocations, and this flag is set for those
65260484Sobrien     backends.)  */
65360484Sobrien  unsigned may_use_rela_p : 1;
65460484Sobrien
65560484Sobrien  /* Whether the default relocation type is RELA.  If a backend with
65660484Sobrien     this flag set wants REL relocations for a particular section,
65760484Sobrien     it must note that explicitly.  Similarly, if this flag is clear,
65877298Sobrien     and the backend wants RELA relocations for a particular
65977298Sobrien     section.  */
66060484Sobrien  unsigned default_use_rela_p : 1;
66160484Sobrien
66260484Sobrien  /* True if addresses "naturally" sign extend.  This is used when
66360484Sobrien     swapping in from Elf32 when BFD64.  */
66460484Sobrien  unsigned sign_extend_vma : 1;
66560484Sobrien
66633965Sjdp  unsigned want_got_plt : 1;
66733965Sjdp  unsigned plt_readonly : 1;
66833965Sjdp  unsigned want_plt_sym : 1;
66938889Sjdp  unsigned plt_not_loaded : 1;
67038889Sjdp  unsigned plt_alignment : 4;
67160484Sobrien  unsigned can_gc_sections : 1;
67260484Sobrien  unsigned want_dynbss : 1;
67333965Sjdp};
67433965Sjdp
67533965Sjdp/* Information stored for each BFD section in an ELF file.  This
67633965Sjdp   structure is allocated by elf_new_section_hook.  */
67733965Sjdp
67833965Sjdpstruct bfd_elf_section_data
67933965Sjdp{
68033965Sjdp  /* The ELF header for this section.  */
68133965Sjdp  Elf_Internal_Shdr this_hdr;
68233965Sjdp  /* The ELF header for the reloc section associated with this
68333965Sjdp     section, if any.  */
68433965Sjdp  Elf_Internal_Shdr rel_hdr;
68533965Sjdp  /* If there is a second reloc section associated with this section,
68633965Sjdp     as can happen on Irix 6, this field points to the header.  */
68733965Sjdp  Elf_Internal_Shdr *rel_hdr2;
68860484Sobrien  /* The number of relocations currently assigned to REL_HDR.  */
68960484Sobrien  unsigned int rel_count;
69060484Sobrien  /* The number of relocations currently assigned to REL_HDR2.  */
69160484Sobrien  unsigned int rel_count2;
69233965Sjdp  /* The ELF section number of this section.  Only used for an output
69333965Sjdp     file.  */
69433965Sjdp  int this_idx;
69560484Sobrien  /* The ELF section number of the reloc section indicated by
69660484Sobrien     REL_HDR if any.  Only used for an output file.  */
69733965Sjdp  int rel_idx;
69860484Sobrien  /* The ELF section number of the reloc section indicated by
69960484Sobrien     REL_HDR2 if any.  Only used for an output file.  */
70060484Sobrien  int rel_idx2;
70133965Sjdp  /* Used by the backend linker to store the symbol hash table entries
70233965Sjdp     associated with relocs against global symbols.  */
70333965Sjdp  struct elf_link_hash_entry **rel_hashes;
70433965Sjdp  /* A pointer to the swapped relocs.  If the section uses REL relocs,
70533965Sjdp     rather than RELA, all the r_addend fields will be zero.  This
70633965Sjdp     pointer may be NULL.  It is used by the backend linker.  */
70733965Sjdp  Elf_Internal_Rela *relocs;
70833965Sjdp  /* Used by the backend linker when generating a shared library to
70933965Sjdp     record the dynamic symbol index for a section symbol
71060484Sobrien     corresponding to this section.  A value of 0 means that there is
71160484Sobrien     no dynamic symbol for this section.  */
71233965Sjdp  long dynindx;
71333965Sjdp  /* A pointer used for .stab linking optimizations.  */
71433965Sjdp  PTR stab_info;
71533965Sjdp  /* A pointer available for the processor specific ELF backend.  */
71633965Sjdp  PTR tdata;
71760484Sobrien  /* Nonzero if this section uses RELA relocations, rather than REL.  */
71860484Sobrien  unsigned int use_rela_p:1;
71933965Sjdp};
72033965Sjdp
72133965Sjdp#define elf_section_data(sec)  ((struct bfd_elf_section_data*)sec->used_by_bfd)
72233965Sjdp
72333965Sjdp#define get_elf_backend_data(abfd) \
72433965Sjdp  ((struct elf_backend_data *) (abfd)->xvec->backend_data)
72533965Sjdp
72633965Sjdp/* Enumeration to specify the special section.  */
72733965Sjdptypedef enum elf_linker_section_enum
72833965Sjdp{
72933965Sjdp  LINKER_SECTION_UNKNOWN,		/* not used */
73033965Sjdp  LINKER_SECTION_GOT,			/* .got section for global offset pointers */
73133965Sjdp  LINKER_SECTION_PLT,			/* .plt section for generated procedure stubs */
73233965Sjdp  LINKER_SECTION_SDATA,			/* .sdata/.sbss section for PowerPC */
73333965Sjdp  LINKER_SECTION_SDATA2,		/* .sdata2/.sbss2 section for PowerPC */
73433965Sjdp  LINKER_SECTION_MAX			/* # of linker sections */
73533965Sjdp} elf_linker_section_enum_t;
73633965Sjdp
73733965Sjdp/* Sections created by the linker.  */
73833965Sjdp
73933965Sjdptypedef struct elf_linker_section
74033965Sjdp{
74133965Sjdp  char *name;				/* name of the section */
74233965Sjdp  char *rel_name;			/* name of the associated .rel{,a}. section */
74333965Sjdp  char *bss_name;			/* name of a related .bss section */
74433965Sjdp  char *sym_name;			/* name of symbol to reference this section */
74533965Sjdp  asection *section;			/* pointer to the section */
74633965Sjdp  asection *bss_section;		/* pointer to the bss section associated with this */
74733965Sjdp  asection *rel_section;		/* pointer to the relocations needed for this section */
74833965Sjdp  struct elf_link_hash_entry *sym_hash;	/* pointer to the created symbol hash value */
74933965Sjdp  bfd_vma initial_size;			/* initial size before any linker generated allocations */
75033965Sjdp  bfd_vma sym_offset;			/* offset of symbol from beginning of section */
75133965Sjdp  bfd_vma hole_size;			/* size of reserved address hole in allocation */
75233965Sjdp  bfd_vma hole_offset;			/* current offset for the hole */
75333965Sjdp  bfd_vma max_hole_offset;		/* maximum offset for the hole */
75433965Sjdp  elf_linker_section_enum_t which;	/* which section this is */
75533965Sjdp  boolean hole_written_p;		/* whether the hole has been initialized */
75638889Sjdp  unsigned int alignment;		/* alignment for the section */
75733965Sjdp  flagword flags;			/* flags to use to create the section */
75833965Sjdp} elf_linker_section_t;
75933965Sjdp
76033965Sjdp/* Linked list of allocated pointer entries.  This hangs off of the symbol lists, and
76133965Sjdp   provides allows us to return different pointers, based on different addend's.  */
76233965Sjdp
76333965Sjdptypedef struct elf_linker_section_pointers
76433965Sjdp{
76533965Sjdp  struct elf_linker_section_pointers *next;	/* next allocated pointer for this symbol */
76633965Sjdp  bfd_vma offset;				/* offset of pointer from beginning of section */
76733965Sjdp  bfd_signed_vma addend;			/* addend used */
76833965Sjdp  elf_linker_section_enum_t which;		/* which linker section this is */
76933965Sjdp  boolean written_address_p;			/* whether address was written yet */
77033965Sjdp} elf_linker_section_pointers_t;
77133965Sjdp
77233965Sjdp/* Some private data is stashed away for future use using the tdata pointer
77333965Sjdp   in the bfd structure.  */
77433965Sjdp
77533965Sjdpstruct elf_obj_tdata
77633965Sjdp{
77733965Sjdp  Elf_Internal_Ehdr elf_header[1];	/* Actual data, but ref like ptr */
77833965Sjdp  Elf_Internal_Shdr **elf_sect_ptr;
77933965Sjdp  Elf_Internal_Phdr *phdr;
78033965Sjdp  struct elf_segment_map *segment_map;
78133965Sjdp  struct bfd_strtab_hash *strtab_ptr;
78233965Sjdp  int num_locals;
78333965Sjdp  int num_globals;
78433965Sjdp  asymbol **section_syms;		/* STT_SECTION symbols for each section */
78533965Sjdp  Elf_Internal_Shdr symtab_hdr;
78633965Sjdp  Elf_Internal_Shdr shstrtab_hdr;
78733965Sjdp  Elf_Internal_Shdr strtab_hdr;
78833965Sjdp  Elf_Internal_Shdr dynsymtab_hdr;
78933965Sjdp  Elf_Internal_Shdr dynstrtab_hdr;
79033965Sjdp  Elf_Internal_Shdr dynversym_hdr;
79133965Sjdp  Elf_Internal_Shdr dynverref_hdr;
79233965Sjdp  Elf_Internal_Shdr dynverdef_hdr;
79333965Sjdp  unsigned int symtab_section, shstrtab_section;
79433965Sjdp  unsigned int strtab_section, dynsymtab_section;
79533965Sjdp  unsigned int dynversym_section, dynverdef_section, dynverref_section;
79633965Sjdp  file_ptr next_file_pos;
79760484Sobrien#if 0
79860484Sobrien  /* we don't need these inside bfd anymore, and I think
79977298Sobrien     these weren't used outside bfd.  */
80033965Sjdp  void *prstatus;			/* The raw /proc prstatus structure */
80133965Sjdp  void *prpsinfo;			/* The raw /proc prpsinfo structure */
80260484Sobrien#endif
80333965Sjdp  bfd_vma gp;				/* The gp value (MIPS only, for now) */
80433965Sjdp  unsigned int gp_size;			/* The gp size (MIPS only, for now) */
80533965Sjdp
80677298Sobrien  /* Information grabbed from an elf core file.  */
80760484Sobrien  int core_signal;
80860484Sobrien  int core_pid;
80960484Sobrien  int core_lwpid;
81060484Sobrien  char* core_program;
81160484Sobrien  char* core_command;
81260484Sobrien
81333965Sjdp  /* This is set to true if the object was created by the backend
81433965Sjdp     linker.  */
81533965Sjdp  boolean linker;
81633965Sjdp
81733965Sjdp  /* A mapping from external symbols to entries in the linker hash
81833965Sjdp     table, used when linking.  This is indexed by the symbol index
81933965Sjdp     minus the sh_info field of the symbol table header.  */
82033965Sjdp  struct elf_link_hash_entry **sym_hashes;
82133965Sjdp
82233965Sjdp  /* A mapping from local symbols to offsets into the global offset
82360484Sobrien     table, used when linking.  This is indexed by the symbol index.
82460484Sobrien     Like for the globals, we use a union and two names primarily to
82560484Sobrien     document the intent of any particular piece of code.  The field
82660484Sobrien     should be used as a count until size_dynamic_sections, at which
82760484Sobrien     point the contents of the .got is fixed.  Afterward, if an entry
82877298Sobrien     is -1, then the symbol does not require a global offset table entry.  */
82960484Sobrien  union
83060484Sobrien    {
83160484Sobrien      bfd_signed_vma *refcounts;
83260484Sobrien      bfd_vma *offsets;
83360484Sobrien    } local_got;
83433965Sjdp
83533965Sjdp  /* A mapping from local symbols to offsets into the various linker
83633965Sjdp     sections added.  This is index by the symbol index.  */
83733965Sjdp  elf_linker_section_pointers_t **linker_section_pointers;
83833965Sjdp
83933965Sjdp  /* The linker ELF emulation code needs to let the backend ELF linker
84033965Sjdp     know what filename should be used for a dynamic object if the
84133965Sjdp     dynamic object is found using a search.  The emulation code then
84233965Sjdp     sometimes needs to know what name was actually used.  Until the
84333965Sjdp     file has been added to the linker symbol table, this field holds
84433965Sjdp     the name the linker wants.  After it has been added, it holds the
84533965Sjdp     name actually used, which will be the DT_SONAME entry if there is
84633965Sjdp     one.  */
84733965Sjdp  const char *dt_name;
84833965Sjdp
84977298Sobrien  /* When a reference in a regular object is resolved by a shared
85077298Sobrien     object is loaded into via the DT_NEEDED entries by the linker
85177298Sobrien     ELF emulation code, we need to add the shared object to the
85277298Sobrien     DT_NEEDED list of the resulting binary to indicate the dependency
85377298Sobrien     as if the -l option is passed to the linker. This field holds the
85477298Sobrien     name of the loaded shared object.  */
85577298Sobrien  const char *dt_soname;
85677298Sobrien
85733965Sjdp  /* Irix 5 often screws up the symbol table, sorting local symbols
85833965Sjdp     after global symbols.  This flag is set if the symbol table in
85933965Sjdp     this BFD appears to be screwed up.  If it is, we ignore the
86033965Sjdp     sh_info field in the symbol table header, and always read all the
86133965Sjdp     symbols.  */
86233965Sjdp  boolean bad_symtab;
86333965Sjdp
86433965Sjdp  /* Records the result of `get_program_header_size'.  */
86533965Sjdp  bfd_size_type program_header_size;
86633965Sjdp
86733965Sjdp  /* Used by find_nearest_line entry point.  */
86833965Sjdp  PTR line_info;
86933965Sjdp
87033965Sjdp  /* Used by MIPS ELF find_nearest_line entry point.  The structure
87133965Sjdp     could be included directly in this one, but there's no point to
87233965Sjdp     wasting the memory just for the infrequently called
87333965Sjdp     find_nearest_line.  */
87433965Sjdp  struct mips_elf_find_line *find_line_info;
87533965Sjdp
87677298Sobrien  /* A place to stash dwarf1 info for this bfd.  */
87760484Sobrien  struct dwarf1_debug *dwarf1_find_line_info;
87860484Sobrien
87977298Sobrien  /* A place to stash dwarf2 info for this bfd.  */
88077298Sobrien  PTR dwarf2_find_line_info;
88138889Sjdp
88233965Sjdp  /* An array of stub sections indexed by symbol number, used by the
88333965Sjdp     MIPS ELF linker.  FIXME: We should figure out some way to only
88433965Sjdp     include this field for a MIPS ELF target.  */
88533965Sjdp  asection **local_stubs;
88633965Sjdp
88733965Sjdp  /* Used to determine if the e_flags field has been initialized */
88833965Sjdp  boolean flags_init;
88933965Sjdp
89033965Sjdp  /* Number of symbol version definitions we are about to emit.  */
89138889Sjdp  unsigned int cverdefs;
89233965Sjdp
89333965Sjdp  /* Number of symbol version references we are about to emit.  */
89438889Sjdp  unsigned int cverrefs;
89533965Sjdp
89633965Sjdp  /* Symbol version definitions in external objects.  */
89733965Sjdp  Elf_Internal_Verdef *verdef;
89833965Sjdp
89933965Sjdp  /* Symbol version references to external objects.  */
90033965Sjdp  Elf_Internal_Verneed *verref;
90133965Sjdp
90233965Sjdp  /* Linker sections that we are interested in.  */
90333965Sjdp  struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
90477298Sobrien
90577298Sobrien  /* The Irix 5 support uses two virtual sections, which represent
90677298Sobrien     text/data symbols defined in dynamic objects.  */
90777298Sobrien  asymbol *elf_data_symbol;
90877298Sobrien  asymbol *elf_text_symbol;
90977298Sobrien  asection *elf_data_section;
91077298Sobrien  asection *elf_text_section;
91133965Sjdp};
91233965Sjdp
91333965Sjdp#define elf_tdata(bfd)		((bfd) -> tdata.elf_obj_data)
91433965Sjdp#define elf_elfheader(bfd)	(elf_tdata(bfd) -> elf_header)
91533965Sjdp#define elf_elfsections(bfd)	(elf_tdata(bfd) -> elf_sect_ptr)
91633965Sjdp#define elf_shstrtab(bfd)	(elf_tdata(bfd) -> strtab_ptr)
91733965Sjdp#define elf_onesymtab(bfd)	(elf_tdata(bfd) -> symtab_section)
91833965Sjdp#define elf_dynsymtab(bfd)	(elf_tdata(bfd) -> dynsymtab_section)
91933965Sjdp#define elf_dynversym(bfd)	(elf_tdata(bfd) -> dynversym_section)
92033965Sjdp#define elf_dynverdef(bfd)	(elf_tdata(bfd) -> dynverdef_section)
92133965Sjdp#define elf_dynverref(bfd)	(elf_tdata(bfd) -> dynverref_section)
92233965Sjdp#define elf_num_locals(bfd)	(elf_tdata(bfd) -> num_locals)
92333965Sjdp#define elf_num_globals(bfd)	(elf_tdata(bfd) -> num_globals)
92433965Sjdp#define elf_section_syms(bfd)	(elf_tdata(bfd) -> section_syms)
92533965Sjdp#define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
92633965Sjdp#define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
92733965Sjdp#define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
92833965Sjdp#define elf_gp_size(bfd)	(elf_tdata(bfd) -> gp_size)
92933965Sjdp#define elf_sym_hashes(bfd)	(elf_tdata(bfd) -> sym_hashes)
93060484Sobrien#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
93160484Sobrien#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
93233965Sjdp#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
93333965Sjdp#define elf_dt_name(bfd)	(elf_tdata(bfd) -> dt_name)
93477298Sobrien#define elf_dt_soname(bfd)	(elf_tdata(bfd) -> dt_soname)
93533965Sjdp#define elf_bad_symtab(bfd)	(elf_tdata(bfd) -> bad_symtab)
93633965Sjdp#define elf_flags_init(bfd)	(elf_tdata(bfd) -> flags_init)
93733965Sjdp#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
93833965Sjdp
93933965Sjdpextern void _bfd_elf_swap_verdef_in
94033965Sjdp  PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
94133965Sjdpextern void _bfd_elf_swap_verdef_out
94233965Sjdp  PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
94333965Sjdpextern void _bfd_elf_swap_verdaux_in
94433965Sjdp  PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
94533965Sjdpextern void _bfd_elf_swap_verdaux_out
94633965Sjdp  PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
94733965Sjdpextern void _bfd_elf_swap_verneed_in
94833965Sjdp  PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
94933965Sjdpextern void _bfd_elf_swap_verneed_out
95033965Sjdp  PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
95133965Sjdpextern void _bfd_elf_swap_vernaux_in
95233965Sjdp  PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
95333965Sjdpextern void _bfd_elf_swap_vernaux_out
95433965Sjdp  PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
95533965Sjdpextern void _bfd_elf_swap_versym_in
95633965Sjdp  PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
95733965Sjdpextern void _bfd_elf_swap_versym_out
95833965Sjdp  PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
95933965Sjdp
96033965Sjdpextern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
96133965Sjdpextern char *bfd_elf_string_from_elf_section
96233965Sjdp  PARAMS ((bfd *, unsigned, unsigned));
96333965Sjdpextern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
96433965Sjdp
96533965Sjdpextern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
96633965Sjdpextern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
96733965Sjdp					  bfd_print_symbol_type));
96833965Sjdp#define elf_string_from_elf_strtab(abfd,strindex) \
96933965Sjdp     bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
97033965Sjdp
97133965Sjdp#define bfd_elf32_print_symbol	bfd_elf_print_symbol
97233965Sjdp#define bfd_elf64_print_symbol	bfd_elf_print_symbol
97333965Sjdp
97460484Sobrienextern unsigned long bfd_elf_hash PARAMS ((const char *));
97533965Sjdp
97633965Sjdpextern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
97733965Sjdp							    arelent *,
97833965Sjdp							    asymbol *,
97933965Sjdp							    PTR,
98033965Sjdp							    asection *,
98133965Sjdp							    bfd *,
98233965Sjdp							    char **));
98333965Sjdpextern boolean bfd_elf_mkobject PARAMS ((bfd *));
98460484Sobrienextern boolean bfd_elf_mkcorefile PARAMS ((bfd *));
98533965Sjdpextern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
98633965Sjdpextern boolean _bfd_elf_make_section_from_shdr
98733965Sjdp  PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
98860484Sobrienextern boolean _bfd_elf_make_section_from_phdr
98960484Sobrien  PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));
99033965Sjdpextern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
99133965Sjdp  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
99233965Sjdpextern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
99333965Sjdp  PARAMS ((bfd *));
99460484Sobrienextern void _bfd_elf_link_hash_copy_indirect
99560484Sobrien  PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
99660484Sobrienextern void _bfd_elf_link_hash_hide_symbol
99777298Sobrien  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
99833965Sjdpextern boolean _bfd_elf_link_hash_table_init
99933965Sjdp  PARAMS ((struct elf_link_hash_table *, bfd *,
100033965Sjdp	   struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
100133965Sjdp				       struct bfd_hash_table *,
100233965Sjdp				       const char *)));
100333965Sjdpextern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));
100433965Sjdp
100533965Sjdpextern boolean _bfd_elf_copy_private_symbol_data
100633965Sjdp  PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
100733965Sjdpextern boolean _bfd_elf_copy_private_section_data
100833965Sjdp  PARAMS ((bfd *, asection *, bfd *, asection *));
100933965Sjdpextern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
101060484Sobrienextern boolean _bfd_elf_write_corefile_contents PARAMS ((bfd *));
101133965Sjdpextern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
101233965Sjdp						       file_ptr,
101333965Sjdp						       bfd_size_type));
101433965Sjdpextern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
101533965Sjdpextern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
101633965Sjdpextern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
101733965Sjdpextern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
101833965Sjdpextern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
101933965Sjdpextern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
102033965Sjdp						  arelent **, asymbol **));
102133965Sjdpextern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
102233965Sjdpextern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **,
102333965Sjdp							 asymbol **));
102433965Sjdpextern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
102533965Sjdpextern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
102633965Sjdp					       symbol_info *));
102733965Sjdpextern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *));
102833965Sjdpextern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
102933965Sjdpextern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
103033965Sjdp						unsigned long));
103133965Sjdpextern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
103233965Sjdp						    asymbol **,
103377298Sobrien						    bfd_vma, const char **,
103477298Sobrien						    const char **,
103533965Sjdp						    unsigned int *));
103633965Sjdp#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
103733965Sjdp#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
103833965Sjdpextern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
103933965Sjdpextern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
104077298Sobrienextern boolean _bfd_elf_init_reloc_shdr
104160484Sobrien  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean));
104233965Sjdp
104333965Sjdp/* If the target doesn't have reloc handling written yet:  */
104433965Sjdpextern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
104533965Sjdp					       Elf_Internal_Rela *));
104633965Sjdp
104733965Sjdpextern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
104833965Sjdpextern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int));
104933965Sjdp
105033965Sjdpextern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
105133965Sjdp
105233965Sjdpasection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
105333965Sjdpboolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
105433965Sjdp						  struct bfd_link_info *));
105533965Sjdpstruct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
105633965Sjdpboolean
105733965Sjdp_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
105833965Sjdp					     struct elf_link_hash_entry *));
105960484Sobrienlong
106060484Sobrien_bfd_elf_link_lookup_local_dynindx PARAMS ((struct bfd_link_info *,
106160484Sobrien					    bfd *, long));
106233965Sjdpboolean
106333965Sjdp_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
106433965Sjdp						 struct bfd_link_info *));
106533965Sjdpvoid _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
106633965Sjdpfile_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
106733965Sjdp							    file_ptr,
106833965Sjdp							    boolean));
106933965Sjdp
107033965Sjdpextern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
107133965Sjdp
107233965Sjdpboolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
107333965Sjdp						  struct bfd_link_info *));
107433965Sjdpboolean _bfd_elf_create_got_section PARAMS ((bfd *,
107533965Sjdp					     struct bfd_link_info *));
107660484Sobrienunsigned long _bfd_elf_link_renumber_dynsyms PARAMS ((bfd *,
107760484Sobrien						      struct bfd_link_info *));
107833965Sjdp
107933965Sjdpelf_linker_section_t *_bfd_elf_create_linker_section
108033965Sjdp  PARAMS ((bfd *abfd,
108133965Sjdp	   struct bfd_link_info *info,
108233965Sjdp	   enum elf_linker_section_enum,
108333965Sjdp	   elf_linker_section_t *defaults));
108433965Sjdp
108533965Sjdpelf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
108633965Sjdp  PARAMS ((elf_linker_section_pointers_t *linker_pointers,
108733965Sjdp	   bfd_signed_vma addend,
108833965Sjdp	   elf_linker_section_enum_t which));
108933965Sjdp
109033965Sjdpboolean bfd_elf32_create_pointer_linker_section
109133965Sjdp  PARAMS ((bfd *abfd,
109233965Sjdp	   struct bfd_link_info *info,
109333965Sjdp	   elf_linker_section_t *lsect,
109433965Sjdp	   struct elf_link_hash_entry *h,
109533965Sjdp	   const Elf32_Internal_Rela *rel));
109633965Sjdp
109733965Sjdpbfd_vma bfd_elf32_finish_pointer_linker_section
109833965Sjdp  PARAMS ((bfd *output_abfd,
109933965Sjdp	   bfd *input_bfd,
110033965Sjdp	   struct bfd_link_info *info,
110133965Sjdp	   elf_linker_section_t *lsect,
110233965Sjdp	   struct elf_link_hash_entry *h,
110333965Sjdp	   bfd_vma relocation,
110433965Sjdp	   const Elf32_Internal_Rela *rel,
110533965Sjdp	   int relative_reloc));
110633965Sjdp
110733965Sjdpboolean bfd_elf64_create_pointer_linker_section
110833965Sjdp  PARAMS ((bfd *abfd,
110933965Sjdp	   struct bfd_link_info *info,
111033965Sjdp	   elf_linker_section_t *lsect,
111133965Sjdp	   struct elf_link_hash_entry *h,
111233965Sjdp	   const Elf64_Internal_Rela *rel));
111333965Sjdp
111433965Sjdpbfd_vma bfd_elf64_finish_pointer_linker_section
111533965Sjdp  PARAMS ((bfd *output_abfd,
111633965Sjdp	   bfd *input_bfd,
111733965Sjdp	   struct bfd_link_info *info,
111833965Sjdp	   elf_linker_section_t *lsect,
111933965Sjdp	   struct elf_link_hash_entry *h,
112033965Sjdp	   bfd_vma relocation,
112133965Sjdp	   const Elf64_Internal_Rela *rel,
112233965Sjdp	   int relative_reloc));
112333965Sjdp
112433965Sjdpboolean _bfd_elf_make_linker_section_rela
112533965Sjdp  PARAMS ((bfd *dynobj,
112633965Sjdp	   elf_linker_section_t *lsect,
112733965Sjdp	   int alignment));
112833965Sjdp
112960484Sobrienboolean _bfd_elfcore_section_from_phdr
113060484Sobrien  PARAMS ((bfd *, Elf_Internal_Phdr *, int));
113160484Sobrien
113233965Sjdpextern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
113333965Sjdpextern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
113433965Sjdpextern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
113533965Sjdpextern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
113633965Sjdpextern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
113733965Sjdp								 bfd *));
113833965Sjdp
113933965Sjdpextern boolean bfd_elf32_bfd_link_add_symbols
114033965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
114133965Sjdpextern boolean bfd_elf32_bfd_final_link
114233965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
114333965Sjdp
114433965Sjdpextern void bfd_elf32_swap_symbol_in
114533965Sjdp  PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
114633965Sjdpextern void bfd_elf32_swap_symbol_out
114733965Sjdp  PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
114833965Sjdpextern void bfd_elf32_swap_reloc_in
114933965Sjdp  PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
115033965Sjdpextern void bfd_elf32_swap_reloc_out
115133965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
115233965Sjdpextern void bfd_elf32_swap_reloca_in
115333965Sjdp  PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
115433965Sjdpextern void bfd_elf32_swap_reloca_out
115533965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
115633965Sjdpextern void bfd_elf32_swap_phdr_in
115733965Sjdp  PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
115833965Sjdpextern void bfd_elf32_swap_phdr_out
115933965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
116033965Sjdpextern void bfd_elf32_swap_dyn_in
116133965Sjdp  PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
116233965Sjdpextern void bfd_elf32_swap_dyn_out
116360484Sobrien  PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
116433965Sjdpextern long bfd_elf32_slurp_symbol_table
116533965Sjdp  PARAMS ((bfd *, asymbol **, boolean));
116633965Sjdpextern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
116733965Sjdpextern int bfd_elf32_write_out_phdrs
116833965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
116977298Sobrienextern void bfd_elf32_write_relocs
117077298Sobrien  PARAMS ((bfd *, asection *, PTR));
117177298Sobrienextern boolean bfd_elf32_slurp_reloc_table
117277298Sobrien  PARAMS ((bfd *, asection *, asymbol **, boolean));
117333965Sjdpextern boolean bfd_elf32_add_dynamic_entry
117433965Sjdp  PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
117533965Sjdpextern boolean bfd_elf32_link_create_dynamic_sections
117633965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
117733965Sjdpextern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
117833965Sjdp  PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
117933965Sjdp
118033965Sjdpextern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
118133965Sjdpextern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
118233965Sjdpextern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
118333965Sjdpextern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
118433965Sjdpextern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
118533965Sjdp								 bfd *));
118633965Sjdpextern boolean bfd_elf64_bfd_link_add_symbols
118733965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
118833965Sjdpextern boolean bfd_elf64_bfd_final_link
118933965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
119033965Sjdp
119133965Sjdpextern void bfd_elf64_swap_symbol_in
119233965Sjdp  PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
119333965Sjdpextern void bfd_elf64_swap_symbol_out
119433965Sjdp  PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
119533965Sjdpextern void bfd_elf64_swap_reloc_in
119633965Sjdp  PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
119733965Sjdpextern void bfd_elf64_swap_reloc_out
119833965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
119933965Sjdpextern void bfd_elf64_swap_reloca_in
120033965Sjdp  PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
120133965Sjdpextern void bfd_elf64_swap_reloca_out
120233965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
120333965Sjdpextern void bfd_elf64_swap_phdr_in
120433965Sjdp  PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
120533965Sjdpextern void bfd_elf64_swap_phdr_out
120633965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
120733965Sjdpextern void bfd_elf64_swap_dyn_in
120833965Sjdp  PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
120933965Sjdpextern void bfd_elf64_swap_dyn_out
121060484Sobrien  PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
121133965Sjdpextern long bfd_elf64_slurp_symbol_table
121233965Sjdp  PARAMS ((bfd *, asymbol **, boolean));
121333965Sjdpextern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
121433965Sjdpextern int bfd_elf64_write_out_phdrs
121533965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
121677298Sobrienextern void bfd_elf64_write_relocs
121777298Sobrien  PARAMS ((bfd *, asection *, PTR));
121877298Sobrienextern boolean bfd_elf64_slurp_reloc_table
121977298Sobrien  PARAMS ((bfd *, asection *, asymbol **, boolean));
122033965Sjdpextern boolean bfd_elf64_add_dynamic_entry
122133965Sjdp  PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
122233965Sjdpextern boolean bfd_elf64_link_create_dynamic_sections
122333965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
122433965Sjdpextern Elf_Internal_Rela *_bfd_elf64_link_read_relocs
122533965Sjdp  PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
122633965Sjdp
122760484Sobrien#define bfd_elf32_link_record_dynamic_symbol \
122860484Sobrien  _bfd_elf_link_record_dynamic_symbol
122960484Sobrien#define bfd_elf64_link_record_dynamic_symbol \
123060484Sobrien  _bfd_elf_link_record_dynamic_symbol
123133965Sjdp
123260484Sobrienboolean _bfd_elf32_link_record_local_dynamic_symbol
123360484Sobrien  PARAMS ((struct bfd_link_info *, bfd *, long));
123460484Sobrienboolean _bfd_elf64_link_record_local_dynamic_symbol
123560484Sobrien  PARAMS ((struct bfd_link_info *, bfd *, long));
123660484Sobrien
123738889Sjdpextern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *));
123860484Sobrienextern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
123960484Sobrien  PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
124060484Sobrien           asection *, bfd *, char **));
124138889Sjdp
124260484Sobrienboolean _bfd_elf32_gc_sections
124360484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
124460484Sobrienboolean _bfd_elf32_gc_common_finalize_got_offsets
124560484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
124660484Sobrienboolean _bfd_elf32_gc_common_final_link
124760484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
124860484Sobrienboolean _bfd_elf32_gc_record_vtinherit
124960484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
125060484Sobrienboolean _bfd_elf32_gc_record_vtentry
125160484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
125260484Sobrien
125360484Sobrienboolean _bfd_elf64_gc_sections
125460484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
125560484Sobrienboolean _bfd_elf64_gc_common_finalize_got_offsets
125660484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
125760484Sobrienboolean _bfd_elf64_gc_common_final_link
125860484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
125960484Sobrienboolean _bfd_elf64_gc_record_vtinherit
126060484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
126160484Sobrienboolean _bfd_elf64_gc_record_vtentry
126260484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
126360484Sobrien
126433965Sjdp/* MIPS ELF specific routines.  */
126533965Sjdp
126633965Sjdpextern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
126733965Sjdpextern boolean _bfd_mips_elf_section_from_shdr
126860484Sobrien  PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
126933965Sjdpextern boolean _bfd_mips_elf_fake_sections
127033965Sjdp  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
127133965Sjdpextern boolean _bfd_mips_elf_section_from_bfd_section
127233965Sjdp  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
127333965Sjdpextern boolean _bfd_mips_elf_section_processing
127433965Sjdp  PARAMS ((bfd *, Elf_Internal_Shdr *));
127533965Sjdpextern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
127633965Sjdpextern boolean _bfd_mips_elf_read_ecoff_info
127733965Sjdp  PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
127833965Sjdpextern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
127933965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
128033965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128133965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
128233965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128333965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
128433965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128533965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
128633965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128733965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
128833965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128933965Sjdpextern boolean _bfd_mips_elf_set_private_flags PARAMS ((bfd *, flagword));
129033965Sjdpextern boolean _bfd_mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
129133965Sjdpextern boolean _bfd_mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
129233965Sjdpextern boolean _bfd_mips_elf_find_nearest_line
129333965Sjdp  PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
129433965Sjdp	   const char **, unsigned int *));
129533965Sjdpextern boolean _bfd_mips_elf_set_section_contents
129633965Sjdp  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
129760484Sobrienextern boolean _bfd_mips_elf_create_dynamic_sections
129860484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
129960484Sobrienextern boolean _bfd_mips_elf_add_symbol_hook
130060484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
130160484Sobrien	   const char **, flagword *, asection **, bfd_vma *));
130260484Sobrienextern boolean _bfd_mips_elf_adjust_dynamic_symbol
130360484Sobrien  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
130460484Sobrienextern boolean _bfd_mips_elf_finish_dynamic_symbol
130560484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
130660484Sobrien	   Elf_Internal_Sym *));
130760484Sobrienextern boolean _bfd_mips_elf_finish_dynamic_sections
130860484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
130977298Sobrienextern asection * _bfd_mips_elf_gc_mark_hook
131060484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
131160484Sobrien	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
131277298Sobrienextern boolean _bfd_mips_elf_gc_sweep_hook
131377298Sobrien  PARAMS ((bfd *, struct bfd_link_info *, asection *,
131460484Sobrien	   const Elf_Internal_Rela *));
131560484Sobrienextern boolean _bfd_mips_elf_always_size_sections
131660484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
131760484Sobrienextern boolean _bfd_mips_elf_size_dynamic_sections
131860484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
131960484Sobrienextern boolean _bfd_mips_elf_check_relocs
132060484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, asection *,
132160484Sobrien	   const Elf_Internal_Rela *));
132260484Sobrienextern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
132360484Sobrien  PARAMS ((bfd *));
132477298Sobrienextern boolean _bfd_mips_elf_print_private_bfd_data
132560484Sobrien  PARAMS ((bfd *, PTR));
132660484Sobrienextern boolean _bfd_mips_elf_link_output_symbol_hook
132760484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
132860484Sobrien	   asection *));
132960484Sobrienextern boolean _bfd_mips_elf_final_link
133060484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
133160484Sobrienextern int _bfd_mips_elf_additional_program_headers PARAMS ((bfd *));
133260484Sobrienextern boolean _bfd_mips_elf_modify_segment_map PARAMS ((bfd *));
133360484Sobrienextern boolean _bfd_mips_elf_relocate_section
133460484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
133560484Sobrien	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
133633965Sjdp
133760484Sobrien/* SH ELF specific routine.  */
133860484Sobrien
133960484Sobrienextern boolean _sh_elf_set_mach_from_flags PARAMS ((bfd *));
134060484Sobrien
134133965Sjdp#endif /* _LIBELF_H_ */
1342