elf-bfd.h revision 78828
133965Sjdp/* BFD back-end data structures for ELF files.
278828Sobrien   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
378828Sobrien   Free Software 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
3078828Sobrien/* The number of entries in a section is its size divided by the size
3178828Sobrien   of a single entry.  This is normally only applicaable to reloc and
3278828Sobrien   symbol table sections.  */
3378828Sobrien#define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
3478828Sobrien
3533965Sjdp/* If size isn't specified as 64 or 32, NAME macro should fail.  */
3633965Sjdp#ifndef NAME
3733965Sjdp#if ARCH_SIZE==64
3833965Sjdp#define NAME(x,y) CAT4(x,64,_,y)
3933965Sjdp#endif
4033965Sjdp#if ARCH_SIZE==32
4133965Sjdp#define NAME(x,y) CAT4(x,32,_,y)
4233965Sjdp#endif
4333965Sjdp#endif
4433965Sjdp
4533965Sjdp#ifndef NAME
4633965Sjdp#define NAME(x,y) CAT4(x,NOSIZE,_,y)
4733965Sjdp#endif
4833965Sjdp
4933965Sjdp#define ElfNAME(X)	NAME(Elf,X)
5033965Sjdp#define elfNAME(X)	NAME(elf,X)
5133965Sjdp
5233965Sjdp/* Information held for an ELF symbol.  The first field is the
5333965Sjdp   corresponding asymbol.  Every symbol is an ELF file is actually a
5433965Sjdp   pointer to this structure, although it is often handled as a
5533965Sjdp   pointer to an asymbol.  */
5633965Sjdp
5733965Sjdptypedef struct
5833965Sjdp{
5933965Sjdp  /* The BFD symbol.  */
6033965Sjdp  asymbol symbol;
6133965Sjdp  /* ELF symbol information.  */
6233965Sjdp  Elf_Internal_Sym internal_elf_sym;
6333965Sjdp  /* Backend specific information.  */
6433965Sjdp  union
6533965Sjdp    {
6633965Sjdp      unsigned int hppa_arg_reloc;
6733965Sjdp      PTR mips_extr;
6833965Sjdp      PTR any;
6933965Sjdp    }
7033965Sjdp  tc_data;
7133965Sjdp
7233965Sjdp  /* Version information.  This is from an Elf_Internal_Versym
7333965Sjdp     structure in a SHT_GNU_versym section.  It is zero if there is no
7433965Sjdp     version information.  */
7533965Sjdp  unsigned short version;
7633965Sjdp
7733965Sjdp} elf_symbol_type;
7833965Sjdp
7933965Sjdp/* ELF linker hash table entries.  */
8033965Sjdp
8133965Sjdpstruct elf_link_hash_entry
8233965Sjdp{
8333965Sjdp  struct bfd_link_hash_entry root;
8433965Sjdp
8533965Sjdp  /* Symbol index in output file.  This is initialized to -1.  It is
8633965Sjdp     set to -2 if the symbol is used by a reloc.  */
8733965Sjdp  long indx;
8833965Sjdp
8933965Sjdp  /* Symbol size.  */
9033965Sjdp  bfd_size_type size;
9133965Sjdp
9233965Sjdp  /* Symbol index as a dynamic symbol.  Initialized to -1, and remains
9333965Sjdp     -1 if this is not a dynamic symbol.  */
9460484Sobrien  /* ??? Note that this is consistently used as a synonym for tests
9560484Sobrien     against whether we can perform various simplifying transformations
9660484Sobrien     to the code.  (E.g. changing a pc-relative jump to a PLT entry
9760484Sobrien     into a pc-relative jump to the target function.)  That test, which
9860484Sobrien     is often relatively complex, and someplaces wrong or incomplete,
9960484Sobrien     should really be replaced by a predicate in elflink.c.
10060484Sobrien
10160484Sobrien     End result: this field -1 does not indicate that the symbol is
10260484Sobrien     not in the dynamic symbol table, but rather that the symbol is
10360484Sobrien     not visible outside this DSO.  */
10433965Sjdp  long dynindx;
10533965Sjdp
10633965Sjdp  /* String table index in .dynstr if this is a dynamic symbol.  */
10733965Sjdp  unsigned long dynstr_index;
10833965Sjdp
10933965Sjdp  /* If this is a weak defined symbol from a dynamic object, this
11033965Sjdp     field points to a defined symbol with the same value, if there is
11133965Sjdp     one.  Otherwise it is NULL.  */
11233965Sjdp  struct elf_link_hash_entry *weakdef;
11333965Sjdp
11433965Sjdp  /* If this symbol requires an entry in the global offset table, the
11560484Sobrien     processor specific backend uses this field to track usage and
11660484Sobrien     final offset.  We use a union and two names primarily to document
11760484Sobrien     the intent of any particular piece of code.  The field should be
11860484Sobrien     used as a count until size_dynamic_sections, at which point the
11960484Sobrien     contents of the .got is fixed.  Afterward, if this field is -1,
12060484Sobrien     then the symbol does not require a global offset table entry.  */
12160484Sobrien  union
12260484Sobrien    {
12360484Sobrien      bfd_signed_vma refcount;
12460484Sobrien      bfd_vma offset;
12560484Sobrien    } got;
12633965Sjdp
12760484Sobrien  /* Same, but tracks a procedure linkage table entry.  */
12860484Sobrien  union
12960484Sobrien    {
13060484Sobrien      bfd_signed_vma refcount;
13160484Sobrien      bfd_vma offset;
13260484Sobrien    } plt;
13333965Sjdp
13433965Sjdp  /* If this symbol is used in the linker created sections, the processor
13533965Sjdp     specific backend uses this field to map the field into the offset
13633965Sjdp     from the beginning of the section.  */
13733965Sjdp  struct elf_linker_section_pointers *linker_section_pointer;
13833965Sjdp
13933965Sjdp  /* Version information.  */
14033965Sjdp  union
14133965Sjdp  {
14233965Sjdp    /* This field is used for a symbol which is not defined in a
14333965Sjdp       regular object.  It points to the version information read in
14433965Sjdp       from the dynamic object.  */
14533965Sjdp    Elf_Internal_Verdef *verdef;
14633965Sjdp    /* This field is used for a symbol which is defined in a regular
14733965Sjdp       object.  It is set up in size_dynamic_sections.  It points to
14833965Sjdp       the version information we should write out for this symbol.  */
14933965Sjdp    struct bfd_elf_version_tree *vertree;
15033965Sjdp  } verinfo;
15133965Sjdp
15260484Sobrien  /* Virtual table entry use information.  This array is nominally of size
15360484Sobrien     size/sizeof(target_void_pointer), though we have to be able to assume
15460484Sobrien     and track a size while the symbol is still undefined.  It is indexed
15560484Sobrien     via offset/sizeof(target_void_pointer).  */
15660484Sobrien  size_t vtable_entries_size;
15760484Sobrien  boolean *vtable_entries_used;
15860484Sobrien
15960484Sobrien  /* Virtual table derivation info.  */
16060484Sobrien  struct elf_link_hash_entry *vtable_parent;
16160484Sobrien
16233965Sjdp  /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.).  */
16333965Sjdp  char type;
16433965Sjdp
16560484Sobrien  /* Symbol st_other value, symbol visibility.  */
16633965Sjdp  unsigned char other;
16733965Sjdp
16860484Sobrien  /* Hash value of the name computed using the ELF hash function.  */
16960484Sobrien  unsigned long elf_hash_value;
17060484Sobrien
17133965Sjdp  /* Some flags; legal values follow.  */
17233965Sjdp  unsigned short elf_link_hash_flags;
17333965Sjdp  /* Symbol is referenced by a non-shared object.  */
17433965Sjdp#define ELF_LINK_HASH_REF_REGULAR 01
17533965Sjdp  /* Symbol is defined by a non-shared object.  */
17633965Sjdp#define ELF_LINK_HASH_DEF_REGULAR 02
17733965Sjdp  /* Symbol is referenced by a shared object.  */
17833965Sjdp#define ELF_LINK_HASH_REF_DYNAMIC 04
17933965Sjdp  /* Symbol is defined by a shared object.  */
18033965Sjdp#define ELF_LINK_HASH_DEF_DYNAMIC 010
18160484Sobrien  /* Symbol has a non-weak reference from a non-shared object.  */
18260484Sobrien#define ELF_LINK_HASH_REF_REGULAR_NONWEAK 020
18333965Sjdp  /* Dynamic symbol has been adjustd.  */
18460484Sobrien#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 040
18533965Sjdp  /* Symbol needs a copy reloc.  */
18660484Sobrien#define ELF_LINK_HASH_NEEDS_COPY 0100
18733965Sjdp  /* Symbol needs a procedure linkage table entry.  */
18860484Sobrien#define ELF_LINK_HASH_NEEDS_PLT 0200
18933965Sjdp  /* Symbol appears in a non-ELF input file.  */
19060484Sobrien#define ELF_LINK_NON_ELF 0400
19133965Sjdp  /* Symbol should be marked as hidden in the version information.  */
19260484Sobrien#define ELF_LINK_HIDDEN 01000
19333965Sjdp  /* Symbol was forced to local scope due to a version script file.  */
19460484Sobrien#define ELF_LINK_FORCED_LOCAL 02000
19560484Sobrien  /* Symbol was marked during garbage collection.  */
19660484Sobrien#define ELF_LINK_HASH_MARK 04000
19760484Sobrien  /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
19860484Sobrien     not currently set by all the backends.  */
19960484Sobrien#define ELF_LINK_NON_GOT_REF 010000
20033965Sjdp};
20133965Sjdp
20260484Sobrien/* Records local symbols to be emitted in the dynamic symbol table.  */
20360484Sobrien
20460484Sobrienstruct elf_link_local_dynamic_entry
20560484Sobrien{
20660484Sobrien  struct elf_link_local_dynamic_entry *next;
20760484Sobrien
20860484Sobrien  /* The input bfd this symbol came from.  */
20960484Sobrien  bfd *input_bfd;
21060484Sobrien
21160484Sobrien  /* The index of the local symbol being copied.  */
21260484Sobrien  long input_indx;
21360484Sobrien
21460484Sobrien  /* The index in the outgoing dynamic symbol table.  */
21560484Sobrien  long dynindx;
21677298Sobrien
21760484Sobrien  /* A copy of the input symbol.  */
21860484Sobrien  Elf_Internal_Sym isym;
21960484Sobrien};
22060484Sobrien
22133965Sjdp/* ELF linker hash table.  */
22233965Sjdp
22333965Sjdpstruct elf_link_hash_table
22433965Sjdp{
22533965Sjdp  struct bfd_link_hash_table root;
22633965Sjdp  /* Whether we have created the special dynamic sections required
22733965Sjdp     when linking against or generating a shared object.  */
22833965Sjdp  boolean dynamic_sections_created;
22933965Sjdp  /* The BFD used to hold special sections created by the linker.
23033965Sjdp     This will be the first BFD found which requires these sections to
23133965Sjdp     be created.  */
23233965Sjdp  bfd *dynobj;
23333965Sjdp  /* The number of symbols found in the link which must be put into
23433965Sjdp     the .dynsym section.  */
23533965Sjdp  bfd_size_type dynsymcount;
23633965Sjdp  /* The string table of dynamic symbols, which becomes the .dynstr
23733965Sjdp     section.  */
23833965Sjdp  struct bfd_strtab_hash *dynstr;
23933965Sjdp  /* The number of buckets in the hash table in the .hash section.
24033965Sjdp     This is based on the number of dynamic symbols.  */
24133965Sjdp  bfd_size_type bucketcount;
24233965Sjdp  /* A linked list of DT_NEEDED names found in dynamic objects
24333965Sjdp     included in the link.  */
24433965Sjdp  struct bfd_link_needed_list *needed;
24533965Sjdp  /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
24633965Sjdp  struct elf_link_hash_entry *hgot;
24733965Sjdp  /* A pointer to information used to link stabs in sections.  */
24833965Sjdp  PTR stab_info;
24960484Sobrien  /* A linked list of local symbols to be added to .dynsym.  */
25060484Sobrien  struct elf_link_local_dynamic_entry *dynlocal;
25177298Sobrien  /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
25277298Sobrien     objects included in the link.  */
25377298Sobrien  struct bfd_link_needed_list *runpath;
25433965Sjdp};
25533965Sjdp
25633965Sjdp/* Look up an entry in an ELF linker hash table.  */
25733965Sjdp
25833965Sjdp#define elf_link_hash_lookup(table, string, create, copy, follow)	\
25933965Sjdp  ((struct elf_link_hash_entry *)					\
26033965Sjdp   bfd_link_hash_lookup (&(table)->root, (string), (create),		\
26133965Sjdp			 (copy), (follow)))
26233965Sjdp
26333965Sjdp/* Traverse an ELF linker hash table.  */
26433965Sjdp
26533965Sjdp#define elf_link_hash_traverse(table, func, info)			\
26633965Sjdp  (bfd_link_hash_traverse						\
26733965Sjdp   (&(table)->root,							\
26833965Sjdp    (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func),	\
26933965Sjdp    (info)))
27033965Sjdp
27133965Sjdp/* Get the ELF linker hash table from a link_info structure.  */
27233965Sjdp
27333965Sjdp#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
27433965Sjdp
27533965Sjdp/* Constant information held for an ELF backend.  */
27633965Sjdp
27733965Sjdpstruct elf_size_info {
27833965Sjdp  unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
27933965Sjdp  unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
28033965Sjdp
28160484Sobrien  /* The size of entries in the .hash section.  */
28260484Sobrien  unsigned char sizeof_hash_entry;
28360484Sobrien
28460484Sobrien  /* The number of internal relocations to allocate per external
28560484Sobrien     relocation entry.  */
28660484Sobrien  unsigned char int_rels_per_ext_rel;
28760484Sobrien
28833965Sjdp  unsigned char arch_size, file_align;
28933965Sjdp  unsigned char elfclass, ev_current;
29033965Sjdp  int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
29133965Sjdp  boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
29233965Sjdp  void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
29333965Sjdp  void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
29433965Sjdp  boolean (*slurp_reloc_table)
29533965Sjdp    PARAMS ((bfd *, asection *, asymbol **, boolean));
29633965Sjdp  long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
29733965Sjdp  void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
29860484Sobrien  void (*swap_dyn_out) PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
29960484Sobrien
30060484Sobrien  /* This function, if defined, is called to swap in a REL
30160484Sobrien     relocation.  If an external relocation corresponds to more than
30260484Sobrien     one internal relocation, then all relocations are swapped in at
30360484Sobrien     once.  */
30460484Sobrien  void (*swap_reloc_in)
30560484Sobrien    PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
30660484Sobrien
30760484Sobrien  /* This function, if defined, is called to swap out a REL
30860484Sobrien     relocation.  */
30960484Sobrien  void (*swap_reloc_out)
31060484Sobrien    PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
31160484Sobrien
31260484Sobrien  /* This function, if defined, is called to swap in a RELA
31360484Sobrien     relocation.  If an external relocation corresponds to more than
31460484Sobrien     one internal relocation, then all relocations are swapped in at
31560484Sobrien     once.  */
31660484Sobrien  void (*swap_reloca_in)
31760484Sobrien    PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
31860484Sobrien
31960484Sobrien  /* This function, if defined, is called to swap out a RELA
32060484Sobrien     relocation.  */
32160484Sobrien  void (*swap_reloca_out)
32260484Sobrien    PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
32360484Sobrien
32433965Sjdp};
32533965Sjdp
32633965Sjdp#define elf_symbol_from(ABFD,S) \
32733965Sjdp	(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
32833965Sjdp	  && (S)->the_bfd->tdata.elf_obj_data != 0) \
32933965Sjdp	 ? (elf_symbol_type *) (S) \
33033965Sjdp	 : 0)
33133965Sjdp
33233965Sjdpstruct elf_backend_data
33333965Sjdp{
33433965Sjdp  /* The architecture for this backend.  */
33533965Sjdp  enum bfd_architecture arch;
33633965Sjdp
33733965Sjdp  /* The ELF machine code (EM_xxxx) for this backend.  */
33833965Sjdp  int elf_machine_code;
33933965Sjdp
34033965Sjdp  /* The maximum page size for this backend.  */
34133965Sjdp  bfd_vma maxpagesize;
34233965Sjdp
34333965Sjdp  /* A function to translate an ELF RELA relocation to a BFD arelent
34433965Sjdp     structure.  */
34533965Sjdp  void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
34633965Sjdp				     Elf_Internal_Rela *));
34733965Sjdp
34833965Sjdp  /* A function to translate an ELF REL relocation to a BFD arelent
34933965Sjdp     structure.  */
35033965Sjdp  void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
35133965Sjdp					 Elf_Internal_Rel *));
35233965Sjdp
35333965Sjdp  /* A function to determine whether a symbol is global when
35433965Sjdp     partitioning the symbol table into local and global symbols.
35533965Sjdp     This should be NULL for most targets, in which case the correct
35633965Sjdp     thing will be done.  MIPS ELF, at least on the Irix 5, has
35733965Sjdp     special requirements.  */
35833965Sjdp  boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
35933965Sjdp
36033965Sjdp  /* The remaining functions are hooks which are called only if they
36133965Sjdp     are not NULL.  */
36233965Sjdp
36333965Sjdp  /* A function to permit a backend specific check on whether a
36433965Sjdp     particular BFD format is relevant for an object file, and to
36533965Sjdp     permit the backend to set any global information it wishes.  When
36633965Sjdp     this is called elf_elfheader is set, but anything else should be
36733965Sjdp     used with caution.  If this returns false, the check_format
36833965Sjdp     routine will return a bfd_error_wrong_format error.  */
36933965Sjdp  boolean (*elf_backend_object_p) PARAMS ((bfd *));
37033965Sjdp
37133965Sjdp  /* A function to do additional symbol processing when reading the
37233965Sjdp     ELF symbol table.  This is where any processor-specific special
37333965Sjdp     section indices are handled.  */
37433965Sjdp  void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
37533965Sjdp
37633965Sjdp  /* A function to do additional symbol processing after reading the
37733965Sjdp     entire ELF symbol table.  */
37833965Sjdp  boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
37933965Sjdp							  elf_symbol_type *,
38033965Sjdp							  unsigned int));
38133965Sjdp
38260484Sobrien   /* A function to set the type of the info field.  Processor-specific
38377298Sobrien     types should be handled here.  */
38477298Sobrien  int (*elf_backend_get_symbol_type) PARAMS (( Elf_Internal_Sym *, int));
38577298Sobrien
38633965Sjdp  /* A function to do additional processing on the ELF section header
38733965Sjdp     just before writing it out.  This is used to set the flags and
38833965Sjdp     type fields for some sections, or to actually write out data for
38933965Sjdp     unusual sections.  */
39033965Sjdp  boolean (*elf_backend_section_processing) PARAMS ((bfd *,
39133965Sjdp						     Elf32_Internal_Shdr *));
39233965Sjdp
39333965Sjdp  /* A function to handle unusual section types when creating BFD
39433965Sjdp     sections from ELF sections.  */
39533965Sjdp  boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
39633965Sjdp						    Elf32_Internal_Shdr *,
39733965Sjdp						    char *));
39833965Sjdp
39977298Sobrien  /* A function to convert machine dependent section header flags to
40077298Sobrien     BFD internal section header flags.  */
40177298Sobrien  boolean (*elf_backend_section_flags) PARAMS ((flagword *,
40277298Sobrien						Elf32_Internal_Shdr *));
40377298Sobrien
40460484Sobrien  /* A function to handle unusual program segment types when creating BFD
40577298Sobrien     sections from ELF program segments.  */
40660484Sobrien  boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *,
40760484Sobrien						    Elf32_Internal_Phdr *,
40860484Sobrien						    int));
40960484Sobrien
41033965Sjdp  /* A function to set up the ELF section header for a BFD section in
41133965Sjdp     preparation for writing it out.  This is where the flags and type
41233965Sjdp     fields are set for unusual sections.  */
41333965Sjdp  boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
41433965Sjdp						asection *));
41533965Sjdp
41633965Sjdp  /* A function to get the ELF section index for a BFD section.  If
41733965Sjdp     this returns true, the section was found.  If it is a normal ELF
41833965Sjdp     section, *RETVAL should be left unchanged.  If it is not a normal
41933965Sjdp     ELF section *RETVAL should be set to the SHN_xxxx index.  */
42033965Sjdp  boolean (*elf_backend_section_from_bfd_section)
42133965Sjdp    PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
42233965Sjdp
42333965Sjdp  /* If this field is not NULL, it is called by the add_symbols phase
42433965Sjdp     of a link just before adding a symbol to the global linker hash
42533965Sjdp     table.  It may modify any of the fields as it wishes.  If *NAME
42633965Sjdp     is set to NULL, the symbol will be skipped rather than being
42733965Sjdp     added to the hash table.  This function is responsible for
42833965Sjdp     handling all processor dependent symbol bindings and section
42933965Sjdp     indices, and must set at least *FLAGS and *SEC for each processor
43033965Sjdp     dependent case; failure to do so will cause a link error.  */
43133965Sjdp  boolean (*elf_add_symbol_hook)
43233965Sjdp    PARAMS ((bfd *abfd, struct bfd_link_info *info,
43333965Sjdp	     const Elf_Internal_Sym *, const char **name,
43433965Sjdp	     flagword *flags, asection **sec, bfd_vma *value));
43533965Sjdp
43633965Sjdp  /* If this field is not NULL, it is called by the elf_link_output_sym
43733965Sjdp     phase of a link for each symbol which will appear in the object file.  */
43833965Sjdp  boolean (*elf_backend_link_output_symbol_hook)
43933965Sjdp    PARAMS ((bfd *, struct bfd_link_info *info, const char *,
44033965Sjdp	     Elf_Internal_Sym *, asection *));
44133965Sjdp
44233965Sjdp  /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
44333965Sjdp     linker the first time it encounters a dynamic object in the link.
44433965Sjdp     This function must create any sections required for dynamic
44533965Sjdp     linking.  The ABFD argument is a dynamic object.  The .interp,
44633965Sjdp     .dynamic, .dynsym, .dynstr, and .hash functions have already been
44733965Sjdp     created, and this function may modify the section flags if
44833965Sjdp     desired.  This function will normally create the .got and .plt
44933965Sjdp     sections, but different backends have different requirements.  */
45033965Sjdp  boolean (*elf_backend_create_dynamic_sections)
45133965Sjdp    PARAMS ((bfd *abfd, struct bfd_link_info *info));
45233965Sjdp
45333965Sjdp  /* The CHECK_RELOCS function is called by the add_symbols phase of
45433965Sjdp     the ELF backend linker.  It is called once for each section with
45533965Sjdp     relocs of an object file, just after the symbols for the object
45633965Sjdp     file have been added to the global linker hash table.  The
45733965Sjdp     function must look through the relocs and do any special handling
45833965Sjdp     required.  This generally means allocating space in the global
45933965Sjdp     offset table, and perhaps allocating space for a reloc.  The
46033965Sjdp     relocs are always passed as Rela structures; if the section
46133965Sjdp     actually uses Rel structures, the r_addend field will always be
46233965Sjdp     zero.  */
46333965Sjdp  boolean (*check_relocs)
46433965Sjdp    PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
46533965Sjdp	     const Elf_Internal_Rela *relocs));
46633965Sjdp
46733965Sjdp  /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
46833965Sjdp     linker for every symbol which is defined by a dynamic object and
46933965Sjdp     referenced by a regular object.  This is called after all the
47033965Sjdp     input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
47133965Sjdp     function has been called.  The hash table entry should be
47233965Sjdp     bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
47333965Sjdp     defined in a section from a dynamic object.  Dynamic object
47433965Sjdp     sections are not included in the final link, and this function is
47533965Sjdp     responsible for changing the value to something which the rest of
47633965Sjdp     the link can deal with.  This will normally involve adding an
47733965Sjdp     entry to the .plt or .got or some such section, and setting the
47833965Sjdp     symbol to point to that.  */
47933965Sjdp  boolean (*elf_backend_adjust_dynamic_symbol)
48033965Sjdp    PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
48133965Sjdp
48233965Sjdp  /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
48333965Sjdp     after all the linker input files have been seen but before the
48433965Sjdp     section sizes have been set.  This is called after
48533965Sjdp     ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS.  */
48633965Sjdp  boolean (*elf_backend_always_size_sections)
48733965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
48833965Sjdp
48933965Sjdp  /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
49033965Sjdp     linker after all the linker input files have been seen but before
49133965Sjdp     the sections sizes have been set.  This is called after
49233965Sjdp     ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
49333965Sjdp     It is only called when linking against a dynamic object.  It must
49433965Sjdp     set the sizes of the dynamic sections, and may fill in their
49533965Sjdp     contents as well.  The generic ELF linker can handle the .dynsym,
49633965Sjdp     .dynstr and .hash sections.  This function must handle the
49733965Sjdp     .interp section and any sections created by the
49833965Sjdp     CREATE_DYNAMIC_SECTIONS entry point.  */
49933965Sjdp  boolean (*elf_backend_size_dynamic_sections)
50033965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
50133965Sjdp
50233965Sjdp  /* The RELOCATE_SECTION function is called by the ELF backend linker
50333965Sjdp     to handle the relocations for a section.
50433965Sjdp
50533965Sjdp     The relocs are always passed as Rela structures; if the section
50633965Sjdp     actually uses Rel structures, the r_addend field will always be
50733965Sjdp     zero.
50833965Sjdp
50933965Sjdp     This function is responsible for adjust the section contents as
51033965Sjdp     necessary, and (if using Rela relocs and generating a
51133965Sjdp     relocateable output file) adjusting the reloc addend as
51233965Sjdp     necessary.
51333965Sjdp
51433965Sjdp     This function does not have to worry about setting the reloc
51533965Sjdp     address or the reloc symbol index.
51633965Sjdp
51733965Sjdp     LOCAL_SYMS is a pointer to the swapped in local symbols.
51833965Sjdp
51933965Sjdp     LOCAL_SECTIONS is an array giving the section in the input file
52033965Sjdp     corresponding to the st_shndx field of each local symbol.
52133965Sjdp
52233965Sjdp     The global hash table entry for the global symbols can be found
52333965Sjdp     via elf_sym_hashes (input_bfd).
52433965Sjdp
52533965Sjdp     When generating relocateable output, this function must handle
52633965Sjdp     STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
52733965Sjdp     going to be the section symbol corresponding to the output
52833965Sjdp     section, which means that the addend must be adjusted
52933965Sjdp     accordingly.  */
53033965Sjdp  boolean (*elf_backend_relocate_section)
53133965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
53233965Sjdp	     bfd *input_bfd, asection *input_section, bfd_byte *contents,
53333965Sjdp	     Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
53433965Sjdp	     asection **local_sections));
53533965Sjdp
53633965Sjdp  /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
53733965Sjdp     linker just before it writes a symbol out to the .dynsym section.
53833965Sjdp     The processor backend may make any required adjustment to the
53933965Sjdp     symbol.  It may also take the opportunity to set contents of the
54033965Sjdp     dynamic sections.  Note that FINISH_DYNAMIC_SYMBOL is called on
54133965Sjdp     all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
54233965Sjdp     on those symbols which are defined by a dynamic object.  */
54333965Sjdp  boolean (*elf_backend_finish_dynamic_symbol)
54433965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
54533965Sjdp	     struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
54633965Sjdp
54733965Sjdp  /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
54833965Sjdp     linker just before it writes all the dynamic sections out to the
54933965Sjdp     output file.  The FINISH_DYNAMIC_SYMBOL will have been called on
55033965Sjdp     all dynamic symbols.  */
55133965Sjdp  boolean (*elf_backend_finish_dynamic_sections)
55233965Sjdp    PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
55333965Sjdp
55433965Sjdp  /* A function to do any beginning processing needed for the ELF file
55533965Sjdp     before building the ELF headers and computing file positions.  */
55633965Sjdp  void (*elf_backend_begin_write_processing)
55733965Sjdp    PARAMS ((bfd *, struct bfd_link_info *));
55833965Sjdp
55933965Sjdp  /* A function to do any final processing needed for the ELF file
56033965Sjdp     before writing it out.  The LINKER argument is true if this BFD
56133965Sjdp     was created by the ELF backend linker.  */
56233965Sjdp  void (*elf_backend_final_write_processing)
56333965Sjdp    PARAMS ((bfd *, boolean linker));
56433965Sjdp
56533965Sjdp  /* This function is called by get_program_header_size.  It should
56633965Sjdp     return the number of additional program segments which this BFD
56733965Sjdp     will need.  It should return -1 on error.  */
56833965Sjdp  int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
56933965Sjdp
57033965Sjdp  /* This function is called to modify an existing segment map in a
57133965Sjdp     backend specific fashion.  */
57233965Sjdp  boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
57333965Sjdp
57460484Sobrien  /* This function is called during section gc to discover the section a
57560484Sobrien     particular relocation refers to.  It need not be defined for hosts
57660484Sobrien     that have no queer relocation types.  */
57760484Sobrien  asection * (*gc_mark_hook)
57860484Sobrien    PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
57960484Sobrien	     struct elf_link_hash_entry *h, Elf_Internal_Sym *));
58060484Sobrien
58160484Sobrien  /* This function, if defined, is called during the sweep phase of gc
58260484Sobrien     in order that a backend might update any data structures it might
58360484Sobrien     be maintaining.  */
58460484Sobrien  boolean (*gc_sweep_hook)
58560484Sobrien    PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
58660484Sobrien	     const Elf_Internal_Rela *relocs));
58760484Sobrien
58860484Sobrien  /* This function, if defined, is called after the ELF headers have
58960484Sobrien     been created.  This allows for things like the OS and ABI versions
59060484Sobrien     to be changed.  */
59160484Sobrien  void (*elf_backend_post_process_headers)
59260484Sobrien    PARAMS ((bfd *, struct bfd_link_info *));
59360484Sobrien
59460484Sobrien  /* This function, if defined, prints a symbol to file and returns the
59560484Sobrien     name of the symbol to be printed.  It should return NULL to fall
59660484Sobrien     back to default symbol printing.  */
59760484Sobrien  const char *(*elf_backend_print_symbol_all)
59860484Sobrien    PARAMS ((bfd *, PTR, asymbol *));
59960484Sobrien
60060484Sobrien  /* This function, if defined, is called after all local symbols and
60160484Sobrien     global symbols converted to locals are emited into the symtab
60260484Sobrien     section.  It allows the backend to emit special global symbols
60360484Sobrien     not handled in the hash table.  */
60460484Sobrien  boolean (*elf_backend_output_arch_syms)
60560484Sobrien    PARAMS ((bfd *, struct bfd_link_info *, PTR,
60660484Sobrien	    boolean (*) PARAMS ((PTR, const char *,
60760484Sobrien             Elf_Internal_Sym *, asection *))));
60860484Sobrien
60960484Sobrien  /* Copy any information related to dynamic linking from a pre-existing
61060484Sobrien     symbol IND to a newly created symbol DIR.  */
61160484Sobrien  void (*elf_backend_copy_indirect_symbol)
61260484Sobrien    PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
61360484Sobrien
61460484Sobrien  /* Modify any information related to dynamic linking such that the
61560484Sobrien     symbol is not exported.  */
61660484Sobrien  void (*elf_backend_hide_symbol)
61777298Sobrien    PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
61860484Sobrien
61933965Sjdp  /* The swapping table to use when dealing with ECOFF information.
62033965Sjdp     Used for the MIPS ELF .mdebug section.  */
62133965Sjdp  const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
62233965Sjdp
62333965Sjdp  /* Alternate EM_xxxx machine codes for this backend.  */
62433965Sjdp  int elf_machine_alt1;
62533965Sjdp  int elf_machine_alt2;
62633965Sjdp
62733965Sjdp  const struct elf_size_info *s;
62833965Sjdp
62938889Sjdp  /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
63038889Sjdp     .got section */
63138889Sjdp  bfd_vma got_symbol_offset;
63238889Sjdp
63360484Sobrien  /* The size in bytes of the headers for the GOT and PLT.  This includes
63460484Sobrien     the so-called reserved entries on some systems.  */
63560484Sobrien  bfd_vma got_header_size;
63660484Sobrien  bfd_vma plt_header_size;
63760484Sobrien
63860484Sobrien  /* This is true if the linker should act like collect and gather
63960484Sobrien     global constructors and destructors by name.  This is true for
64060484Sobrien     MIPS ELF because the Irix 5 tools can not handle the .init
64160484Sobrien     section.  */
64260484Sobrien  unsigned collect : 1;
64360484Sobrien
64460484Sobrien  /* This is true if the linker should ignore changes to the type of a
64560484Sobrien     symbol.  This is true for MIPS ELF because some Irix 5 objects
64660484Sobrien     record undefined functions as STT_OBJECT although the definitions
64760484Sobrien     are STT_FUNC.  */
64860484Sobrien  unsigned type_change_ok : 1;
64960484Sobrien
65060484Sobrien  /* Whether the backend may use REL relocations.  (Some backends use
65160484Sobrien     both REL and RELA relocations, and this flag is set for those
65260484Sobrien     backends.)  */
65360484Sobrien  unsigned may_use_rel_p : 1;
65477298Sobrien
65560484Sobrien  /* Whether the backend may use RELA relocations.  (Some backends use
65660484Sobrien     both REL and RELA relocations, and this flag is set for those
65760484Sobrien     backends.)  */
65860484Sobrien  unsigned may_use_rela_p : 1;
65960484Sobrien
66060484Sobrien  /* Whether the default relocation type is RELA.  If a backend with
66160484Sobrien     this flag set wants REL relocations for a particular section,
66260484Sobrien     it must note that explicitly.  Similarly, if this flag is clear,
66377298Sobrien     and the backend wants RELA relocations for a particular
66477298Sobrien     section.  */
66560484Sobrien  unsigned default_use_rela_p : 1;
66660484Sobrien
66760484Sobrien  /* True if addresses "naturally" sign extend.  This is used when
66860484Sobrien     swapping in from Elf32 when BFD64.  */
66960484Sobrien  unsigned sign_extend_vma : 1;
67060484Sobrien
67133965Sjdp  unsigned want_got_plt : 1;
67233965Sjdp  unsigned plt_readonly : 1;
67333965Sjdp  unsigned want_plt_sym : 1;
67438889Sjdp  unsigned plt_not_loaded : 1;
67538889Sjdp  unsigned plt_alignment : 4;
67660484Sobrien  unsigned can_gc_sections : 1;
67760484Sobrien  unsigned want_dynbss : 1;
67833965Sjdp};
67933965Sjdp
68033965Sjdp/* Information stored for each BFD section in an ELF file.  This
68133965Sjdp   structure is allocated by elf_new_section_hook.  */
68233965Sjdp
68333965Sjdpstruct bfd_elf_section_data
68433965Sjdp{
68533965Sjdp  /* The ELF header for this section.  */
68633965Sjdp  Elf_Internal_Shdr this_hdr;
68733965Sjdp  /* The ELF header for the reloc section associated with this
68833965Sjdp     section, if any.  */
68933965Sjdp  Elf_Internal_Shdr rel_hdr;
69033965Sjdp  /* If there is a second reloc section associated with this section,
69133965Sjdp     as can happen on Irix 6, this field points to the header.  */
69233965Sjdp  Elf_Internal_Shdr *rel_hdr2;
69360484Sobrien  /* The number of relocations currently assigned to REL_HDR.  */
69460484Sobrien  unsigned int rel_count;
69560484Sobrien  /* The number of relocations currently assigned to REL_HDR2.  */
69660484Sobrien  unsigned int rel_count2;
69733965Sjdp  /* The ELF section number of this section.  Only used for an output
69833965Sjdp     file.  */
69933965Sjdp  int this_idx;
70060484Sobrien  /* The ELF section number of the reloc section indicated by
70160484Sobrien     REL_HDR if any.  Only used for an output file.  */
70233965Sjdp  int rel_idx;
70360484Sobrien  /* The ELF section number of the reloc section indicated by
70460484Sobrien     REL_HDR2 if any.  Only used for an output file.  */
70560484Sobrien  int rel_idx2;
70633965Sjdp  /* Used by the backend linker to store the symbol hash table entries
70733965Sjdp     associated with relocs against global symbols.  */
70833965Sjdp  struct elf_link_hash_entry **rel_hashes;
70933965Sjdp  /* A pointer to the swapped relocs.  If the section uses REL relocs,
71033965Sjdp     rather than RELA, all the r_addend fields will be zero.  This
71133965Sjdp     pointer may be NULL.  It is used by the backend linker.  */
71233965Sjdp  Elf_Internal_Rela *relocs;
71333965Sjdp  /* Used by the backend linker when generating a shared library to
71433965Sjdp     record the dynamic symbol index for a section symbol
71560484Sobrien     corresponding to this section.  A value of 0 means that there is
71660484Sobrien     no dynamic symbol for this section.  */
71733965Sjdp  long dynindx;
71833965Sjdp  /* A pointer used for .stab linking optimizations.  */
71933965Sjdp  PTR stab_info;
72033965Sjdp  /* A pointer available for the processor specific ELF backend.  */
72133965Sjdp  PTR tdata;
72260484Sobrien  /* Nonzero if this section uses RELA relocations, rather than REL.  */
72360484Sobrien  unsigned int use_rela_p:1;
72433965Sjdp};
72533965Sjdp
72633965Sjdp#define elf_section_data(sec)  ((struct bfd_elf_section_data*)sec->used_by_bfd)
72733965Sjdp
72833965Sjdp#define get_elf_backend_data(abfd) \
72933965Sjdp  ((struct elf_backend_data *) (abfd)->xvec->backend_data)
73033965Sjdp
73133965Sjdp/* Enumeration to specify the special section.  */
73233965Sjdptypedef enum elf_linker_section_enum
73333965Sjdp{
73433965Sjdp  LINKER_SECTION_UNKNOWN,		/* not used */
73533965Sjdp  LINKER_SECTION_GOT,			/* .got section for global offset pointers */
73633965Sjdp  LINKER_SECTION_PLT,			/* .plt section for generated procedure stubs */
73733965Sjdp  LINKER_SECTION_SDATA,			/* .sdata/.sbss section for PowerPC */
73833965Sjdp  LINKER_SECTION_SDATA2,		/* .sdata2/.sbss2 section for PowerPC */
73933965Sjdp  LINKER_SECTION_MAX			/* # of linker sections */
74033965Sjdp} elf_linker_section_enum_t;
74133965Sjdp
74233965Sjdp/* Sections created by the linker.  */
74333965Sjdp
74433965Sjdptypedef struct elf_linker_section
74533965Sjdp{
74633965Sjdp  char *name;				/* name of the section */
74733965Sjdp  char *rel_name;			/* name of the associated .rel{,a}. section */
74833965Sjdp  char *bss_name;			/* name of a related .bss section */
74933965Sjdp  char *sym_name;			/* name of symbol to reference this section */
75033965Sjdp  asection *section;			/* pointer to the section */
75133965Sjdp  asection *bss_section;		/* pointer to the bss section associated with this */
75233965Sjdp  asection *rel_section;		/* pointer to the relocations needed for this section */
75333965Sjdp  struct elf_link_hash_entry *sym_hash;	/* pointer to the created symbol hash value */
75433965Sjdp  bfd_vma initial_size;			/* initial size before any linker generated allocations */
75533965Sjdp  bfd_vma sym_offset;			/* offset of symbol from beginning of section */
75633965Sjdp  bfd_vma hole_size;			/* size of reserved address hole in allocation */
75733965Sjdp  bfd_vma hole_offset;			/* current offset for the hole */
75833965Sjdp  bfd_vma max_hole_offset;		/* maximum offset for the hole */
75933965Sjdp  elf_linker_section_enum_t which;	/* which section this is */
76033965Sjdp  boolean hole_written_p;		/* whether the hole has been initialized */
76138889Sjdp  unsigned int alignment;		/* alignment for the section */
76233965Sjdp  flagword flags;			/* flags to use to create the section */
76333965Sjdp} elf_linker_section_t;
76433965Sjdp
76533965Sjdp/* Linked list of allocated pointer entries.  This hangs off of the symbol lists, and
76633965Sjdp   provides allows us to return different pointers, based on different addend's.  */
76733965Sjdp
76833965Sjdptypedef struct elf_linker_section_pointers
76933965Sjdp{
77033965Sjdp  struct elf_linker_section_pointers *next;	/* next allocated pointer for this symbol */
77133965Sjdp  bfd_vma offset;				/* offset of pointer from beginning of section */
77233965Sjdp  bfd_signed_vma addend;			/* addend used */
77333965Sjdp  elf_linker_section_enum_t which;		/* which linker section this is */
77433965Sjdp  boolean written_address_p;			/* whether address was written yet */
77533965Sjdp} elf_linker_section_pointers_t;
77633965Sjdp
77733965Sjdp/* Some private data is stashed away for future use using the tdata pointer
77833965Sjdp   in the bfd structure.  */
77933965Sjdp
78033965Sjdpstruct elf_obj_tdata
78133965Sjdp{
78233965Sjdp  Elf_Internal_Ehdr elf_header[1];	/* Actual data, but ref like ptr */
78333965Sjdp  Elf_Internal_Shdr **elf_sect_ptr;
78433965Sjdp  Elf_Internal_Phdr *phdr;
78533965Sjdp  struct elf_segment_map *segment_map;
78633965Sjdp  struct bfd_strtab_hash *strtab_ptr;
78733965Sjdp  int num_locals;
78833965Sjdp  int num_globals;
78933965Sjdp  asymbol **section_syms;		/* STT_SECTION symbols for each section */
79033965Sjdp  Elf_Internal_Shdr symtab_hdr;
79133965Sjdp  Elf_Internal_Shdr shstrtab_hdr;
79233965Sjdp  Elf_Internal_Shdr strtab_hdr;
79333965Sjdp  Elf_Internal_Shdr dynsymtab_hdr;
79433965Sjdp  Elf_Internal_Shdr dynstrtab_hdr;
79533965Sjdp  Elf_Internal_Shdr dynversym_hdr;
79633965Sjdp  Elf_Internal_Shdr dynverref_hdr;
79733965Sjdp  Elf_Internal_Shdr dynverdef_hdr;
79833965Sjdp  unsigned int symtab_section, shstrtab_section;
79933965Sjdp  unsigned int strtab_section, dynsymtab_section;
80033965Sjdp  unsigned int dynversym_section, dynverdef_section, dynverref_section;
80133965Sjdp  file_ptr next_file_pos;
80260484Sobrien#if 0
80360484Sobrien  /* we don't need these inside bfd anymore, and I think
80477298Sobrien     these weren't used outside bfd.  */
80533965Sjdp  void *prstatus;			/* The raw /proc prstatus structure */
80633965Sjdp  void *prpsinfo;			/* The raw /proc prpsinfo structure */
80760484Sobrien#endif
80833965Sjdp  bfd_vma gp;				/* The gp value (MIPS only, for now) */
80933965Sjdp  unsigned int gp_size;			/* The gp size (MIPS only, for now) */
81033965Sjdp
81177298Sobrien  /* Information grabbed from an elf core file.  */
81260484Sobrien  int core_signal;
81360484Sobrien  int core_pid;
81460484Sobrien  int core_lwpid;
81560484Sobrien  char* core_program;
81660484Sobrien  char* core_command;
81760484Sobrien
81833965Sjdp  /* This is set to true if the object was created by the backend
81933965Sjdp     linker.  */
82033965Sjdp  boolean linker;
82133965Sjdp
82233965Sjdp  /* A mapping from external symbols to entries in the linker hash
82333965Sjdp     table, used when linking.  This is indexed by the symbol index
82433965Sjdp     minus the sh_info field of the symbol table header.  */
82533965Sjdp  struct elf_link_hash_entry **sym_hashes;
82633965Sjdp
82733965Sjdp  /* A mapping from local symbols to offsets into the global offset
82860484Sobrien     table, used when linking.  This is indexed by the symbol index.
82960484Sobrien     Like for the globals, we use a union and two names primarily to
83060484Sobrien     document the intent of any particular piece of code.  The field
83160484Sobrien     should be used as a count until size_dynamic_sections, at which
83260484Sobrien     point the contents of the .got is fixed.  Afterward, if an entry
83377298Sobrien     is -1, then the symbol does not require a global offset table entry.  */
83460484Sobrien  union
83560484Sobrien    {
83660484Sobrien      bfd_signed_vma *refcounts;
83760484Sobrien      bfd_vma *offsets;
83860484Sobrien    } local_got;
83933965Sjdp
84033965Sjdp  /* A mapping from local symbols to offsets into the various linker
84133965Sjdp     sections added.  This is index by the symbol index.  */
84233965Sjdp  elf_linker_section_pointers_t **linker_section_pointers;
84333965Sjdp
84433965Sjdp  /* The linker ELF emulation code needs to let the backend ELF linker
84533965Sjdp     know what filename should be used for a dynamic object if the
84633965Sjdp     dynamic object is found using a search.  The emulation code then
84733965Sjdp     sometimes needs to know what name was actually used.  Until the
84833965Sjdp     file has been added to the linker symbol table, this field holds
84933965Sjdp     the name the linker wants.  After it has been added, it holds the
85033965Sjdp     name actually used, which will be the DT_SONAME entry if there is
85133965Sjdp     one.  */
85233965Sjdp  const char *dt_name;
85333965Sjdp
85477298Sobrien  /* When a reference in a regular object is resolved by a shared
85577298Sobrien     object is loaded into via the DT_NEEDED entries by the linker
85677298Sobrien     ELF emulation code, we need to add the shared object to the
85777298Sobrien     DT_NEEDED list of the resulting binary to indicate the dependency
85877298Sobrien     as if the -l option is passed to the linker. This field holds the
85977298Sobrien     name of the loaded shared object.  */
86077298Sobrien  const char *dt_soname;
86177298Sobrien
86233965Sjdp  /* Irix 5 often screws up the symbol table, sorting local symbols
86333965Sjdp     after global symbols.  This flag is set if the symbol table in
86433965Sjdp     this BFD appears to be screwed up.  If it is, we ignore the
86533965Sjdp     sh_info field in the symbol table header, and always read all the
86633965Sjdp     symbols.  */
86733965Sjdp  boolean bad_symtab;
86833965Sjdp
86933965Sjdp  /* Records the result of `get_program_header_size'.  */
87033965Sjdp  bfd_size_type program_header_size;
87133965Sjdp
87233965Sjdp  /* Used by find_nearest_line entry point.  */
87333965Sjdp  PTR line_info;
87433965Sjdp
87533965Sjdp  /* Used by MIPS ELF find_nearest_line entry point.  The structure
87633965Sjdp     could be included directly in this one, but there's no point to
87733965Sjdp     wasting the memory just for the infrequently called
87833965Sjdp     find_nearest_line.  */
87933965Sjdp  struct mips_elf_find_line *find_line_info;
88033965Sjdp
88177298Sobrien  /* A place to stash dwarf1 info for this bfd.  */
88260484Sobrien  struct dwarf1_debug *dwarf1_find_line_info;
88360484Sobrien
88477298Sobrien  /* A place to stash dwarf2 info for this bfd.  */
88577298Sobrien  PTR dwarf2_find_line_info;
88638889Sjdp
88733965Sjdp  /* An array of stub sections indexed by symbol number, used by the
88833965Sjdp     MIPS ELF linker.  FIXME: We should figure out some way to only
88933965Sjdp     include this field for a MIPS ELF target.  */
89033965Sjdp  asection **local_stubs;
89133965Sjdp
89233965Sjdp  /* Used to determine if the e_flags field has been initialized */
89333965Sjdp  boolean flags_init;
89433965Sjdp
89533965Sjdp  /* Number of symbol version definitions we are about to emit.  */
89638889Sjdp  unsigned int cverdefs;
89733965Sjdp
89833965Sjdp  /* Number of symbol version references we are about to emit.  */
89938889Sjdp  unsigned int cverrefs;
90033965Sjdp
90133965Sjdp  /* Symbol version definitions in external objects.  */
90233965Sjdp  Elf_Internal_Verdef *verdef;
90333965Sjdp
90433965Sjdp  /* Symbol version references to external objects.  */
90533965Sjdp  Elf_Internal_Verneed *verref;
90633965Sjdp
90733965Sjdp  /* Linker sections that we are interested in.  */
90833965Sjdp  struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
90977298Sobrien
91077298Sobrien  /* The Irix 5 support uses two virtual sections, which represent
91177298Sobrien     text/data symbols defined in dynamic objects.  */
91277298Sobrien  asymbol *elf_data_symbol;
91377298Sobrien  asymbol *elf_text_symbol;
91477298Sobrien  asection *elf_data_section;
91577298Sobrien  asection *elf_text_section;
91633965Sjdp};
91733965Sjdp
91833965Sjdp#define elf_tdata(bfd)		((bfd) -> tdata.elf_obj_data)
91933965Sjdp#define elf_elfheader(bfd)	(elf_tdata(bfd) -> elf_header)
92033965Sjdp#define elf_elfsections(bfd)	(elf_tdata(bfd) -> elf_sect_ptr)
92133965Sjdp#define elf_shstrtab(bfd)	(elf_tdata(bfd) -> strtab_ptr)
92233965Sjdp#define elf_onesymtab(bfd)	(elf_tdata(bfd) -> symtab_section)
92333965Sjdp#define elf_dynsymtab(bfd)	(elf_tdata(bfd) -> dynsymtab_section)
92433965Sjdp#define elf_dynversym(bfd)	(elf_tdata(bfd) -> dynversym_section)
92533965Sjdp#define elf_dynverdef(bfd)	(elf_tdata(bfd) -> dynverdef_section)
92633965Sjdp#define elf_dynverref(bfd)	(elf_tdata(bfd) -> dynverref_section)
92733965Sjdp#define elf_num_locals(bfd)	(elf_tdata(bfd) -> num_locals)
92833965Sjdp#define elf_num_globals(bfd)	(elf_tdata(bfd) -> num_globals)
92933965Sjdp#define elf_section_syms(bfd)	(elf_tdata(bfd) -> section_syms)
93033965Sjdp#define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
93133965Sjdp#define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
93233965Sjdp#define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
93333965Sjdp#define elf_gp_size(bfd)	(elf_tdata(bfd) -> gp_size)
93433965Sjdp#define elf_sym_hashes(bfd)	(elf_tdata(bfd) -> sym_hashes)
93560484Sobrien#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
93660484Sobrien#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
93733965Sjdp#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
93833965Sjdp#define elf_dt_name(bfd)	(elf_tdata(bfd) -> dt_name)
93977298Sobrien#define elf_dt_soname(bfd)	(elf_tdata(bfd) -> dt_soname)
94033965Sjdp#define elf_bad_symtab(bfd)	(elf_tdata(bfd) -> bad_symtab)
94133965Sjdp#define elf_flags_init(bfd)	(elf_tdata(bfd) -> flags_init)
94233965Sjdp#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
94333965Sjdp
94433965Sjdpextern void _bfd_elf_swap_verdef_in
94533965Sjdp  PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
94633965Sjdpextern void _bfd_elf_swap_verdef_out
94733965Sjdp  PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
94833965Sjdpextern void _bfd_elf_swap_verdaux_in
94933965Sjdp  PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
95033965Sjdpextern void _bfd_elf_swap_verdaux_out
95133965Sjdp  PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
95233965Sjdpextern void _bfd_elf_swap_verneed_in
95333965Sjdp  PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
95433965Sjdpextern void _bfd_elf_swap_verneed_out
95533965Sjdp  PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
95633965Sjdpextern void _bfd_elf_swap_vernaux_in
95733965Sjdp  PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
95833965Sjdpextern void _bfd_elf_swap_vernaux_out
95933965Sjdp  PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
96033965Sjdpextern void _bfd_elf_swap_versym_in
96133965Sjdp  PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
96233965Sjdpextern void _bfd_elf_swap_versym_out
96333965Sjdp  PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
96433965Sjdp
96533965Sjdpextern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
96633965Sjdpextern char *bfd_elf_string_from_elf_section
96733965Sjdp  PARAMS ((bfd *, unsigned, unsigned));
96833965Sjdpextern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
96933965Sjdp
97033965Sjdpextern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
97133965Sjdpextern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
97233965Sjdp					  bfd_print_symbol_type));
97333965Sjdp#define elf_string_from_elf_strtab(abfd,strindex) \
97433965Sjdp     bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
97533965Sjdp
97633965Sjdp#define bfd_elf32_print_symbol	bfd_elf_print_symbol
97733965Sjdp#define bfd_elf64_print_symbol	bfd_elf_print_symbol
97833965Sjdp
97960484Sobrienextern unsigned long bfd_elf_hash PARAMS ((const char *));
98033965Sjdp
98133965Sjdpextern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
98233965Sjdp							    arelent *,
98333965Sjdp							    asymbol *,
98433965Sjdp							    PTR,
98533965Sjdp							    asection *,
98633965Sjdp							    bfd *,
98733965Sjdp							    char **));
98833965Sjdpextern boolean bfd_elf_mkobject PARAMS ((bfd *));
98960484Sobrienextern boolean bfd_elf_mkcorefile PARAMS ((bfd *));
99033965Sjdpextern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
99133965Sjdpextern boolean _bfd_elf_make_section_from_shdr
99233965Sjdp  PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
99360484Sobrienextern boolean _bfd_elf_make_section_from_phdr
99460484Sobrien  PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));
99533965Sjdpextern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
99633965Sjdp  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
99733965Sjdpextern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
99833965Sjdp  PARAMS ((bfd *));
99960484Sobrienextern void _bfd_elf_link_hash_copy_indirect
100060484Sobrien  PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
100160484Sobrienextern void _bfd_elf_link_hash_hide_symbol
100277298Sobrien  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
100333965Sjdpextern boolean _bfd_elf_link_hash_table_init
100433965Sjdp  PARAMS ((struct elf_link_hash_table *, bfd *,
100533965Sjdp	   struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
100633965Sjdp				       struct bfd_hash_table *,
100733965Sjdp				       const char *)));
100833965Sjdpextern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));
100933965Sjdp
101033965Sjdpextern boolean _bfd_elf_copy_private_symbol_data
101133965Sjdp  PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
101233965Sjdpextern boolean _bfd_elf_copy_private_section_data
101333965Sjdp  PARAMS ((bfd *, asection *, bfd *, asection *));
101433965Sjdpextern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
101560484Sobrienextern boolean _bfd_elf_write_corefile_contents PARAMS ((bfd *));
101633965Sjdpextern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
101733965Sjdp						       file_ptr,
101833965Sjdp						       bfd_size_type));
101933965Sjdpextern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
102033965Sjdpextern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
102133965Sjdpextern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
102233965Sjdpextern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
102333965Sjdpextern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
102433965Sjdpextern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
102533965Sjdp						  arelent **, asymbol **));
102633965Sjdpextern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
102733965Sjdpextern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **,
102833965Sjdp							 asymbol **));
102933965Sjdpextern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
103033965Sjdpextern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
103133965Sjdp					       symbol_info *));
103233965Sjdpextern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *));
103333965Sjdpextern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
103433965Sjdpextern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
103533965Sjdp						unsigned long));
103633965Sjdpextern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
103733965Sjdp						    asymbol **,
103877298Sobrien						    bfd_vma, const char **,
103977298Sobrien						    const char **,
104033965Sjdp						    unsigned int *));
104133965Sjdp#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
104233965Sjdp#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
104333965Sjdpextern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
104433965Sjdpextern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
104577298Sobrienextern boolean _bfd_elf_init_reloc_shdr
104660484Sobrien  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean));
104733965Sjdp
104833965Sjdp/* If the target doesn't have reloc handling written yet:  */
104933965Sjdpextern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
105033965Sjdp					       Elf_Internal_Rela *));
105133965Sjdp
105233965Sjdpextern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
105333965Sjdpextern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int));
105433965Sjdp
105533965Sjdpextern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
105633965Sjdp
105733965Sjdpasection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
105833965Sjdpboolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
105933965Sjdp						  struct bfd_link_info *));
106033965Sjdpstruct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
106133965Sjdpboolean
106233965Sjdp_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
106333965Sjdp					     struct elf_link_hash_entry *));
106460484Sobrienlong
106560484Sobrien_bfd_elf_link_lookup_local_dynindx PARAMS ((struct bfd_link_info *,
106660484Sobrien					    bfd *, long));
106733965Sjdpboolean
106833965Sjdp_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
106933965Sjdp						 struct bfd_link_info *));
107033965Sjdpvoid _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
107133965Sjdpfile_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
107233965Sjdp							    file_ptr,
107333965Sjdp							    boolean));
107433965Sjdp
107533965Sjdpextern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
107633965Sjdp
107733965Sjdpboolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
107833965Sjdp						  struct bfd_link_info *));
107933965Sjdpboolean _bfd_elf_create_got_section PARAMS ((bfd *,
108033965Sjdp					     struct bfd_link_info *));
108160484Sobrienunsigned long _bfd_elf_link_renumber_dynsyms PARAMS ((bfd *,
108260484Sobrien						      struct bfd_link_info *));
108333965Sjdp
108433965Sjdpelf_linker_section_t *_bfd_elf_create_linker_section
108533965Sjdp  PARAMS ((bfd *abfd,
108633965Sjdp	   struct bfd_link_info *info,
108733965Sjdp	   enum elf_linker_section_enum,
108833965Sjdp	   elf_linker_section_t *defaults));
108933965Sjdp
109033965Sjdpelf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
109133965Sjdp  PARAMS ((elf_linker_section_pointers_t *linker_pointers,
109233965Sjdp	   bfd_signed_vma addend,
109333965Sjdp	   elf_linker_section_enum_t which));
109433965Sjdp
109533965Sjdpboolean bfd_elf32_create_pointer_linker_section
109633965Sjdp  PARAMS ((bfd *abfd,
109733965Sjdp	   struct bfd_link_info *info,
109833965Sjdp	   elf_linker_section_t *lsect,
109933965Sjdp	   struct elf_link_hash_entry *h,
110033965Sjdp	   const Elf32_Internal_Rela *rel));
110133965Sjdp
110233965Sjdpbfd_vma bfd_elf32_finish_pointer_linker_section
110333965Sjdp  PARAMS ((bfd *output_abfd,
110433965Sjdp	   bfd *input_bfd,
110533965Sjdp	   struct bfd_link_info *info,
110633965Sjdp	   elf_linker_section_t *lsect,
110733965Sjdp	   struct elf_link_hash_entry *h,
110833965Sjdp	   bfd_vma relocation,
110933965Sjdp	   const Elf32_Internal_Rela *rel,
111033965Sjdp	   int relative_reloc));
111133965Sjdp
111233965Sjdpboolean bfd_elf64_create_pointer_linker_section
111333965Sjdp  PARAMS ((bfd *abfd,
111433965Sjdp	   struct bfd_link_info *info,
111533965Sjdp	   elf_linker_section_t *lsect,
111633965Sjdp	   struct elf_link_hash_entry *h,
111733965Sjdp	   const Elf64_Internal_Rela *rel));
111833965Sjdp
111933965Sjdpbfd_vma bfd_elf64_finish_pointer_linker_section
112033965Sjdp  PARAMS ((bfd *output_abfd,
112133965Sjdp	   bfd *input_bfd,
112233965Sjdp	   struct bfd_link_info *info,
112333965Sjdp	   elf_linker_section_t *lsect,
112433965Sjdp	   struct elf_link_hash_entry *h,
112533965Sjdp	   bfd_vma relocation,
112633965Sjdp	   const Elf64_Internal_Rela *rel,
112733965Sjdp	   int relative_reloc));
112833965Sjdp
112933965Sjdpboolean _bfd_elf_make_linker_section_rela
113033965Sjdp  PARAMS ((bfd *dynobj,
113133965Sjdp	   elf_linker_section_t *lsect,
113233965Sjdp	   int alignment));
113333965Sjdp
113460484Sobrienboolean _bfd_elfcore_section_from_phdr
113560484Sobrien  PARAMS ((bfd *, Elf_Internal_Phdr *, int));
113660484Sobrien
113733965Sjdpextern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
113833965Sjdpextern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
113933965Sjdpextern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
114033965Sjdpextern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
114133965Sjdpextern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
114233965Sjdp								 bfd *));
114333965Sjdp
114433965Sjdpextern boolean bfd_elf32_bfd_link_add_symbols
114533965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
114633965Sjdpextern boolean bfd_elf32_bfd_final_link
114733965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
114833965Sjdp
114933965Sjdpextern void bfd_elf32_swap_symbol_in
115033965Sjdp  PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
115133965Sjdpextern void bfd_elf32_swap_symbol_out
115233965Sjdp  PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
115333965Sjdpextern void bfd_elf32_swap_reloc_in
115433965Sjdp  PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
115533965Sjdpextern void bfd_elf32_swap_reloc_out
115633965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
115733965Sjdpextern void bfd_elf32_swap_reloca_in
115833965Sjdp  PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
115933965Sjdpextern void bfd_elf32_swap_reloca_out
116033965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
116133965Sjdpextern void bfd_elf32_swap_phdr_in
116233965Sjdp  PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
116333965Sjdpextern void bfd_elf32_swap_phdr_out
116433965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
116533965Sjdpextern void bfd_elf32_swap_dyn_in
116633965Sjdp  PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
116733965Sjdpextern void bfd_elf32_swap_dyn_out
116860484Sobrien  PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
116933965Sjdpextern long bfd_elf32_slurp_symbol_table
117033965Sjdp  PARAMS ((bfd *, asymbol **, boolean));
117133965Sjdpextern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
117233965Sjdpextern int bfd_elf32_write_out_phdrs
117333965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
117477298Sobrienextern void bfd_elf32_write_relocs
117577298Sobrien  PARAMS ((bfd *, asection *, PTR));
117677298Sobrienextern boolean bfd_elf32_slurp_reloc_table
117777298Sobrien  PARAMS ((bfd *, asection *, asymbol **, boolean));
117833965Sjdpextern boolean bfd_elf32_add_dynamic_entry
117933965Sjdp  PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
118033965Sjdpextern boolean bfd_elf32_link_create_dynamic_sections
118133965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
118233965Sjdpextern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
118333965Sjdp  PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
118433965Sjdp
118533965Sjdpextern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
118633965Sjdpextern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
118733965Sjdpextern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
118833965Sjdpextern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
118933965Sjdpextern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
119033965Sjdp								 bfd *));
119133965Sjdpextern boolean bfd_elf64_bfd_link_add_symbols
119233965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
119333965Sjdpextern boolean bfd_elf64_bfd_final_link
119433965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
119533965Sjdp
119633965Sjdpextern void bfd_elf64_swap_symbol_in
119733965Sjdp  PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
119833965Sjdpextern void bfd_elf64_swap_symbol_out
119933965Sjdp  PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
120033965Sjdpextern void bfd_elf64_swap_reloc_in
120133965Sjdp  PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
120233965Sjdpextern void bfd_elf64_swap_reloc_out
120333965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
120433965Sjdpextern void bfd_elf64_swap_reloca_in
120533965Sjdp  PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
120633965Sjdpextern void bfd_elf64_swap_reloca_out
120733965Sjdp  PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
120833965Sjdpextern void bfd_elf64_swap_phdr_in
120933965Sjdp  PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
121033965Sjdpextern void bfd_elf64_swap_phdr_out
121133965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
121233965Sjdpextern void bfd_elf64_swap_dyn_in
121333965Sjdp  PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
121433965Sjdpextern void bfd_elf64_swap_dyn_out
121560484Sobrien  PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
121633965Sjdpextern long bfd_elf64_slurp_symbol_table
121733965Sjdp  PARAMS ((bfd *, asymbol **, boolean));
121833965Sjdpextern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
121933965Sjdpextern int bfd_elf64_write_out_phdrs
122033965Sjdp  PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
122177298Sobrienextern void bfd_elf64_write_relocs
122277298Sobrien  PARAMS ((bfd *, asection *, PTR));
122377298Sobrienextern boolean bfd_elf64_slurp_reloc_table
122477298Sobrien  PARAMS ((bfd *, asection *, asymbol **, boolean));
122533965Sjdpextern boolean bfd_elf64_add_dynamic_entry
122633965Sjdp  PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
122733965Sjdpextern boolean bfd_elf64_link_create_dynamic_sections
122833965Sjdp  PARAMS ((bfd *, struct bfd_link_info *));
122933965Sjdpextern Elf_Internal_Rela *_bfd_elf64_link_read_relocs
123033965Sjdp  PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
123133965Sjdp
123260484Sobrien#define bfd_elf32_link_record_dynamic_symbol \
123360484Sobrien  _bfd_elf_link_record_dynamic_symbol
123460484Sobrien#define bfd_elf64_link_record_dynamic_symbol \
123560484Sobrien  _bfd_elf_link_record_dynamic_symbol
123633965Sjdp
123760484Sobrienboolean _bfd_elf32_link_record_local_dynamic_symbol
123860484Sobrien  PARAMS ((struct bfd_link_info *, bfd *, long));
123960484Sobrienboolean _bfd_elf64_link_record_local_dynamic_symbol
124060484Sobrien  PARAMS ((struct bfd_link_info *, bfd *, long));
124160484Sobrien
124238889Sjdpextern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *));
124360484Sobrienextern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
124460484Sobrien  PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
124560484Sobrien           asection *, bfd *, char **));
124638889Sjdp
124760484Sobrienboolean _bfd_elf32_gc_sections
124860484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
124960484Sobrienboolean _bfd_elf32_gc_common_finalize_got_offsets
125060484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
125160484Sobrienboolean _bfd_elf32_gc_common_final_link
125260484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
125360484Sobrienboolean _bfd_elf32_gc_record_vtinherit
125460484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
125560484Sobrienboolean _bfd_elf32_gc_record_vtentry
125660484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
125760484Sobrien
125860484Sobrienboolean _bfd_elf64_gc_sections
125960484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
126060484Sobrienboolean _bfd_elf64_gc_common_finalize_got_offsets
126160484Sobrien  PARAMS ((bfd *abfd, struct bfd_link_info *info));
126260484Sobrienboolean _bfd_elf64_gc_common_final_link
126360484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
126460484Sobrienboolean _bfd_elf64_gc_record_vtinherit
126560484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
126660484Sobrienboolean _bfd_elf64_gc_record_vtentry
126760484Sobrien  PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
126860484Sobrien
126933965Sjdp/* MIPS ELF specific routines.  */
127033965Sjdp
127133965Sjdpextern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
127233965Sjdpextern boolean _bfd_mips_elf_section_from_shdr
127360484Sobrien  PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
127433965Sjdpextern boolean _bfd_mips_elf_fake_sections
127533965Sjdp  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
127633965Sjdpextern boolean _bfd_mips_elf_section_from_bfd_section
127733965Sjdp  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
127833965Sjdpextern boolean _bfd_mips_elf_section_processing
127933965Sjdp  PARAMS ((bfd *, Elf_Internal_Shdr *));
128033965Sjdpextern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
128133965Sjdpextern boolean _bfd_mips_elf_read_ecoff_info
128233965Sjdp  PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
128333965Sjdpextern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
128433965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
128533965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128633965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
128733965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
128833965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
128933965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
129033965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
129133965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
129233965Sjdpextern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
129333965Sjdp  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
129433965Sjdpextern boolean _bfd_mips_elf_set_private_flags PARAMS ((bfd *, flagword));
129533965Sjdpextern boolean _bfd_mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
129633965Sjdpextern boolean _bfd_mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
129733965Sjdpextern boolean _bfd_mips_elf_find_nearest_line
129833965Sjdp  PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
129933965Sjdp	   const char **, unsigned int *));
130033965Sjdpextern boolean _bfd_mips_elf_set_section_contents
130133965Sjdp  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
130260484Sobrienextern boolean _bfd_mips_elf_create_dynamic_sections
130360484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
130460484Sobrienextern boolean _bfd_mips_elf_add_symbol_hook
130560484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
130660484Sobrien	   const char **, flagword *, asection **, bfd_vma *));
130760484Sobrienextern boolean _bfd_mips_elf_adjust_dynamic_symbol
130860484Sobrien  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
130960484Sobrienextern boolean _bfd_mips_elf_finish_dynamic_symbol
131060484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
131160484Sobrien	   Elf_Internal_Sym *));
131260484Sobrienextern boolean _bfd_mips_elf_finish_dynamic_sections
131360484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
131477298Sobrienextern asection * _bfd_mips_elf_gc_mark_hook
131560484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
131660484Sobrien	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
131777298Sobrienextern boolean _bfd_mips_elf_gc_sweep_hook
131877298Sobrien  PARAMS ((bfd *, struct bfd_link_info *, asection *,
131960484Sobrien	   const Elf_Internal_Rela *));
132060484Sobrienextern boolean _bfd_mips_elf_always_size_sections
132160484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
132260484Sobrienextern boolean _bfd_mips_elf_size_dynamic_sections
132360484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
132460484Sobrienextern boolean _bfd_mips_elf_check_relocs
132560484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, asection *,
132660484Sobrien	   const Elf_Internal_Rela *));
132760484Sobrienextern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
132860484Sobrien  PARAMS ((bfd *));
132977298Sobrienextern boolean _bfd_mips_elf_print_private_bfd_data
133060484Sobrien  PARAMS ((bfd *, PTR));
133160484Sobrienextern boolean _bfd_mips_elf_link_output_symbol_hook
133260484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
133360484Sobrien	   asection *));
133460484Sobrienextern boolean _bfd_mips_elf_final_link
133560484Sobrien  PARAMS ((bfd *, struct bfd_link_info *));
133660484Sobrienextern int _bfd_mips_elf_additional_program_headers PARAMS ((bfd *));
133760484Sobrienextern boolean _bfd_mips_elf_modify_segment_map PARAMS ((bfd *));
133860484Sobrienextern boolean _bfd_mips_elf_relocate_section
133960484Sobrien  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
134060484Sobrien	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
134133965Sjdp
134260484Sobrien/* SH ELF specific routine.  */
134360484Sobrien
134460484Sobrienextern boolean _sh_elf_set_mach_from_flags PARAMS ((bfd *));
134560484Sobrien
134633965Sjdp#endif /* _LIBELF_H_ */
1347