133965Sjdp/* BFD back-end data structures for ELF files.
289857Sobrien   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3218822Sdim   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
433965Sjdp   Written by Cygnus Support.
533965Sjdp
6130561Sobrien   This file is part of BFD, the Binary File Descriptor library.
733965Sjdp
8130561Sobrien   This program is free software; you can redistribute it and/or modify
9130561Sobrien   it under the terms of the GNU General Public License as published by
10130561Sobrien   the Free Software Foundation; either version 2 of the License, or
11130561Sobrien   (at your option) any later version.
1233965Sjdp
13130561Sobrien   This program is distributed in the hope that it will be useful,
14130561Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
15130561Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16130561Sobrien   GNU General Public License for more details.
1733965Sjdp
18130561Sobrien   You should have received a copy of the GNU General Public License
19130561Sobrien   along with this program; if not, write to the Free Software
20218822Sdim   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 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
3189857Sobrien   of a single entry.  This is normally only applicable 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
37130561Sobrien#if ARCH_SIZE == 64
38130561Sobrien#define NAME(x, y) x ## 64 ## _ ## y
3933965Sjdp#endif
40130561Sobrien#if ARCH_SIZE == 32
41130561Sobrien#define NAME(x, y) x ## 32 ## _ ## y
4233965Sjdp#endif
4333965Sjdp#endif
4433965Sjdp
4533965Sjdp#ifndef NAME
46130561Sobrien#define NAME(x, y) 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;
67130561Sobrien      void *mips_extr;
68130561Sobrien      void *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
7989857Sobrienstruct elf_strtab_hash;
80130561Sobrienstruct got_entry;
81130561Sobrienstruct plt_entry;
8289857Sobrien
8333965Sjdp/* ELF linker hash table entries.  */
8433965Sjdp
8533965Sjdpstruct elf_link_hash_entry
8633965Sjdp{
8733965Sjdp  struct bfd_link_hash_entry root;
8833965Sjdp
8933965Sjdp  /* Symbol index in output file.  This is initialized to -1.  It is
9033965Sjdp     set to -2 if the symbol is used by a reloc.  */
9133965Sjdp  long indx;
9233965Sjdp
9333965Sjdp  /* Symbol index as a dynamic symbol.  Initialized to -1, and remains
9433965Sjdp     -1 if this is not a dynamic symbol.  */
9560484Sobrien  /* ??? Note that this is consistently used as a synonym for tests
9660484Sobrien     against whether we can perform various simplifying transformations
9760484Sobrien     to the code.  (E.g. changing a pc-relative jump to a PLT entry
9860484Sobrien     into a pc-relative jump to the target function.)  That test, which
9960484Sobrien     is often relatively complex, and someplaces wrong or incomplete,
10060484Sobrien     should really be replaced by a predicate in elflink.c.
10160484Sobrien
10260484Sobrien     End result: this field -1 does not indicate that the symbol is
10360484Sobrien     not in the dynamic symbol table, but rather that the symbol is
10460484Sobrien     not visible outside this DSO.  */
10533965Sjdp  long dynindx;
10633965Sjdp
10789857Sobrien  /* If this symbol requires an entry in the global offset table, the
10889857Sobrien     processor specific backend uses this field to track usage and
109130561Sobrien     final offset.  Two schemes are supported:  The first assumes that
110130561Sobrien     a symbol may only have one GOT entry, and uses REFCOUNT until
111130561Sobrien     size_dynamic_sections, at which point the contents of the .got is
112130561Sobrien     fixed.  Afterward, if OFFSET is -1, then the symbol does not
113130561Sobrien     require a global offset table entry.  The second scheme allows
114130561Sobrien     multiple GOT entries per symbol, managed via a linked list
115130561Sobrien     pointed to by GLIST.  */
116130561Sobrien  union gotplt_union
11789857Sobrien    {
11889857Sobrien      bfd_signed_vma refcount;
11989857Sobrien      bfd_vma offset;
120130561Sobrien      struct got_entry *glist;
121130561Sobrien      struct plt_entry *plist;
12289857Sobrien    } got;
12389857Sobrien
12489857Sobrien  /* Same, but tracks a procedure linkage table entry.  */
125130561Sobrien  union gotplt_union plt;
12689857Sobrien
12789857Sobrien  /* Symbol size.  */
12889857Sobrien  bfd_size_type size;
12989857Sobrien
13033965Sjdp  /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.).  */
131218822Sdim  unsigned int type : 8;
13233965Sjdp
13360484Sobrien  /* Symbol st_other value, symbol visibility.  */
134218822Sdim  unsigned int other : 8;
13533965Sjdp
13633965Sjdp  /* Symbol is referenced by a non-shared object.  */
137218822Sdim  unsigned int ref_regular : 1;
13833965Sjdp  /* Symbol is defined by a non-shared object.  */
139218822Sdim  unsigned int def_regular : 1;
14033965Sjdp  /* Symbol is referenced by a shared object.  */
141218822Sdim  unsigned int ref_dynamic : 1;
14233965Sjdp  /* Symbol is defined by a shared object.  */
143218822Sdim  unsigned int def_dynamic : 1;
14460484Sobrien  /* Symbol has a non-weak reference from a non-shared object.  */
145218822Sdim  unsigned int ref_regular_nonweak : 1;
14633965Sjdp  /* Dynamic symbol has been adjustd.  */
147218822Sdim  unsigned int dynamic_adjusted : 1;
14833965Sjdp  /* Symbol needs a copy reloc.  */
149218822Sdim  unsigned int needs_copy : 1;
15033965Sjdp  /* Symbol needs a procedure linkage table entry.  */
151218822Sdim  unsigned int needs_plt : 1;
15233965Sjdp  /* Symbol appears in a non-ELF input file.  */
153218822Sdim  unsigned int non_elf : 1;
15433965Sjdp  /* Symbol should be marked as hidden in the version information.  */
155218822Sdim  unsigned int hidden : 1;
15633965Sjdp  /* Symbol was forced to local scope due to a version script file.  */
157218822Sdim  unsigned int forced_local : 1;
158218822Sdim  /* Symbol was forced to be dynamic due to a version script file.  */
159218822Sdim  unsigned int dynamic : 1;
16060484Sobrien  /* Symbol was marked during garbage collection.  */
161218822Sdim  unsigned int mark : 1;
16260484Sobrien  /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
16360484Sobrien     not currently set by all the backends.  */
164218822Sdim  unsigned int non_got_ref : 1;
165218822Sdim  /* Symbol has a definition in a shared object.
166218822Sdim     FIXME: There is no real need for this field if def_dynamic is never
167218822Sdim     cleared and all places that test def_dynamic also test def_regular.  */
168218822Sdim  unsigned int dynamic_def : 1;
169130561Sobrien  /* Symbol is weak in all shared objects.  */
170218822Sdim  unsigned int dynamic_weak : 1;
171130561Sobrien  /* Symbol is referenced with a relocation where C/C++ pointer equality
172130561Sobrien     matters.  */
173218822Sdim  unsigned int pointer_equality_needed : 1;
174218822Sdim
175218822Sdim  /* String table index in .dynstr if this is a dynamic symbol.  */
176218822Sdim  unsigned long dynstr_index;
177218822Sdim
178218822Sdim  union
179218822Sdim  {
180218822Sdim    /* If this is a weak defined symbol from a dynamic object, this
181218822Sdim       field points to a defined symbol with the same value, if there is
182218822Sdim       one.  Otherwise it is NULL.  */
183218822Sdim    struct elf_link_hash_entry *weakdef;
184218822Sdim
185218822Sdim    /* Hash value of the name computed using the ELF hash function.
186218822Sdim       Used part way through size_dynamic_sections, after we've finished
187218822Sdim       with weakdefs.  */
188218822Sdim    unsigned long elf_hash_value;
189218822Sdim  } u;
190218822Sdim
191218822Sdim  /* Version information.  */
192218822Sdim  union
193218822Sdim  {
194218822Sdim    /* This field is used for a symbol which is not defined in a
195218822Sdim       regular object.  It points to the version information read in
196218822Sdim       from the dynamic object.  */
197218822Sdim    Elf_Internal_Verdef *verdef;
198218822Sdim    /* This field is used for a symbol which is defined in a regular
199218822Sdim       object.  It is set up in size_dynamic_sections.  It points to
200218822Sdim       the version information we should write out for this symbol.  */
201218822Sdim    struct bfd_elf_version_tree *vertree;
202218822Sdim  } verinfo;
203218822Sdim
204218822Sdim  struct
205218822Sdim  {
206218822Sdim    /* Virtual table entry use information.  This array is nominally of size
207218822Sdim       size/sizeof(target_void_pointer), though we have to be able to assume
208218822Sdim       and track a size while the symbol is still undefined.  It is indexed
209218822Sdim       via offset/sizeof(target_void_pointer).  */
210218822Sdim    size_t size;
211218822Sdim    bfd_boolean *used;
212218822Sdim
213218822Sdim    /* Virtual table derivation info.  */
214218822Sdim    struct elf_link_hash_entry *parent;
215218822Sdim  } *vtable;
21633965Sjdp};
21733965Sjdp
218130561Sobrien/* Will references to this symbol always reference the symbol
219130561Sobrien   in this object?  STV_PROTECTED is excluded from the visibility test
220130561Sobrien   here so that function pointer comparisons work properly.  Since
221130561Sobrien   function symbols not defined in an app are set to their .plt entry,
222130561Sobrien   it's necessary for shared libs to also reference the .plt even
223130561Sobrien   though the symbol is really local to the shared lib.  */
224130561Sobrien#define SYMBOL_REFERENCES_LOCAL(INFO, H) \
225130561Sobrien  _bfd_elf_symbol_refs_local_p (H, INFO, 0)
226130561Sobrien
227130561Sobrien/* Will _calls_ to this symbol always call the version in this object?  */
228130561Sobrien#define SYMBOL_CALLS_LOCAL(INFO, H) \
229130561Sobrien  _bfd_elf_symbol_refs_local_p (H, INFO, 1)
230130561Sobrien
231218822Sdim/* Common symbols that are turned into definitions don't have the
232218822Sdim   DEF_REGULAR flag set, so they might appear to be undefined.  */
233218822Sdim#define ELF_COMMON_DEF_P(H) \
234218822Sdim  (!(H)->def_regular							\
235218822Sdim   && !(H)->def_dynamic							\
236218822Sdim   && (H)->root.type == bfd_link_hash_defined)
237218822Sdim
23860484Sobrien/* Records local symbols to be emitted in the dynamic symbol table.  */
23960484Sobrien
24060484Sobrienstruct elf_link_local_dynamic_entry
24160484Sobrien{
24260484Sobrien  struct elf_link_local_dynamic_entry *next;
24360484Sobrien
24460484Sobrien  /* The input bfd this symbol came from.  */
24560484Sobrien  bfd *input_bfd;
24660484Sobrien
24760484Sobrien  /* The index of the local symbol being copied.  */
24860484Sobrien  long input_indx;
24960484Sobrien
25060484Sobrien  /* The index in the outgoing dynamic symbol table.  */
25160484Sobrien  long dynindx;
25277298Sobrien
25360484Sobrien  /* A copy of the input symbol.  */
25460484Sobrien  Elf_Internal_Sym isym;
25560484Sobrien};
25660484Sobrien
257104834Sobrienstruct elf_link_loaded_list
258104834Sobrien{
259104834Sobrien  struct elf_link_loaded_list *next;
260104834Sobrien  bfd *abfd;
261104834Sobrien};
262104834Sobrien
263130561Sobrien/* Structures used by the eh_frame optimization code.  */
264130561Sobrienstruct eh_cie_fde
265130561Sobrien{
266218822Sdim  /* For FDEs, this points to the CIE used.  */
267218822Sdim  struct eh_cie_fde *cie_inf;
268218822Sdim  unsigned int size;
269130561Sobrien  unsigned int offset;
270130561Sobrien  unsigned int new_offset;
271130561Sobrien  unsigned char fde_encoding;
272130561Sobrien  unsigned char lsda_encoding;
273130561Sobrien  unsigned char lsda_offset;
274218822Sdim  unsigned int cie : 1;
275218822Sdim  unsigned int removed : 1;
276218822Sdim  unsigned int add_augmentation_size : 1;
277218822Sdim  unsigned int add_fde_encoding : 1;
278218822Sdim  unsigned int make_relative : 1;
279218822Sdim  unsigned int make_lsda_relative : 1;
280218822Sdim  unsigned int need_lsda_relative : 1;
281218822Sdim  unsigned int per_encoding_relative : 1;
282218822Sdim  unsigned int *set_loc;
283130561Sobrien};
284130561Sobrien
285130561Sobrienstruct eh_frame_sec_info
286130561Sobrien{
287130561Sobrien  unsigned int count;
288130561Sobrien  struct eh_cie_fde entry[1];
289130561Sobrien};
290130561Sobrien
291130561Sobrienstruct eh_frame_array_ent
292130561Sobrien{
293130561Sobrien  bfd_vma initial_loc;
294130561Sobrien  bfd_vma fde;
295130561Sobrien};
296130561Sobrien
297218822Sdimstruct htab;
298218822Sdim
299130561Sobrienstruct eh_frame_hdr_info
300130561Sobrien{
301218822Sdim  struct htab *cies;
302130561Sobrien  asection *hdr_sec;
303130561Sobrien  unsigned int fde_count, array_count;
304130561Sobrien  struct eh_frame_array_ent *array;
305130561Sobrien  /* TRUE if .eh_frame_hdr should contain the sorted search table.
306130561Sobrien     We build it if we successfully read all .eh_frame input sections
307130561Sobrien     and recognize them.  */
308130561Sobrien  bfd_boolean table;
309218822Sdim  bfd_boolean offsets_adjusted;
310130561Sobrien};
311130561Sobrien
31233965Sjdp/* ELF linker hash table.  */
31333965Sjdp
31433965Sjdpstruct elf_link_hash_table
31533965Sjdp{
31633965Sjdp  struct bfd_link_hash_table root;
31789857Sobrien
31833965Sjdp  /* Whether we have created the special dynamic sections required
31933965Sjdp     when linking against or generating a shared object.  */
320130561Sobrien  bfd_boolean dynamic_sections_created;
32189857Sobrien
322218822Sdim  /* True if this target has relocatable executables, so needs dynamic
323218822Sdim     section symbols.  */
324218822Sdim  bfd_boolean is_relocatable_executable;
325218822Sdim
32633965Sjdp  /* The BFD used to hold special sections created by the linker.
32733965Sjdp     This will be the first BFD found which requires these sections to
32833965Sjdp     be created.  */
32933965Sjdp  bfd *dynobj;
33089857Sobrien
33189857Sobrien  /* The value to use when initialising got.refcount/offset and
33289857Sobrien     plt.refcount/offset in an elf_link_hash_entry.  Set to zero when
333218822Sdim     the values are refcounts.  Set to init_got_offset/init_plt_offset
334218822Sdim     in size_dynamic_sections when the values may be offsets.  */
335218822Sdim  union gotplt_union init_got_refcount;
336218822Sdim  union gotplt_union init_plt_refcount;
33789857Sobrien
338130561Sobrien  /* The value to use for got.refcount/offset and plt.refcount/offset
339130561Sobrien     when the values may be offsets.  Normally (bfd_vma) -1.  */
340218822Sdim  union gotplt_union init_got_offset;
341218822Sdim  union gotplt_union init_plt_offset;
342130561Sobrien
34333965Sjdp  /* The number of symbols found in the link which must be put into
34433965Sjdp     the .dynsym section.  */
34533965Sjdp  bfd_size_type dynsymcount;
34689857Sobrien
34733965Sjdp  /* The string table of dynamic symbols, which becomes the .dynstr
34833965Sjdp     section.  */
34989857Sobrien  struct elf_strtab_hash *dynstr;
35089857Sobrien
35133965Sjdp  /* The number of buckets in the hash table in the .hash section.
35233965Sjdp     This is based on the number of dynamic symbols.  */
35333965Sjdp  bfd_size_type bucketcount;
35489857Sobrien
35533965Sjdp  /* A linked list of DT_NEEDED names found in dynamic objects
35633965Sjdp     included in the link.  */
35733965Sjdp  struct bfd_link_needed_list *needed;
35889857Sobrien
359218822Sdim  /* Sections in the output bfd that provides a section symbol
360218822Sdim     to be used by relocations emitted against local symbols.
361218822Sdim     Most targets will not use data_index_section.  */
362218822Sdim  asection *text_index_section;
363218822Sdim  asection *data_index_section;
364218822Sdim
36533965Sjdp  /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
36633965Sjdp  struct elf_link_hash_entry *hgot;
36789857Sobrien
368218822Sdim  /* The _PROCEDURE_LINKAGE_TABLE_ symbol.  */
369218822Sdim  struct elf_link_hash_entry *hplt;
37089857Sobrien
37189857Sobrien  /* A pointer to information used to merge SEC_MERGE sections.  */
372130561Sobrien  void *merge_info;
37389857Sobrien
374218822Sdim  /* Used to link stabs in sections.  */
375218822Sdim  struct stab_info stab_info;
376218822Sdim
377130561Sobrien  /* Used by eh_frame code when editing .eh_frame.  */
378130561Sobrien  struct eh_frame_hdr_info eh_info;
379130561Sobrien
38060484Sobrien  /* A linked list of local symbols to be added to .dynsym.  */
38160484Sobrien  struct elf_link_local_dynamic_entry *dynlocal;
38289857Sobrien
38377298Sobrien  /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
38477298Sobrien     objects included in the link.  */
38577298Sobrien  struct bfd_link_needed_list *runpath;
386104834Sobrien
387130561Sobrien  /* Cached first output tls section and size of PT_TLS segment.  */
388130561Sobrien  asection *tls_sec;
389130561Sobrien  bfd_size_type tls_size;
390104834Sobrien
391104834Sobrien  /* A linked list of BFD's loaded in the link.  */
392104834Sobrien  struct elf_link_loaded_list *loaded;
39333965Sjdp};
39433965Sjdp
39533965Sjdp/* Look up an entry in an ELF linker hash table.  */
39633965Sjdp
39733965Sjdp#define elf_link_hash_lookup(table, string, create, copy, follow)	\
39833965Sjdp  ((struct elf_link_hash_entry *)					\
39933965Sjdp   bfd_link_hash_lookup (&(table)->root, (string), (create),		\
40033965Sjdp			 (copy), (follow)))
40133965Sjdp
40233965Sjdp/* Traverse an ELF linker hash table.  */
40333965Sjdp
40433965Sjdp#define elf_link_hash_traverse(table, func, info)			\
40533965Sjdp  (bfd_link_hash_traverse						\
40633965Sjdp   (&(table)->root,							\
407130561Sobrien    (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),	\
40833965Sjdp    (info)))
40933965Sjdp
41033965Sjdp/* Get the ELF linker hash table from a link_info structure.  */
41133965Sjdp
41233965Sjdp#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
41389857Sobrien
414130561Sobrien/* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
415130561Sobrien#define is_elf_hash_table(htab)					      	\
416130561Sobrien  (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
41789857Sobrien
41889857Sobrien/* Used by bfd_section_from_r_symndx to cache a small number of local
41989857Sobrien   symbol to section mappings.  */
42089857Sobrien#define LOCAL_SYM_CACHE_SIZE 32
42189857Sobrienstruct sym_sec_cache
42289857Sobrien{
42389857Sobrien  bfd *abfd;
42489857Sobrien  unsigned long indx[LOCAL_SYM_CACHE_SIZE];
42589857Sobrien  asection *sec[LOCAL_SYM_CACHE_SIZE];
42689857Sobrien};
42733965Sjdp
42833965Sjdp/* Constant information held for an ELF backend.  */
42933965Sjdp
43033965Sjdpstruct elf_size_info {
43133965Sjdp  unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
43233965Sjdp  unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
43333965Sjdp
43460484Sobrien  /* The size of entries in the .hash section.  */
43560484Sobrien  unsigned char sizeof_hash_entry;
43660484Sobrien
43760484Sobrien  /* The number of internal relocations to allocate per external
43860484Sobrien     relocation entry.  */
43960484Sobrien  unsigned char int_rels_per_ext_rel;
440130561Sobrien  /* We use some fixed size arrays.  This should be large enough to
441130561Sobrien     handle all back-ends.  */
442130561Sobrien#define MAX_INT_RELS_PER_EXT_REL 3
44360484Sobrien
444130561Sobrien  unsigned char arch_size, log_file_align;
44533965Sjdp  unsigned char elfclass, ev_current;
44689857Sobrien  int (*write_out_phdrs)
447130561Sobrien    (bfd *, const Elf_Internal_Phdr *, unsigned int);
448130561Sobrien  bfd_boolean
449130561Sobrien    (*write_shdrs_and_ehdr) (bfd *);
45089857Sobrien  void (*write_relocs)
451130561Sobrien    (bfd *, asection *, void *);
452218822Sdim  bfd_boolean (*swap_symbol_in)
453130561Sobrien    (bfd *, const void *, const void *, Elf_Internal_Sym *);
45489857Sobrien  void (*swap_symbol_out)
455130561Sobrien    (bfd *, const Elf_Internal_Sym *, void *, void *);
456130561Sobrien  bfd_boolean (*slurp_reloc_table)
457130561Sobrien    (bfd *, asection *, asymbol **, bfd_boolean);
45889857Sobrien  long (*slurp_symbol_table)
459130561Sobrien    (bfd *, asymbol **, bfd_boolean);
46089857Sobrien  void (*swap_dyn_in)
461130561Sobrien    (bfd *, const void *, Elf_Internal_Dyn *);
46289857Sobrien  void (*swap_dyn_out)
463130561Sobrien    (bfd *, const Elf_Internal_Dyn *, void *);
46460484Sobrien
465130561Sobrien  /* This function is called to swap in a REL relocation.  If an
466130561Sobrien     external relocation corresponds to more than one internal
467130561Sobrien     relocation, then all relocations are swapped in at once.  */
46860484Sobrien  void (*swap_reloc_in)
469130561Sobrien    (bfd *, const bfd_byte *, Elf_Internal_Rela *);
47060484Sobrien
471130561Sobrien  /* This function is called to swap out a REL relocation.  */
47260484Sobrien  void (*swap_reloc_out)
473130561Sobrien    (bfd *, const Elf_Internal_Rela *, bfd_byte *);
47460484Sobrien
475130561Sobrien  /* This function is called to swap in a RELA relocation.  If an
476130561Sobrien     external relocation corresponds to more than one internal
477130561Sobrien     relocation, then all relocations are swapped in at once.  */
47860484Sobrien  void (*swap_reloca_in)
479130561Sobrien    (bfd *, const bfd_byte *, Elf_Internal_Rela *);
48060484Sobrien
481130561Sobrien  /* This function is called to swap out a RELA relocation.  */
48260484Sobrien  void (*swap_reloca_out)
483130561Sobrien    (bfd *, const Elf_Internal_Rela *, bfd_byte *);
48433965Sjdp};
48533965Sjdp
48633965Sjdp#define elf_symbol_from(ABFD,S) \
48733965Sjdp	(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
48833965Sjdp	  && (S)->the_bfd->tdata.elf_obj_data != 0) \
48933965Sjdp	 ? (elf_symbol_type *) (S) \
49033965Sjdp	 : 0)
49133965Sjdp
49289857Sobrienenum elf_reloc_type_class {
49389857Sobrien  reloc_class_normal,
49489857Sobrien  reloc_class_relative,
49589857Sobrien  reloc_class_plt,
49689857Sobrien  reloc_class_copy
49789857Sobrien};
49889857Sobrien
49989857Sobrienstruct elf_reloc_cookie
50089857Sobrien{
50189857Sobrien  Elf_Internal_Rela *rels, *rel, *relend;
502104834Sobrien  Elf_Internal_Sym *locsyms;
50389857Sobrien  bfd *abfd;
50489857Sobrien  size_t locsymcount;
50589857Sobrien  size_t extsymoff;
50689857Sobrien  struct elf_link_hash_entry **sym_hashes;
507130561Sobrien  int r_sym_shift;
508130561Sobrien  bfd_boolean bad_symtab;
50989857Sobrien};
51089857Sobrien
511104834Sobrien/* The level of IRIX compatibility we're striving for.  */
512104834Sobrien
513104834Sobrientypedef enum {
514104834Sobrien  ict_none,
515104834Sobrien  ict_irix5,
516104834Sobrien  ict_irix6
517104834Sobrien} irix_compat_t;
518104834Sobrien
519130561Sobrien/* Mapping of ELF section names and types.  */
520130561Sobrienstruct bfd_elf_special_section
521130561Sobrien{
522130561Sobrien  const char *prefix;
523130561Sobrien  int prefix_length;
524130561Sobrien  /* 0 means name must match PREFIX exactly.
525130561Sobrien     -1 means name must start with PREFIX followed by an arbitrary string.
526130561Sobrien     -2 means name must match PREFIX exactly or consist of PREFIX followed
527130561Sobrien     by a dot then anything.
528130561Sobrien     > 0 means name must start with the first PREFIX_LENGTH chars of
529130561Sobrien     PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX.  */
530130561Sobrien  int suffix_length;
531130561Sobrien  int type;
532130561Sobrien  int attr;
533130561Sobrien};
534130561Sobrien
535218822Sdimenum action_discarded
536218822Sdim  {
537218822Sdim    COMPLAIN = 1,
538218822Sdim    PRETEND = 2
539218822Sdim  };
540218822Sdim
541218822Sdimtypedef asection * (*elf_gc_mark_hook_fn)
542218822Sdim  (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
543218822Sdim   struct elf_link_hash_entry *, Elf_Internal_Sym *);
544218822Sdim
54533965Sjdpstruct elf_backend_data
54633965Sjdp{
54733965Sjdp  /* The architecture for this backend.  */
54833965Sjdp  enum bfd_architecture arch;
54933965Sjdp
55033965Sjdp  /* The ELF machine code (EM_xxxx) for this backend.  */
55133965Sjdp  int elf_machine_code;
55233965Sjdp
553218822Sdim  /* EI_OSABI. */
554218822Sdim  int elf_osabi;
555218822Sdim
55633965Sjdp  /* The maximum page size for this backend.  */
55733965Sjdp  bfd_vma maxpagesize;
55833965Sjdp
559218822Sdim  /* The minimum page size for this backend.  An input object will not be
560218822Sdim     considered page aligned unless its sections are correctly aligned for
561218822Sdim     pages at least this large.  May be smaller than maxpagesize.  */
562218822Sdim  bfd_vma minpagesize;
563218822Sdim
564218822Sdim  /* The common page size for this backend.  */
565218822Sdim  bfd_vma commonpagesize;
566218822Sdim
567218822Sdim  /* The BFD flags applied to sections created for dynamic linking.  */
568218822Sdim  flagword dynamic_sec_flags;
569218822Sdim
57033965Sjdp  /* A function to translate an ELF RELA relocation to a BFD arelent
57133965Sjdp     structure.  */
57289857Sobrien  void (*elf_info_to_howto)
573130561Sobrien    (bfd *, arelent *, Elf_Internal_Rela *);
57433965Sjdp
57533965Sjdp  /* A function to translate an ELF REL relocation to a BFD arelent
57633965Sjdp     structure.  */
57789857Sobrien  void (*elf_info_to_howto_rel)
578130561Sobrien    (bfd *, arelent *, Elf_Internal_Rela *);
57933965Sjdp
58033965Sjdp  /* A function to determine whether a symbol is global when
58133965Sjdp     partitioning the symbol table into local and global symbols.
58233965Sjdp     This should be NULL for most targets, in which case the correct
58333965Sjdp     thing will be done.  MIPS ELF, at least on the Irix 5, has
58433965Sjdp     special requirements.  */
585130561Sobrien  bfd_boolean (*elf_backend_sym_is_global)
586130561Sobrien    (bfd *, asymbol *);
58733965Sjdp
58833965Sjdp  /* The remaining functions are hooks which are called only if they
58933965Sjdp     are not NULL.  */
59033965Sjdp
59133965Sjdp  /* A function to permit a backend specific check on whether a
59233965Sjdp     particular BFD format is relevant for an object file, and to
59333965Sjdp     permit the backend to set any global information it wishes.  When
59433965Sjdp     this is called elf_elfheader is set, but anything else should be
595130561Sobrien     used with caution.  If this returns FALSE, the check_format
59633965Sjdp     routine will return a bfd_error_wrong_format error.  */
597130561Sobrien  bfd_boolean (*elf_backend_object_p)
598130561Sobrien    (bfd *);
59933965Sjdp
60033965Sjdp  /* A function to do additional symbol processing when reading the
60133965Sjdp     ELF symbol table.  This is where any processor-specific special
60233965Sjdp     section indices are handled.  */
60389857Sobrien  void (*elf_backend_symbol_processing)
604130561Sobrien    (bfd *, asymbol *);
60533965Sjdp
60633965Sjdp  /* A function to do additional symbol processing after reading the
60733965Sjdp     entire ELF symbol table.  */
608130561Sobrien  bfd_boolean (*elf_backend_symbol_table_processing)
609130561Sobrien    (bfd *, elf_symbol_type *, unsigned int);
61033965Sjdp
611218822Sdim  /* A function to set the type of the info field.  Processor-specific
61277298Sobrien     types should be handled here.  */
61389857Sobrien  int (*elf_backend_get_symbol_type)
614130561Sobrien    (Elf_Internal_Sym *, int);
61577298Sobrien
616218822Sdim  /* A function to return the linker hash table entry of a symbol that
617218822Sdim     might be satisfied by an archive symbol.  */
618218822Sdim  struct elf_link_hash_entry * (*elf_backend_archive_symbol_lookup)
619218822Sdim    (bfd *, struct bfd_link_info *, const char *);
620218822Sdim
621130561Sobrien  /* Return true if local section symbols should have a non-null st_name.
622130561Sobrien     NULL implies false.  */
623130561Sobrien  bfd_boolean (*elf_backend_name_local_section_symbols)
624130561Sobrien    (bfd *);
625130561Sobrien
62633965Sjdp  /* A function to do additional processing on the ELF section header
62733965Sjdp     just before writing it out.  This is used to set the flags and
62833965Sjdp     type fields for some sections, or to actually write out data for
62933965Sjdp     unusual sections.  */
630130561Sobrien  bfd_boolean (*elf_backend_section_processing)
631130561Sobrien    (bfd *, Elf_Internal_Shdr *);
63233965Sjdp
63333965Sjdp  /* A function to handle unusual section types when creating BFD
63433965Sjdp     sections from ELF sections.  */
635130561Sobrien  bfd_boolean (*elf_backend_section_from_shdr)
636218822Sdim    (bfd *, Elf_Internal_Shdr *, const char *, int);
63733965Sjdp
638218822Sdim  /* A function to convert machine dependent ELF section header flags to
63977298Sobrien     BFD internal section header flags.  */
640130561Sobrien  bfd_boolean (*elf_backend_section_flags)
641218822Sdim    (flagword *, const Elf_Internal_Shdr *);
64277298Sobrien
643218822Sdim  /* A function that returns a struct containing ELF section flags and
644218822Sdim     type for the given BFD section.   */
645218822Sdim  const struct bfd_elf_special_section * (*get_sec_type_attr)
646218822Sdim    (bfd *, asection *);
647218822Sdim
64860484Sobrien  /* A function to handle unusual program segment types when creating BFD
64977298Sobrien     sections from ELF program segments.  */
650130561Sobrien  bfd_boolean (*elf_backend_section_from_phdr)
651218822Sdim    (bfd *, Elf_Internal_Phdr *, int, const char *);
65260484Sobrien
65333965Sjdp  /* A function to set up the ELF section header for a BFD section in
65433965Sjdp     preparation for writing it out.  This is where the flags and type
65533965Sjdp     fields are set for unusual sections.  */
656130561Sobrien  bfd_boolean (*elf_backend_fake_sections)
657130561Sobrien    (bfd *, Elf_Internal_Shdr *, asection *);
65833965Sjdp
65933965Sjdp  /* A function to get the ELF section index for a BFD section.  If
660130561Sobrien     this returns TRUE, the section was found.  If it is a normal ELF
66133965Sjdp     section, *RETVAL should be left unchanged.  If it is not a normal
66233965Sjdp     ELF section *RETVAL should be set to the SHN_xxxx index.  */
663130561Sobrien  bfd_boolean (*elf_backend_section_from_bfd_section)
664130561Sobrien    (bfd *, asection *, int *retval);
66533965Sjdp
66633965Sjdp  /* If this field is not NULL, it is called by the add_symbols phase
66733965Sjdp     of a link just before adding a symbol to the global linker hash
66833965Sjdp     table.  It may modify any of the fields as it wishes.  If *NAME
66933965Sjdp     is set to NULL, the symbol will be skipped rather than being
67033965Sjdp     added to the hash table.  This function is responsible for
67133965Sjdp     handling all processor dependent symbol bindings and section
67233965Sjdp     indices, and must set at least *FLAGS and *SEC for each processor
67333965Sjdp     dependent case; failure to do so will cause a link error.  */
674130561Sobrien  bfd_boolean (*elf_add_symbol_hook)
675130561Sobrien    (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *,
676130561Sobrien     const char **name, flagword *flags, asection **sec, bfd_vma *value);
67733965Sjdp
67833965Sjdp  /* If this field is not NULL, it is called by the elf_link_output_sym
67933965Sjdp     phase of a link for each symbol which will appear in the object file.  */
680130561Sobrien  bfd_boolean (*elf_backend_link_output_symbol_hook)
681130561Sobrien    (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
682130561Sobrien     asection *, struct elf_link_hash_entry *);
68333965Sjdp
68433965Sjdp  /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
68533965Sjdp     linker the first time it encounters a dynamic object in the link.
68633965Sjdp     This function must create any sections required for dynamic
68733965Sjdp     linking.  The ABFD argument is a dynamic object.  The .interp,
68833965Sjdp     .dynamic, .dynsym, .dynstr, and .hash functions have already been
68933965Sjdp     created, and this function may modify the section flags if
69033965Sjdp     desired.  This function will normally create the .got and .plt
69133965Sjdp     sections, but different backends have different requirements.  */
692130561Sobrien  bfd_boolean (*elf_backend_create_dynamic_sections)
693130561Sobrien    (bfd *abfd, struct bfd_link_info *info);
69433965Sjdp
695218822Sdim  /* When creating a shared library, determine whether to omit the
696218822Sdim     dynamic symbol for the section.  */
697218822Sdim  bfd_boolean (*elf_backend_omit_section_dynsym)
698218822Sdim    (bfd *output_bfd, struct bfd_link_info *info, asection *osec);
699218822Sdim
700218822Sdim  /* Return TRUE if relocations of targets are compatible to the extent
701218822Sdim     that CHECK_RELOCS will properly process them.  PR 4424.  */
702218822Sdim  bfd_boolean (*relocs_compatible) (const bfd_target *, const bfd_target *);
703218822Sdim
70433965Sjdp  /* The CHECK_RELOCS function is called by the add_symbols phase of
70533965Sjdp     the ELF backend linker.  It is called once for each section with
70633965Sjdp     relocs of an object file, just after the symbols for the object
70733965Sjdp     file have been added to the global linker hash table.  The
70833965Sjdp     function must look through the relocs and do any special handling
70933965Sjdp     required.  This generally means allocating space in the global
71033965Sjdp     offset table, and perhaps allocating space for a reloc.  The
71133965Sjdp     relocs are always passed as Rela structures; if the section
71233965Sjdp     actually uses Rel structures, the r_addend field will always be
71333965Sjdp     zero.  */
714130561Sobrien  bfd_boolean (*check_relocs)
715130561Sobrien    (bfd *abfd, struct bfd_link_info *info, asection *o,
716130561Sobrien     const Elf_Internal_Rela *relocs);
71733965Sjdp
718218822Sdim  /* The CHECK_DIRECTIVES function is called once per input file by
719218822Sdim     the add_symbols phase of the ELF backend linker.  The function
720218822Sdim     must inspect the bfd and create any additional symbols according
721218822Sdim     to any custom directives in the bfd.  */
722218822Sdim  bfd_boolean (*check_directives)
723218822Sdim    (bfd *abfd, struct bfd_link_info *info);
724218822Sdim
725218822Sdim  /* The AS_NEEDED_CLEANUP function is called once per --as-needed
726218822Sdim     input file that was not needed by the add_symbols phase of the
727218822Sdim     ELF backend linker.  The function must undo any target specific
728218822Sdim     changes in the symbol hash table.  */
729218822Sdim  bfd_boolean (*as_needed_cleanup)
730218822Sdim    (bfd *abfd, struct bfd_link_info *info);
731218822Sdim
73233965Sjdp  /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
73333965Sjdp     linker for every symbol which is defined by a dynamic object and
73433965Sjdp     referenced by a regular object.  This is called after all the
73533965Sjdp     input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
73633965Sjdp     function has been called.  The hash table entry should be
73733965Sjdp     bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
73833965Sjdp     defined in a section from a dynamic object.  Dynamic object
73933965Sjdp     sections are not included in the final link, and this function is
74033965Sjdp     responsible for changing the value to something which the rest of
74133965Sjdp     the link can deal with.  This will normally involve adding an
74233965Sjdp     entry to the .plt or .got or some such section, and setting the
74333965Sjdp     symbol to point to that.  */
744130561Sobrien  bfd_boolean (*elf_backend_adjust_dynamic_symbol)
745130561Sobrien    (struct bfd_link_info *info, struct elf_link_hash_entry *h);
74633965Sjdp
74733965Sjdp  /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
74833965Sjdp     after all the linker input files have been seen but before the
74933965Sjdp     section sizes have been set.  This is called after
75033965Sjdp     ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS.  */
751130561Sobrien  bfd_boolean (*elf_backend_always_size_sections)
752130561Sobrien    (bfd *output_bfd, struct bfd_link_info *info);
75333965Sjdp
75433965Sjdp  /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
75533965Sjdp     linker after all the linker input files have been seen but before
75633965Sjdp     the sections sizes have been set.  This is called after
75733965Sjdp     ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
75833965Sjdp     It is only called when linking against a dynamic object.  It must
75933965Sjdp     set the sizes of the dynamic sections, and may fill in their
76033965Sjdp     contents as well.  The generic ELF linker can handle the .dynsym,
76133965Sjdp     .dynstr and .hash sections.  This function must handle the
76233965Sjdp     .interp section and any sections created by the
76333965Sjdp     CREATE_DYNAMIC_SECTIONS entry point.  */
764130561Sobrien  bfd_boolean (*elf_backend_size_dynamic_sections)
765130561Sobrien    (bfd *output_bfd, struct bfd_link_info *info);
76633965Sjdp
767218822Sdim  /* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
768218822Sdim     we keep to use as a base for relocs and symbols.  */
769218822Sdim  void (*elf_backend_init_index_section)
770218822Sdim    (bfd *output_bfd, struct bfd_link_info *info);
771218822Sdim
77233965Sjdp  /* The RELOCATE_SECTION function is called by the ELF backend linker
77333965Sjdp     to handle the relocations for a section.
77433965Sjdp
77533965Sjdp     The relocs are always passed as Rela structures; if the section
77633965Sjdp     actually uses Rel structures, the r_addend field will always be
77733965Sjdp     zero.
77833965Sjdp
77933965Sjdp     This function is responsible for adjust the section contents as
78033965Sjdp     necessary, and (if using Rela relocs and generating a
781130561Sobrien     relocatable output file) adjusting the reloc addend as
78233965Sjdp     necessary.
78333965Sjdp
78433965Sjdp     This function does not have to worry about setting the reloc
78533965Sjdp     address or the reloc symbol index.
78633965Sjdp
78733965Sjdp     LOCAL_SYMS is a pointer to the swapped in local symbols.
78833965Sjdp
78933965Sjdp     LOCAL_SECTIONS is an array giving the section in the input file
79033965Sjdp     corresponding to the st_shndx field of each local symbol.
79133965Sjdp
79233965Sjdp     The global hash table entry for the global symbols can be found
79333965Sjdp     via elf_sym_hashes (input_bfd).
79433965Sjdp
795130561Sobrien     When generating relocatable output, this function must handle
79633965Sjdp     STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
79733965Sjdp     going to be the section symbol corresponding to the output
79833965Sjdp     section, which means that the addend must be adjusted
799218822Sdim     accordingly.
800218822Sdim
801218822Sdim     Returns FALSE on error, TRUE on success, 2 if successful and
802218822Sdim     relocations should be written for this section.  */
803218822Sdim  int (*elf_backend_relocate_section)
804130561Sobrien    (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd,
805130561Sobrien     asection *input_section, bfd_byte *contents, Elf_Internal_Rela *relocs,
806130561Sobrien     Elf_Internal_Sym *local_syms, asection **local_sections);
80733965Sjdp
80833965Sjdp  /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
80933965Sjdp     linker just before it writes a symbol out to the .dynsym section.
81033965Sjdp     The processor backend may make any required adjustment to the
81133965Sjdp     symbol.  It may also take the opportunity to set contents of the
81233965Sjdp     dynamic sections.  Note that FINISH_DYNAMIC_SYMBOL is called on
81333965Sjdp     all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
81433965Sjdp     on those symbols which are defined by a dynamic object.  */
815130561Sobrien  bfd_boolean (*elf_backend_finish_dynamic_symbol)
816130561Sobrien    (bfd *output_bfd, struct bfd_link_info *info,
817130561Sobrien     struct elf_link_hash_entry *h, Elf_Internal_Sym *sym);
81833965Sjdp
81933965Sjdp  /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
82033965Sjdp     linker just before it writes all the dynamic sections out to the
82133965Sjdp     output file.  The FINISH_DYNAMIC_SYMBOL will have been called on
82233965Sjdp     all dynamic symbols.  */
823130561Sobrien  bfd_boolean (*elf_backend_finish_dynamic_sections)
824130561Sobrien    (bfd *output_bfd, struct bfd_link_info *info);
82533965Sjdp
82633965Sjdp  /* A function to do any beginning processing needed for the ELF file
82733965Sjdp     before building the ELF headers and computing file positions.  */
82833965Sjdp  void (*elf_backend_begin_write_processing)
829130561Sobrien    (bfd *, struct bfd_link_info *);
83033965Sjdp
83133965Sjdp  /* A function to do any final processing needed for the ELF file
832130561Sobrien     before writing it out.  The LINKER argument is TRUE if this BFD
83333965Sjdp     was created by the ELF backend linker.  */
83433965Sjdp  void (*elf_backend_final_write_processing)
835130561Sobrien    (bfd *, bfd_boolean linker);
83633965Sjdp
83733965Sjdp  /* This function is called by get_program_header_size.  It should
83833965Sjdp     return the number of additional program segments which this BFD
83933965Sjdp     will need.  It should return -1 on error.  */
84089857Sobrien  int (*elf_backend_additional_program_headers)
841218822Sdim    (bfd *, struct bfd_link_info *);
84233965Sjdp
84333965Sjdp  /* This function is called to modify an existing segment map in a
84433965Sjdp     backend specific fashion.  */
845130561Sobrien  bfd_boolean (*elf_backend_modify_segment_map)
846130561Sobrien    (bfd *, struct bfd_link_info *);
84733965Sjdp
848218822Sdim  /* This function is called to modify program headers just before
849218822Sdim     they are written.  */
850218822Sdim  bfd_boolean (*elf_backend_modify_program_headers)
851218822Sdim    (bfd *, struct bfd_link_info *);
852218822Sdim
853218822Sdim  /* This function is called during section garbage collection to
854218822Sdim     mark sections that define global symbols.  */
855218822Sdim  bfd_boolean (*gc_mark_dynamic_ref)
856218822Sdim    (struct elf_link_hash_entry *h, void *inf);
857218822Sdim
85860484Sobrien  /* This function is called during section gc to discover the section a
859104834Sobrien     particular relocation refers to.  */
860218822Sdim  elf_gc_mark_hook_fn gc_mark_hook;
86160484Sobrien
862218822Sdim  /* This function, if defined, is called after the first gc marking pass
863218822Sdim     to allow the backend to mark additional sections.  */
864218822Sdim  bfd_boolean (*gc_mark_extra_sections)
865218822Sdim    (struct bfd_link_info *info, elf_gc_mark_hook_fn gc_mark_hook);
866218822Sdim
86760484Sobrien  /* This function, if defined, is called during the sweep phase of gc
86860484Sobrien     in order that a backend might update any data structures it might
86960484Sobrien     be maintaining.  */
870130561Sobrien  bfd_boolean (*gc_sweep_hook)
871130561Sobrien    (bfd *abfd, struct bfd_link_info *info, asection *o,
872130561Sobrien     const Elf_Internal_Rela *relocs);
87360484Sobrien
87460484Sobrien  /* This function, if defined, is called after the ELF headers have
87560484Sobrien     been created.  This allows for things like the OS and ABI versions
87660484Sobrien     to be changed.  */
87760484Sobrien  void (*elf_backend_post_process_headers)
878130561Sobrien    (bfd *, struct bfd_link_info *);
87960484Sobrien
88060484Sobrien  /* This function, if defined, prints a symbol to file and returns the
88160484Sobrien     name of the symbol to be printed.  It should return NULL to fall
88260484Sobrien     back to default symbol printing.  */
88360484Sobrien  const char *(*elf_backend_print_symbol_all)
884130561Sobrien    (bfd *, void *, asymbol *);
88560484Sobrien
88660484Sobrien  /* This function, if defined, is called after all local symbols and
887130561Sobrien     global symbols converted to locals are emitted into the symtab
888218822Sdim     section.  It allows the backend to emit special local symbols
88960484Sobrien     not handled in the hash table.  */
890218822Sdim  bfd_boolean (*elf_backend_output_arch_local_syms)
891218822Sdim    (bfd *, struct bfd_link_info *, void *,
892218822Sdim     bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
893218822Sdim		      struct elf_link_hash_entry *));
894218822Sdim
895218822Sdim  /* This function, if defined, is called after all symbols are emitted
896218822Sdim     into the symtab section.  It allows the backend to emit special
897218822Sdim     global symbols not handled in the hash table.  */
898130561Sobrien  bfd_boolean (*elf_backend_output_arch_syms)
899130561Sobrien    (bfd *, struct bfd_link_info *, void *,
900130561Sobrien     bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
901130561Sobrien		      struct elf_link_hash_entry *));
90260484Sobrien
903104834Sobrien  /* Copy any information related to dynamic linking from a pre-existing
90489857Sobrien     symbol to a newly created symbol.  Also called to copy flags and
90589857Sobrien     other back-end info to a weakdef, in which case the symbol is not
90689857Sobrien     newly created and plt/got refcounts and dynamic indices should not
90789857Sobrien     be copied.  */
90860484Sobrien  void (*elf_backend_copy_indirect_symbol)
909218822Sdim    (struct bfd_link_info *, struct elf_link_hash_entry *,
910130561Sobrien     struct elf_link_hash_entry *);
91160484Sobrien
91260484Sobrien  /* Modify any information related to dynamic linking such that the
91360484Sobrien     symbol is not exported.  */
91460484Sobrien  void (*elf_backend_hide_symbol)
915130561Sobrien    (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
91660484Sobrien
917218822Sdim  /* A function to do additional symbol fixup, called by
918218822Sdim     _bfd_elf_fix_symbol_flags.  */
919218822Sdim  bfd_boolean (*elf_backend_fixup_symbol)
920218822Sdim    (struct bfd_link_info *, struct elf_link_hash_entry *);
921218822Sdim
922130561Sobrien  /* Merge the backend specific symbol attribute.  */
923130561Sobrien  void (*elf_backend_merge_symbol_attribute)
924130561Sobrien    (struct elf_link_hash_entry *, const Elf_Internal_Sym *, bfd_boolean,
925130561Sobrien     bfd_boolean);
926130561Sobrien
927218822Sdim  /* Decide whether an undefined symbol is special and can be ignored.
928218822Sdim     This is the case for OPTIONAL symbols on IRIX.  */
929218822Sdim  bfd_boolean (*elf_backend_ignore_undef_symbol)
930218822Sdim    (struct elf_link_hash_entry *);
931218822Sdim
93289857Sobrien  /* Emit relocations.  Overrides default routine for emitting relocs,
93389857Sobrien     except during a relocatable link, or if all relocs are being emitted.  */
934130561Sobrien  bfd_boolean (*elf_backend_emit_relocs)
935218822Sdim    (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
936218822Sdim     struct elf_link_hash_entry **);
93789857Sobrien
93889857Sobrien  /* Count relocations.  Not called for relocatable links
93989857Sobrien     or if all relocs are being preserved in the output.  */
94089857Sobrien  unsigned int (*elf_backend_count_relocs)
941130561Sobrien    (asection *, Elf_Internal_Rela *);
94289857Sobrien
94389857Sobrien  /* This function, if defined, is called when an NT_PRSTATUS note is found
944218822Sdim     in a core file.  */
945130561Sobrien  bfd_boolean (*elf_backend_grok_prstatus)
946130561Sobrien    (bfd *, Elf_Internal_Note *);
94789857Sobrien
94889857Sobrien  /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
949218822Sdim     note is found in a core file.  */
950130561Sobrien  bfd_boolean (*elf_backend_grok_psinfo)
951130561Sobrien    (bfd *, Elf_Internal_Note *);
95289857Sobrien
953218822Sdim  /* This function, if defined, is called to write a note to a corefile.  */
954218822Sdim  char *(*elf_backend_write_core_note)
955218822Sdim    (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
956218822Sdim
95789857Sobrien  /* Functions to print VMAs.  Special code to handle 64 bit ELF files.  */
95889857Sobrien  void (* elf_backend_sprintf_vma)
959130561Sobrien    (bfd *, char *, bfd_vma);
96089857Sobrien  void (* elf_backend_fprintf_vma)
961130561Sobrien    (bfd *, void *, bfd_vma);
96289857Sobrien
96389857Sobrien  /* This function returns class of a reloc type.  */
96489857Sobrien  enum elf_reloc_type_class (*elf_backend_reloc_type_class)
965130561Sobrien    (const Elf_Internal_Rela *);
96689857Sobrien
96789857Sobrien  /* This function, if defined, removes information about discarded functions
96889857Sobrien     from other sections which mention them.  */
969130561Sobrien  bfd_boolean (*elf_backend_discard_info)
970130561Sobrien    (bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
97189857Sobrien
97289857Sobrien  /* This function, if defined, signals that the function above has removed
97389857Sobrien     the discarded relocations for this section.  */
974130561Sobrien  bfd_boolean (*elf_backend_ignore_discarded_relocs)
975130561Sobrien    (asection *);
97689857Sobrien
977218822Sdim  /* What to do when ld finds relocations against symbols defined in
978218822Sdim     discarded sections.  */
979218822Sdim  unsigned int (*action_discarded)
980218822Sdim    (asection *);
981218822Sdim
982218822Sdim  /* This function returns the width of FDE pointers in bytes, or 0 if
983218822Sdim     that can't be determined for some reason.  The default definition
984218822Sdim     goes by the bfd's EI_CLASS.  */
985218822Sdim  unsigned int (*elf_backend_eh_frame_address_size)
986218822Sdim    (bfd *, asection *);
987218822Sdim
988130561Sobrien  /* These functions tell elf-eh-frame whether to attempt to turn
989130561Sobrien     absolute or lsda encodings into pc-relative ones.  The default
990130561Sobrien     definition enables these transformations.  */
991130561Sobrien  bfd_boolean (*elf_backend_can_make_relative_eh_frame)
992130561Sobrien     (bfd *, struct bfd_link_info *, asection *);
993130561Sobrien  bfd_boolean (*elf_backend_can_make_lsda_relative_eh_frame)
994130561Sobrien     (bfd *, struct bfd_link_info *, asection *);
995130561Sobrien
996130561Sobrien  /* This function returns an encoding after computing the encoded
997130561Sobrien     value (and storing it in ENCODED) for the given OFFSET into OSEC,
998130561Sobrien     to be stored in at LOC_OFFSET into the LOC_SEC input section.
999130561Sobrien     The default definition chooses a 32-bit PC-relative encoding.  */
1000130561Sobrien  bfd_byte (*elf_backend_encode_eh_address)
1001130561Sobrien     (bfd *abfd, struct bfd_link_info *info,
1002130561Sobrien      asection *osec, bfd_vma offset,
1003130561Sobrien      asection *loc_sec, bfd_vma loc_offset,
1004130561Sobrien      bfd_vma *encoded);
1005130561Sobrien
100689857Sobrien  /* This function, if defined, may write out the given section.
1007130561Sobrien     Returns TRUE if it did so and FALSE if the caller should.  */
1008130561Sobrien  bfd_boolean (*elf_backend_write_section)
1009218822Sdim    (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
101089857Sobrien
1011104834Sobrien  /* The level of IRIX compatibility we're striving for.
1012104834Sobrien     MIPS ELF specific function.  */
1013104834Sobrien  irix_compat_t (*elf_backend_mips_irix_compat)
1014130561Sobrien    (bfd *);
1015104834Sobrien
1016104834Sobrien  reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
1017130561Sobrien    (unsigned int, bfd_boolean);
1018104834Sobrien
101933965Sjdp  /* The swapping table to use when dealing with ECOFF information.
102033965Sjdp     Used for the MIPS ELF .mdebug section.  */
102133965Sjdp  const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
102233965Sjdp
1023130561Sobrien  /* This function implements `bfd_elf_bfd_from_remote_memory';
1024130561Sobrien     see elf.c, elfcode.h.  */
1025130561Sobrien  bfd *(*elf_backend_bfd_from_remote_memory)
1026130561Sobrien     (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
1027218822Sdim      int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
1028130561Sobrien
1029218822Sdim  /* This function is used by `_bfd_elf_get_synthetic_symtab';
1030218822Sdim     see elf.c.  */
1031218822Sdim  bfd_vma (*plt_sym_val) (bfd_vma, const asection *, const arelent *);
1032218822Sdim
1033218822Sdim  /* Is symbol defined in common section?  */
1034218822Sdim  bfd_boolean (*common_definition) (Elf_Internal_Sym *);
1035218822Sdim
1036218822Sdim  /* Return a common section index for section.  */
1037218822Sdim  unsigned int (*common_section_index) (asection *);
1038218822Sdim
1039218822Sdim  /* Return a common section for section.  */
1040218822Sdim  asection *(*common_section) (asection *);
1041218822Sdim
1042218822Sdim  /* Return TRUE if we can merge 2 definitions.  */
1043218822Sdim  bfd_boolean (*merge_symbol) (struct bfd_link_info *,
1044218822Sdim			       struct elf_link_hash_entry **,
1045218822Sdim			       struct elf_link_hash_entry *,
1046218822Sdim			       Elf_Internal_Sym *, asection **,
1047218822Sdim			       bfd_vma *, unsigned int *,
1048218822Sdim			       bfd_boolean *, bfd_boolean *,
1049218822Sdim			       bfd_boolean *, bfd_boolean *,
1050218822Sdim			       bfd_boolean *, bfd_boolean *,
1051218822Sdim			       bfd_boolean *, bfd_boolean *,
1052218822Sdim			       bfd *, asection **,
1053218822Sdim			       bfd_boolean *, bfd_boolean *,
1054218822Sdim			       bfd_boolean *, bfd_boolean *,
1055218822Sdim			       bfd *, asection **);
1056218822Sdim
1057218822Sdim  /* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
1058218822Sdim  bfd_boolean (*elf_hash_symbol) (struct elf_link_hash_entry *);
1059218822Sdim
1060218822Sdim  /* Return TRUE if type is a function symbol type.  */
1061218822Sdim  bfd_boolean (*is_function_type) (unsigned int type);
1062218822Sdim
1063218822Sdim  /* Used to handle bad SHF_LINK_ORDER input.  */
1064218822Sdim  bfd_error_handler_type link_order_error_handler;
1065218822Sdim
1066218822Sdim  /* Name of the PLT relocation section.  */
1067218822Sdim  const char *relplt_name;
1068218822Sdim
106933965Sjdp  /* Alternate EM_xxxx machine codes for this backend.  */
107033965Sjdp  int elf_machine_alt1;
107133965Sjdp  int elf_machine_alt2;
107233965Sjdp
107333965Sjdp  const struct elf_size_info *s;
107433965Sjdp
1075218822Sdim  /* An array of target specific special sections.  */
1076130561Sobrien  const struct bfd_elf_special_section *special_sections;
1077130561Sobrien
1078130561Sobrien  /* The size in bytes of the header for the GOT.  This includes the
1079130561Sobrien     so-called reserved entries on some systems.  */
108060484Sobrien  bfd_vma got_header_size;
108160484Sobrien
1082218822Sdim  /* The vendor name to use for a processor-standard attributes section.  */
1083218822Sdim  const char *obj_attrs_vendor;
1084218822Sdim
1085218822Sdim  /* The section name to use for a processor-standard attributes section.  */
1086218822Sdim  const char *obj_attrs_section;
1087218822Sdim
1088218822Sdim  /* Return 1, 2 or 3 to indicate what type of arguments a
1089218822Sdim     processor-specific tag takes.  */
1090218822Sdim  int (*obj_attrs_arg_type) (int);
1091218822Sdim
1092218822Sdim  /* The section type to use for an attributes section.  */
1093218822Sdim  unsigned int obj_attrs_section_type;
1094218822Sdim
1095130561Sobrien  /* This is TRUE if the linker should act like collect and gather
1096130561Sobrien     global constructors and destructors by name.  This is TRUE for
109760484Sobrien     MIPS ELF because the Irix 5 tools can not handle the .init
109860484Sobrien     section.  */
109960484Sobrien  unsigned collect : 1;
110060484Sobrien
1101130561Sobrien  /* This is TRUE if the linker should ignore changes to the type of a
1102130561Sobrien     symbol.  This is TRUE for MIPS ELF because some Irix 5 objects
110360484Sobrien     record undefined functions as STT_OBJECT although the definitions
110460484Sobrien     are STT_FUNC.  */
110560484Sobrien  unsigned type_change_ok : 1;
110660484Sobrien
110760484Sobrien  /* Whether the backend may use REL relocations.  (Some backends use
110860484Sobrien     both REL and RELA relocations, and this flag is set for those
110960484Sobrien     backends.)  */
111060484Sobrien  unsigned may_use_rel_p : 1;
111177298Sobrien
111260484Sobrien  /* Whether the backend may use RELA relocations.  (Some backends use
111360484Sobrien     both REL and RELA relocations, and this flag is set for those
111460484Sobrien     backends.)  */
111560484Sobrien  unsigned may_use_rela_p : 1;
111660484Sobrien
111760484Sobrien  /* Whether the default relocation type is RELA.  If a backend with
111860484Sobrien     this flag set wants REL relocations for a particular section,
111960484Sobrien     it must note that explicitly.  Similarly, if this flag is clear,
112077298Sobrien     and the backend wants RELA relocations for a particular
112177298Sobrien     section.  */
112260484Sobrien  unsigned default_use_rela_p : 1;
112360484Sobrien
112499461Sobrien  /* Set if RELA relocations for a relocatable link can be handled by
112599461Sobrien     generic code.  Backends that set this flag need do nothing in the
112699461Sobrien     backend relocate_section routine for relocatable linking.  */
112799461Sobrien  unsigned rela_normal : 1;
112899461Sobrien
1129130561Sobrien  /* TRUE if addresses "naturally" sign extend.  This is used when
113060484Sobrien     swapping in from Elf32 when BFD64.  */
113160484Sobrien  unsigned sign_extend_vma : 1;
113260484Sobrien
113333965Sjdp  unsigned want_got_plt : 1;
113433965Sjdp  unsigned plt_readonly : 1;
113533965Sjdp  unsigned want_plt_sym : 1;
113638889Sjdp  unsigned plt_not_loaded : 1;
113738889Sjdp  unsigned plt_alignment : 4;
113860484Sobrien  unsigned can_gc_sections : 1;
113989857Sobrien  unsigned can_refcount : 1;
114089857Sobrien  unsigned want_got_sym : 1;
114160484Sobrien  unsigned want_dynbss : 1;
1142218822Sdim
1143218822Sdim  /* Targets which do not support physical addressing often require
1144218822Sdim     that the p_paddr field in the section header to be set to zero.
1145218822Sdim     This field indicates whether this behavior is required.  */
1146104834Sobrien  unsigned want_p_paddr_set_to_zero : 1;
1147218822Sdim
1148218822Sdim  /* True if an object file lacking a .note.GNU-stack section
1149218822Sdim     should be assumed to be requesting exec stack.  At least one
1150218822Sdim     other file in the link needs to have a .note.GNU-stack section
1151218822Sdim     for a PT_GNU_STACK segment to be created.  */
1152218822Sdim  unsigned default_execstack : 1;
115333965Sjdp};
115433965Sjdp
115533965Sjdp/* Information stored for each BFD section in an ELF file.  This
115633965Sjdp   structure is allocated by elf_new_section_hook.  */
115733965Sjdp
115833965Sjdpstruct bfd_elf_section_data
115933965Sjdp{
116033965Sjdp  /* The ELF header for this section.  */
116133965Sjdp  Elf_Internal_Shdr this_hdr;
116289857Sobrien
116333965Sjdp  /* The ELF header for the reloc section associated with this
116433965Sjdp     section, if any.  */
116533965Sjdp  Elf_Internal_Shdr rel_hdr;
116689857Sobrien
116733965Sjdp  /* If there is a second reloc section associated with this section,
116833965Sjdp     as can happen on Irix 6, this field points to the header.  */
116933965Sjdp  Elf_Internal_Shdr *rel_hdr2;
117089857Sobrien
117160484Sobrien  /* The number of relocations currently assigned to REL_HDR.  */
117260484Sobrien  unsigned int rel_count;
117389857Sobrien
117460484Sobrien  /* The number of relocations currently assigned to REL_HDR2.  */
117560484Sobrien  unsigned int rel_count2;
117689857Sobrien
1177218822Sdim  /* The ELF section number of this section.  */
117833965Sjdp  int this_idx;
117989857Sobrien
118060484Sobrien  /* The ELF section number of the reloc section indicated by
118160484Sobrien     REL_HDR if any.  Only used for an output file.  */
118233965Sjdp  int rel_idx;
118389857Sobrien
118460484Sobrien  /* The ELF section number of the reloc section indicated by
118560484Sobrien     REL_HDR2 if any.  Only used for an output file.  */
118660484Sobrien  int rel_idx2;
118789857Sobrien
1188130561Sobrien  /* Used by the backend linker when generating a shared library to
1189130561Sobrien     record the dynamic symbol index for a section symbol
1190130561Sobrien     corresponding to this section.  A value of 0 means that there is
1191130561Sobrien     no dynamic symbol for this section.  */
1192130561Sobrien  int dynindx;
1193130561Sobrien
1194218822Sdim  /* A pointer to the linked-to section for SHF_LINK_ORDER.  */
1195218822Sdim  asection *linked_to;
1196218822Sdim
119733965Sjdp  /* Used by the backend linker to store the symbol hash table entries
119833965Sjdp     associated with relocs against global symbols.  */
119933965Sjdp  struct elf_link_hash_entry **rel_hashes;
120089857Sobrien
120133965Sjdp  /* A pointer to the swapped relocs.  If the section uses REL relocs,
120233965Sjdp     rather than RELA, all the r_addend fields will be zero.  This
120333965Sjdp     pointer may be NULL.  It is used by the backend linker.  */
120433965Sjdp  Elf_Internal_Rela *relocs;
120589857Sobrien
1206130561Sobrien  /* A pointer to a linked list tracking dynamic relocs copied for
1207130561Sobrien     local symbols.  */
1208130561Sobrien  void *local_dynrel;
120989857Sobrien
1210130561Sobrien  /* A pointer to the bfd section used for dynamic relocs.  */
1211130561Sobrien  asection *sreloc;
121289857Sobrien
1213104834Sobrien  union {
1214104834Sobrien    /* Group name, if this section is a member of a group.  */
1215104834Sobrien    const char *name;
121689857Sobrien
1217104834Sobrien    /* Group signature sym, if this is the SHT_GROUP section.  */
1218130561Sobrien    struct bfd_symbol *id;
1219104834Sobrien  } group;
1220104834Sobrien
1221218822Sdim  /* For a member of a group, points to the SHT_GROUP section.
1222218822Sdim     NULL for the SHT_GROUP section itself and non-group sections.  */
1223218822Sdim  asection *sec_group;
1224218822Sdim
1225218822Sdim  /* A linked list of member sections in the group.  Circular when used by
1226218822Sdim     the linker.  For the SHT_GROUP section, points at first member.  */
122789857Sobrien  asection *next_in_group;
122889857Sobrien
1229130561Sobrien  /* A pointer used for various section optimizations.  */
1230130561Sobrien  void *sec_info;
123133965Sjdp};
123233965Sjdp
1233218822Sdim#define elf_section_data(sec)  ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
1234218822Sdim#define elf_linked_to_section(sec) (elf_section_data(sec)->linked_to)
1235130561Sobrien#define elf_section_type(sec)  (elf_section_data(sec)->this_hdr.sh_type)
1236130561Sobrien#define elf_section_flags(sec) (elf_section_data(sec)->this_hdr.sh_flags)
1237104834Sobrien#define elf_group_name(sec)    (elf_section_data(sec)->group.name)
1238104834Sobrien#define elf_group_id(sec)      (elf_section_data(sec)->group.id)
123989857Sobrien#define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
1240218822Sdim#define elf_sec_group(sec)	(elf_section_data(sec)->sec_group)
124133965Sjdp
1242218822Sdim#define xvec_get_elf_backend_data(xvec) \
1243218822Sdim  ((struct elf_backend_data *) (xvec)->backend_data)
124489857Sobrien
124533965Sjdp#define get_elf_backend_data(abfd) \
1246218822Sdim   xvec_get_elf_backend_data ((abfd)->xvec)
124733965Sjdp
1248130561Sobrien/* This struct is used to pass information to routines called via
1249130561Sobrien   elf_link_hash_traverse which must return failure.  */
1250130561Sobrien
1251130561Sobrienstruct elf_info_failed
125233965Sjdp{
1253130561Sobrien  bfd_boolean failed;
1254130561Sobrien  struct bfd_link_info *info;
1255130561Sobrien  struct bfd_elf_version_tree *verdefs;
1256130561Sobrien};
125733965Sjdp
1258130561Sobrien/* This structure is used to pass information to
1259130561Sobrien   _bfd_elf_link_assign_sym_version.  */
126033965Sjdp
1261130561Sobrienstruct elf_assign_sym_version_info
126233965Sjdp{
1263130561Sobrien  /* Output BFD.  */
1264130561Sobrien  bfd *output_bfd;
1265130561Sobrien  /* General link information.  */
1266130561Sobrien  struct bfd_link_info *info;
1267130561Sobrien  /* Version tree.  */
1268130561Sobrien  struct bfd_elf_version_tree *verdefs;
1269130561Sobrien  /* Whether we had a failure.  */
1270130561Sobrien  bfd_boolean failed;
1271130561Sobrien};
127233965Sjdp
1273130561Sobrien/* This structure is used to pass information to
1274130561Sobrien   _bfd_elf_link_find_version_dependencies.  */
127533965Sjdp
1276130561Sobrienstruct elf_find_verdep_info
127733965Sjdp{
1278130561Sobrien  /* Output BFD.  */
1279130561Sobrien  bfd *output_bfd;
1280130561Sobrien  /* General link information.  */
1281130561Sobrien  struct bfd_link_info *info;
1282130561Sobrien  /* The number of dependencies.  */
1283130561Sobrien  unsigned int vers;
1284130561Sobrien  /* Whether we had a failure.  */
1285130561Sobrien  bfd_boolean failed;
1286130561Sobrien};
128733965Sjdp
1288218822Sdim/* The maximum number of known object attributes for any target.  */
1289281048Sandrew#define NUM_KNOWN_OBJ_ATTRIBUTES 71
1290218822Sdim
1291218822Sdim/* The value of an object attribute.  type & 1 indicates whether there
1292218822Sdim   is an integer value; type & 2 indicates whether there is a string
1293218822Sdim   value.  */
1294218822Sdim
1295218822Sdimtypedef struct obj_attribute
1296218822Sdim{
1297218822Sdim  int type;
1298218822Sdim  unsigned int i;
1299218822Sdim  char *s;
1300218822Sdim} obj_attribute;
1301218822Sdim
1302218822Sdimtypedef struct obj_attribute_list
1303218822Sdim{
1304218822Sdim  struct obj_attribute_list *next;
1305218822Sdim  int tag;
1306218822Sdim  obj_attribute attr;
1307218822Sdim} obj_attribute_list;
1308218822Sdim
1309218822Sdim/* Object attributes may either be defined by the processor ABI, index
1310218822Sdim   OBJ_ATTR_PROC in the *_obj_attributes arrays, or be GNU-specific
1311218822Sdim   (and possibly also processor-specific), index OBJ_ATTR_GNU.  */
1312218822Sdim#define OBJ_ATTR_PROC 0
1313218822Sdim#define OBJ_ATTR_GNU 1
1314218822Sdim#define OBJ_ATTR_FIRST OBJ_ATTR_PROC
1315218822Sdim#define OBJ_ATTR_LAST OBJ_ATTR_GNU
1316218822Sdim
1317218822Sdim/* The following object attribute tags are taken as generic, for all
1318218822Sdim   targets and for "gnu" where there is no target standard.  */
1319218822Sdimenum
1320218822Sdim{
1321218822Sdim  Tag_NULL = 0,
1322218822Sdim  Tag_File = 1,
1323218822Sdim  Tag_Section = 2,
1324218822Sdim  Tag_Symbol = 3,
1325218822Sdim  Tag_compatibility = 32
1326218822Sdim};
1327218822Sdim
132833965Sjdp/* Some private data is stashed away for future use using the tdata pointer
132933965Sjdp   in the bfd structure.  */
133033965Sjdp
133133965Sjdpstruct elf_obj_tdata
133233965Sjdp{
133333965Sjdp  Elf_Internal_Ehdr elf_header[1];	/* Actual data, but ref like ptr */
133433965Sjdp  Elf_Internal_Shdr **elf_sect_ptr;
133533965Sjdp  Elf_Internal_Phdr *phdr;
133633965Sjdp  struct elf_segment_map *segment_map;
133789857Sobrien  struct elf_strtab_hash *strtab_ptr;
133833965Sjdp  int num_locals;
133933965Sjdp  int num_globals;
134089857Sobrien  unsigned int num_elf_sections;	/* elf_sect_ptr size */
134189857Sobrien  int num_section_syms;
134233965Sjdp  asymbol **section_syms;		/* STT_SECTION symbols for each section */
134333965Sjdp  Elf_Internal_Shdr symtab_hdr;
134433965Sjdp  Elf_Internal_Shdr shstrtab_hdr;
134533965Sjdp  Elf_Internal_Shdr strtab_hdr;
134633965Sjdp  Elf_Internal_Shdr dynsymtab_hdr;
134733965Sjdp  Elf_Internal_Shdr dynstrtab_hdr;
134833965Sjdp  Elf_Internal_Shdr dynversym_hdr;
134933965Sjdp  Elf_Internal_Shdr dynverref_hdr;
135033965Sjdp  Elf_Internal_Shdr dynverdef_hdr;
135189857Sobrien  Elf_Internal_Shdr symtab_shndx_hdr;
135233965Sjdp  unsigned int symtab_section, shstrtab_section;
135333965Sjdp  unsigned int strtab_section, dynsymtab_section;
135489857Sobrien  unsigned int symtab_shndx_section;
135533965Sjdp  unsigned int dynversym_section, dynverdef_section, dynverref_section;
135633965Sjdp  file_ptr next_file_pos;
135789857Sobrien  bfd_vma gp;				/* The gp value */
135889857Sobrien  unsigned int gp_size;			/* The gp size */
135933965Sjdp
136077298Sobrien  /* Information grabbed from an elf core file.  */
136160484Sobrien  int core_signal;
136260484Sobrien  int core_pid;
136360484Sobrien  int core_lwpid;
136460484Sobrien  char* core_program;
136560484Sobrien  char* core_command;
136660484Sobrien
136733965Sjdp  /* A mapping from external symbols to entries in the linker hash
136833965Sjdp     table, used when linking.  This is indexed by the symbol index
136933965Sjdp     minus the sh_info field of the symbol table header.  */
137033965Sjdp  struct elf_link_hash_entry **sym_hashes;
137133965Sjdp
1372130561Sobrien  /* Track usage and final offsets of GOT entries for local symbols.
1373130561Sobrien     This array is indexed by symbol index.  Elements are used
1374130561Sobrien     identically to "got" in struct elf_link_hash_entry.  */
137560484Sobrien  union
137660484Sobrien    {
137760484Sobrien      bfd_signed_vma *refcounts;
137860484Sobrien      bfd_vma *offsets;
1379130561Sobrien      struct got_entry **ents;
138060484Sobrien    } local_got;
138133965Sjdp
138233965Sjdp  /* The linker ELF emulation code needs to let the backend ELF linker
138333965Sjdp     know what filename should be used for a dynamic object if the
138433965Sjdp     dynamic object is found using a search.  The emulation code then
138533965Sjdp     sometimes needs to know what name was actually used.  Until the
138633965Sjdp     file has been added to the linker symbol table, this field holds
138733965Sjdp     the name the linker wants.  After it has been added, it holds the
138833965Sjdp     name actually used, which will be the DT_SONAME entry if there is
138933965Sjdp     one.  */
139033965Sjdp  const char *dt_name;
139133965Sjdp
139233965Sjdp  /* Records the result of `get_program_header_size'.  */
139333965Sjdp  bfd_size_type program_header_size;
139433965Sjdp
139533965Sjdp  /* Used by find_nearest_line entry point.  */
1396130561Sobrien  void *line_info;
139733965Sjdp
139833965Sjdp  /* Used by MIPS ELF find_nearest_line entry point.  The structure
139933965Sjdp     could be included directly in this one, but there's no point to
140033965Sjdp     wasting the memory just for the infrequently called
140133965Sjdp     find_nearest_line.  */
140233965Sjdp  struct mips_elf_find_line *find_line_info;
140333965Sjdp
140477298Sobrien  /* A place to stash dwarf1 info for this bfd.  */
140560484Sobrien  struct dwarf1_debug *dwarf1_find_line_info;
140660484Sobrien
140777298Sobrien  /* A place to stash dwarf2 info for this bfd.  */
1408130561Sobrien  void *dwarf2_find_line_info;
140938889Sjdp
141033965Sjdp  /* An array of stub sections indexed by symbol number, used by the
141133965Sjdp     MIPS ELF linker.  FIXME: We should figure out some way to only
141233965Sjdp     include this field for a MIPS ELF target.  */
141333965Sjdp  asection **local_stubs;
1414218822Sdim  asection **local_call_stubs;
141533965Sjdp
141689857Sobrien  /* Used to determine if PT_GNU_EH_FRAME segment header should be
141789857Sobrien     created.  */
1418130561Sobrien  asection *eh_frame_hdr;
141989857Sobrien
1420130561Sobrien  Elf_Internal_Shdr **group_sect_ptr;
1421130561Sobrien  int num_group;
1422130561Sobrien
142333965Sjdp  /* Number of symbol version definitions we are about to emit.  */
142438889Sjdp  unsigned int cverdefs;
142533965Sjdp
142633965Sjdp  /* Number of symbol version references we are about to emit.  */
142738889Sjdp  unsigned int cverrefs;
142833965Sjdp
1429130561Sobrien  /* Segment flags for the PT_GNU_STACK segment.  */
1430218822Sdim  unsigned int stack_flags;
1431130561Sobrien
1432218822Sdim  /* Should the PT_GNU_RELRO segment be emitted?  */
1433218822Sdim  bfd_boolean relro;
1434218822Sdim
143533965Sjdp  /* Symbol version definitions in external objects.  */
143633965Sjdp  Elf_Internal_Verdef *verdef;
143733965Sjdp
143833965Sjdp  /* Symbol version references to external objects.  */
143933965Sjdp  Elf_Internal_Verneed *verref;
144033965Sjdp
144177298Sobrien  /* The Irix 5 support uses two virtual sections, which represent
144277298Sobrien     text/data symbols defined in dynamic objects.  */
144377298Sobrien  asymbol *elf_data_symbol;
144477298Sobrien  asymbol *elf_text_symbol;
144577298Sobrien  asection *elf_data_section;
144677298Sobrien  asection *elf_text_section;
1447130561Sobrien
1448130561Sobrien  /* Whether a dyanmic object was specified normally on the linker
1449130561Sobrien     command line, or was specified when --as-needed was in effect,
1450130561Sobrien     or was found via a DT_NEEDED entry.  */
1451130561Sobrien  enum dynamic_lib_link_class dyn_lib_class;
1452130561Sobrien
1453130561Sobrien  /* This is set to TRUE if the object was created by the backend
1454130561Sobrien     linker.  */
1455130561Sobrien  bfd_boolean linker;
1456130561Sobrien
1457130561Sobrien  /* Irix 5 often screws up the symbol table, sorting local symbols
1458130561Sobrien     after global symbols.  This flag is set if the symbol table in
1459130561Sobrien     this BFD appears to be screwed up.  If it is, we ignore the
1460130561Sobrien     sh_info field in the symbol table header, and always read all the
1461130561Sobrien     symbols.  */
1462130561Sobrien  bfd_boolean bad_symtab;
1463130561Sobrien
1464130561Sobrien  /* Used to determine if the e_flags field has been initialized */
1465130561Sobrien  bfd_boolean flags_init;
1466218822Sdim
1467218822Sdim  /* Symbol buffer.  */
1468218822Sdim  void *symbuf;
1469218822Sdim
1470218822Sdim  obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
1471218822Sdim  obj_attribute_list *other_obj_attributes[2];
147233965Sjdp};
147333965Sjdp
147433965Sjdp#define elf_tdata(bfd)		((bfd) -> tdata.elf_obj_data)
147533965Sjdp#define elf_elfheader(bfd)	(elf_tdata(bfd) -> elf_header)
147633965Sjdp#define elf_elfsections(bfd)	(elf_tdata(bfd) -> elf_sect_ptr)
147789857Sobrien#define elf_numsections(bfd)	(elf_tdata(bfd) -> num_elf_sections)
147833965Sjdp#define elf_shstrtab(bfd)	(elf_tdata(bfd) -> strtab_ptr)
147933965Sjdp#define elf_onesymtab(bfd)	(elf_tdata(bfd) -> symtab_section)
148089857Sobrien#define elf_symtab_shndx(bfd)	(elf_tdata(bfd) -> symtab_shndx_section)
148133965Sjdp#define elf_dynsymtab(bfd)	(elf_tdata(bfd) -> dynsymtab_section)
148233965Sjdp#define elf_dynversym(bfd)	(elf_tdata(bfd) -> dynversym_section)
148333965Sjdp#define elf_dynverdef(bfd)	(elf_tdata(bfd) -> dynverdef_section)
148433965Sjdp#define elf_dynverref(bfd)	(elf_tdata(bfd) -> dynverref_section)
148533965Sjdp#define elf_num_locals(bfd)	(elf_tdata(bfd) -> num_locals)
148633965Sjdp#define elf_num_globals(bfd)	(elf_tdata(bfd) -> num_globals)
148733965Sjdp#define elf_section_syms(bfd)	(elf_tdata(bfd) -> section_syms)
148889857Sobrien#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
148933965Sjdp#define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
149033965Sjdp#define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
149133965Sjdp#define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
149233965Sjdp#define elf_gp_size(bfd)	(elf_tdata(bfd) -> gp_size)
149333965Sjdp#define elf_sym_hashes(bfd)	(elf_tdata(bfd) -> sym_hashes)
149460484Sobrien#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
149560484Sobrien#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
1496130561Sobrien#define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
149733965Sjdp#define elf_dt_name(bfd)	(elf_tdata(bfd) -> dt_name)
1498130561Sobrien#define elf_dyn_lib_class(bfd)	(elf_tdata(bfd) -> dyn_lib_class)
149933965Sjdp#define elf_bad_symtab(bfd)	(elf_tdata(bfd) -> bad_symtab)
150033965Sjdp#define elf_flags_init(bfd)	(elf_tdata(bfd) -> flags_init)
1501218822Sdim#define elf_known_obj_attributes(bfd) (elf_tdata (bfd) -> known_obj_attributes)
1502218822Sdim#define elf_other_obj_attributes(bfd) (elf_tdata (bfd) -> other_obj_attributes)
1503218822Sdim#define elf_known_obj_attributes_proc(bfd) \
1504218822Sdim  (elf_known_obj_attributes (bfd) [OBJ_ATTR_PROC])
1505218822Sdim#define elf_other_obj_attributes_proc(bfd) \
1506218822Sdim  (elf_other_obj_attributes (bfd) [OBJ_ATTR_PROC])
150733965Sjdp
150833965Sjdpextern void _bfd_elf_swap_verdef_in
1509130561Sobrien  (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *);
151033965Sjdpextern void _bfd_elf_swap_verdef_out
1511130561Sobrien  (bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *);
151233965Sjdpextern void _bfd_elf_swap_verdaux_in
1513130561Sobrien  (bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *);
151433965Sjdpextern void _bfd_elf_swap_verdaux_out
1515130561Sobrien  (bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *);
151633965Sjdpextern void _bfd_elf_swap_verneed_in
1517130561Sobrien  (bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *);
151833965Sjdpextern void _bfd_elf_swap_verneed_out
1519130561Sobrien  (bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *);
152033965Sjdpextern void _bfd_elf_swap_vernaux_in
1521130561Sobrien  (bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *);
152233965Sjdpextern void _bfd_elf_swap_vernaux_out
1523130561Sobrien  (bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *);
152433965Sjdpextern void _bfd_elf_swap_versym_in
1525130561Sobrien  (bfd *, const Elf_External_Versym *, Elf_Internal_Versym *);
152633965Sjdpextern void _bfd_elf_swap_versym_out
1527130561Sobrien  (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *);
152833965Sjdp
152989857Sobrienextern int _bfd_elf_section_from_bfd_section
1530130561Sobrien  (bfd *, asection *);
153133965Sjdpextern char *bfd_elf_string_from_elf_section
1532130561Sobrien  (bfd *, unsigned, unsigned);
153389857Sobrienextern char *bfd_elf_get_str_section
1534130561Sobrien  (bfd *, unsigned);
1535104834Sobrienextern Elf_Internal_Sym *bfd_elf_get_elf_syms
1536130561Sobrien  (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
1537130561Sobrien   Elf_External_Sym_Shndx *);
1538218822Sdimextern const char *bfd_elf_sym_name
1539218822Sdim  (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *);
154033965Sjdp
1541130561Sobrienextern bfd_boolean _bfd_elf_copy_private_bfd_data
1542130561Sobrien  (bfd *, bfd *);
1543130561Sobrienextern bfd_boolean _bfd_elf_print_private_bfd_data
1544130561Sobrien  (bfd *, void *);
154589857Sobrienextern void bfd_elf_print_symbol
1546130561Sobrien  (bfd *, void *, asymbol *, bfd_print_symbol_type);
154733965Sjdp
154889857Sobrienextern void _bfd_elf_sprintf_vma
1549130561Sobrien  (bfd *, char *, bfd_vma);
155089857Sobrienextern void _bfd_elf_fprintf_vma
1551130561Sobrien  (bfd *, void *, bfd_vma);
155233965Sjdp
1553218822Sdimextern unsigned int _bfd_elf_eh_frame_address_size
1554218822Sdim  (bfd *, asection *);
1555130561Sobrienextern bfd_byte _bfd_elf_encode_eh_address
1556130561Sobrien  (bfd *abfd, struct bfd_link_info *info, asection *osec, bfd_vma offset,
1557130561Sobrien   asection *loc_sec, bfd_vma loc_offset, bfd_vma *encoded);
1558130561Sobrienextern bfd_boolean _bfd_elf_can_make_relative
1559130561Sobrien  (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
1560130561Sobrien
156189857Sobrienextern enum elf_reloc_type_class _bfd_elf_reloc_type_class
1562130561Sobrien  (const Elf_Internal_Rela *);
156389857Sobrienextern bfd_vma _bfd_elf_rela_local_sym
1564130561Sobrien  (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
156589857Sobrienextern bfd_vma _bfd_elf_rel_local_sym
1566130561Sobrien  (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
156789857Sobrienextern bfd_vma _bfd_elf_section_offset
1568130561Sobrien  (bfd *, struct bfd_link_info *, asection *, bfd_vma);
156989857Sobrien
157089857Sobrienextern unsigned long bfd_elf_hash
1571130561Sobrien  (const char *);
1572218822Sdimextern unsigned long bfd_elf_gnu_hash
1573218822Sdim  (const char *);
157489857Sobrien
157589857Sobrienextern bfd_reloc_status_type bfd_elf_generic_reloc
1576130561Sobrien  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
1577130561Sobrienextern bfd_boolean bfd_elf_mkobject
1578130561Sobrien  (bfd *);
1579130561Sobrienextern bfd_boolean bfd_elf_mkcorefile
1580130561Sobrien  (bfd *);
158189857Sobrienextern Elf_Internal_Shdr *bfd_elf_find_section
1582130561Sobrien  (bfd *, char *);
1583130561Sobrienextern bfd_boolean _bfd_elf_make_section_from_shdr
1584218822Sdim  (bfd *, Elf_Internal_Shdr *, const char *, int);
1585130561Sobrienextern bfd_boolean _bfd_elf_make_section_from_phdr
1586130561Sobrien  (bfd *, Elf_Internal_Phdr *, int, const char *);
158733965Sjdpextern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
1588130561Sobrien  (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
158933965Sjdpextern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
1590130561Sobrien  (bfd *);
159160484Sobrienextern void _bfd_elf_link_hash_copy_indirect
1592218822Sdim  (struct bfd_link_info *, struct elf_link_hash_entry *,
1593130561Sobrien   struct elf_link_hash_entry *);
159460484Sobrienextern void _bfd_elf_link_hash_hide_symbol
1595130561Sobrien  (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
1596218822Sdimextern bfd_boolean _bfd_elf_link_hash_fixup_symbol
1597218822Sdim  (struct bfd_link_info *, struct elf_link_hash_entry *);
1598130561Sobrienextern bfd_boolean _bfd_elf_link_hash_table_init
1599130561Sobrien  (struct elf_link_hash_table *, bfd *,
1600130561Sobrien   struct bfd_hash_entry *(*)
1601218822Sdim     (struct bfd_hash_entry *, struct bfd_hash_table *, const char *),
1602218822Sdim   unsigned int);
1603130561Sobrienextern bfd_boolean _bfd_elf_slurp_version_tables
1604218822Sdim  (bfd *, bfd_boolean);
1605130561Sobrienextern bfd_boolean _bfd_elf_merge_sections
1606130561Sobrien  (bfd *, struct bfd_link_info *);
1607218822Sdimextern bfd_boolean _bfd_elf_match_sections_by_type
1608218822Sdim  (bfd *, const asection *, bfd *, const asection *);
1609218822Sdimextern bfd_boolean bfd_elf_is_group_section
1610218822Sdim  (bfd *, const struct bfd_section *);
1611218822Sdimextern void _bfd_elf_section_already_linked
1612218822Sdim  (bfd *, struct bfd_section *, struct bfd_link_info *);
1613104834Sobrienextern void bfd_elf_set_group_contents
1614130561Sobrien  (bfd *, asection *, void *);
1615218822Sdimextern asection *_bfd_elf_check_kept_section
1616218822Sdim  (asection *, struct bfd_link_info *);
1617104834Sobrienextern void _bfd_elf_link_just_syms
1618130561Sobrien  (asection *, struct bfd_link_info *);
1619218822Sdimextern bfd_boolean _bfd_elf_copy_private_header_data
1620218822Sdim  (bfd *, bfd *);
1621130561Sobrienextern bfd_boolean _bfd_elf_copy_private_symbol_data
1622130561Sobrien  (bfd *, asymbol *, bfd *, asymbol *);
1623218822Sdim#define _bfd_generic_init_private_section_data \
1624218822Sdim  _bfd_elf_init_private_section_data
1625218822Sdimextern bfd_boolean _bfd_elf_init_private_section_data
1626218822Sdim  (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
1627130561Sobrienextern bfd_boolean _bfd_elf_copy_private_section_data
1628130561Sobrien  (bfd *, asection *, bfd *, asection *);
1629130561Sobrienextern bfd_boolean _bfd_elf_write_object_contents
1630130561Sobrien  (bfd *);
1631130561Sobrienextern bfd_boolean _bfd_elf_write_corefile_contents
1632130561Sobrien  (bfd *);
1633130561Sobrienextern bfd_boolean _bfd_elf_set_section_contents
1634130561Sobrien  (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
163589857Sobrienextern long _bfd_elf_get_symtab_upper_bound
1636130561Sobrien  (bfd *);
1637130561Sobrienextern long _bfd_elf_canonicalize_symtab
1638130561Sobrien  (bfd *, asymbol **);
163989857Sobrienextern long _bfd_elf_get_dynamic_symtab_upper_bound
1640130561Sobrien  (bfd *);
164189857Sobrienextern long _bfd_elf_canonicalize_dynamic_symtab
1642130561Sobrien  (bfd *, asymbol **);
1643218822Sdimextern long _bfd_elf_get_synthetic_symtab
1644218822Sdim  (bfd *, long, asymbol **, long, asymbol **, asymbol **);
164589857Sobrienextern long _bfd_elf_get_reloc_upper_bound
1646130561Sobrien  (bfd *, sec_ptr);
164789857Sobrienextern long _bfd_elf_canonicalize_reloc
1648130561Sobrien  (bfd *, sec_ptr, arelent **, asymbol **);
164989857Sobrienextern long _bfd_elf_get_dynamic_reloc_upper_bound
1650130561Sobrien  (bfd *);
165189857Sobrienextern long _bfd_elf_canonicalize_dynamic_reloc
1652130561Sobrien  (bfd *, arelent **, asymbol **);
165389857Sobrienextern asymbol *_bfd_elf_make_empty_symbol
1654130561Sobrien  (bfd *);
165589857Sobrienextern void _bfd_elf_get_symbol_info
1656130561Sobrien  (bfd *, asymbol *, symbol_info *);
1657130561Sobrienextern bfd_boolean _bfd_elf_is_local_label_name
1658130561Sobrien  (bfd *, const char *);
165989857Sobrienextern alent *_bfd_elf_get_lineno
1660130561Sobrien  (bfd *, asymbol *);
1661130561Sobrienextern bfd_boolean _bfd_elf_set_arch_mach
1662130561Sobrien  (bfd *, enum bfd_architecture, unsigned long);
1663130561Sobrienextern bfd_boolean _bfd_elf_find_nearest_line
1664130561Sobrien  (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **,
1665130561Sobrien   unsigned int *);
1666218822Sdimextern bfd_boolean _bfd_elf_find_line
1667218822Sdim  (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
1668218822Sdim#define _bfd_generic_find_line _bfd_elf_find_line
1669218822Sdimextern bfd_boolean _bfd_elf_find_inliner_info
1670218822Sdim  (bfd *, const char **, const char **, unsigned int *);
167133965Sjdp#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
167233965Sjdp#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
167389857Sobrienextern int _bfd_elf_sizeof_headers
1674218822Sdim  (bfd *, struct bfd_link_info *);
1675130561Sobrienextern bfd_boolean _bfd_elf_new_section_hook
1676130561Sobrien  (bfd *, asection *);
1677130561Sobrienextern bfd_boolean _bfd_elf_init_reloc_shdr
1678130561Sobrien  (bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean);
1679218822Sdimextern const struct bfd_elf_special_section *_bfd_elf_get_special_section
1680218822Sdim  (const char *, const struct bfd_elf_special_section *, unsigned int);
1681130561Sobrienextern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
1682218822Sdim  (bfd *, asection *);
168333965Sjdp
168433965Sjdp/* If the target doesn't have reloc handling written yet:  */
168589857Sobrienextern void _bfd_elf_no_info_to_howto
1686130561Sobrien  (bfd *, arelent *, Elf_Internal_Rela *);
168733965Sjdp
1688130561Sobrienextern bfd_boolean bfd_section_from_shdr
1689130561Sobrien  (bfd *, unsigned int shindex);
1690130561Sobrienextern bfd_boolean bfd_section_from_phdr
1691130561Sobrien  (bfd *, Elf_Internal_Phdr *, int);
169233965Sjdp
169389857Sobrienextern int _bfd_elf_symbol_from_bfd_symbol
1694130561Sobrien  (bfd *, asymbol **);
169533965Sjdp
169689857Sobrienextern asection *bfd_section_from_r_symndx
1697130561Sobrien  (bfd *, struct sym_sec_cache *, asection *, unsigned long);
169889857Sobrienextern asection *bfd_section_from_elf_index
1699130561Sobrien  (bfd *, unsigned int);
170089857Sobrienextern struct bfd_strtab_hash *_bfd_elf_stringtab_init
1701130561Sobrien  (void);
170233965Sjdp
170389857Sobrienextern struct elf_strtab_hash * _bfd_elf_strtab_init
1704130561Sobrien  (void);
170589857Sobrienextern void _bfd_elf_strtab_free
1706130561Sobrien  (struct elf_strtab_hash *);
170789857Sobrienextern bfd_size_type _bfd_elf_strtab_add
1708130561Sobrien  (struct elf_strtab_hash *, const char *, bfd_boolean);
170989857Sobrienextern void _bfd_elf_strtab_addref
1710130561Sobrien  (struct elf_strtab_hash *, bfd_size_type);
171189857Sobrienextern void _bfd_elf_strtab_delref
1712130561Sobrien  (struct elf_strtab_hash *, bfd_size_type);
171389857Sobrienextern void _bfd_elf_strtab_clear_all_refs
1714130561Sobrien  (struct elf_strtab_hash *);
171589857Sobrienextern bfd_size_type _bfd_elf_strtab_size
1716130561Sobrien  (struct elf_strtab_hash *);
171789857Sobrienextern bfd_size_type _bfd_elf_strtab_offset
1718130561Sobrien  (struct elf_strtab_hash *, bfd_size_type);
1719130561Sobrienextern bfd_boolean _bfd_elf_strtab_emit
1720130561Sobrien  (bfd *, struct elf_strtab_hash *);
172189857Sobrienextern void _bfd_elf_strtab_finalize
1722130561Sobrien  (struct elf_strtab_hash *);
172333965Sjdp
1724130561Sobrienextern bfd_boolean _bfd_elf_discard_section_eh_frame
1725130561Sobrien  (bfd *, struct bfd_link_info *, asection *,
1726130561Sobrien   bfd_boolean (*) (bfd_vma, void *), struct elf_reloc_cookie *);
1727130561Sobrienextern bfd_boolean _bfd_elf_discard_section_eh_frame_hdr
1728130561Sobrien  (bfd *, struct bfd_link_info *);
172989857Sobrienextern bfd_vma _bfd_elf_eh_frame_section_offset
1730218822Sdim  (bfd *, struct bfd_link_info *, asection *, bfd_vma);
1731130561Sobrienextern bfd_boolean _bfd_elf_write_section_eh_frame
1732130561Sobrien  (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
1733130561Sobrienextern bfd_boolean _bfd_elf_write_section_eh_frame_hdr
1734130561Sobrien  (bfd *, struct bfd_link_info *);
1735130561Sobrienextern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
1736130561Sobrien  (struct bfd_link_info *);
173733965Sjdp
1738130561Sobrienextern bfd_boolean _bfd_elf_merge_symbol
1739130561Sobrien  (bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
1740218822Sdim   asection **, bfd_vma *, unsigned int *,
1741218822Sdim   struct elf_link_hash_entry **, bfd_boolean *,
1742130561Sobrien   bfd_boolean *, bfd_boolean *, bfd_boolean *);
1743130561Sobrien
1744218822Sdimextern bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
1745218822Sdim
1746130561Sobrienextern bfd_boolean _bfd_elf_add_default_symbol
1747130561Sobrien  (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
1748130561Sobrien   const char *, Elf_Internal_Sym *, asection **, bfd_vma *,
1749130561Sobrien   bfd_boolean *, bfd_boolean);
1750130561Sobrien
1751130561Sobrienextern bfd_boolean _bfd_elf_export_symbol
1752130561Sobrien  (struct elf_link_hash_entry *, void *);
1753130561Sobrien
1754130561Sobrienextern bfd_boolean _bfd_elf_link_find_version_dependencies
1755130561Sobrien  (struct elf_link_hash_entry *, void *);
1756130561Sobrien
1757130561Sobrienextern bfd_boolean _bfd_elf_link_assign_sym_version
1758130561Sobrien  (struct elf_link_hash_entry *, void *);
1759130561Sobrien
176089857Sobrienextern long _bfd_elf_link_lookup_local_dynindx
1761130561Sobrien  (struct bfd_link_info *, bfd *, long);
1762130561Sobrienextern bfd_boolean _bfd_elf_compute_section_file_positions
1763130561Sobrien  (bfd *, struct bfd_link_info *);
176489857Sobrienextern void _bfd_elf_assign_file_positions_for_relocs
1765130561Sobrien  (bfd *);
176689857Sobrienextern file_ptr _bfd_elf_assign_file_position_for_section
1767130561Sobrien  (Elf_Internal_Shdr *, file_ptr, bfd_boolean);
176833965Sjdp
1769130561Sobrienextern bfd_boolean _bfd_elf_validate_reloc
1770130561Sobrien  (bfd *, arelent *);
177133965Sjdp
1772130561Sobrienextern bfd_boolean _bfd_elf_link_create_dynamic_sections
1773130561Sobrien  (bfd *, struct bfd_link_info *);
1774218822Sdimextern bfd_boolean _bfd_elf_link_omit_section_dynsym
1775218822Sdim  (bfd *, struct bfd_link_info *, asection *);
1776130561Sobrienextern bfd_boolean _bfd_elf_create_dynamic_sections
1777130561Sobrien  (bfd *, struct bfd_link_info *);
1778130561Sobrienextern bfd_boolean _bfd_elf_create_got_section
1779130561Sobrien  (bfd *, struct bfd_link_info *);
1780218822Sdimextern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
1781218822Sdim  (bfd *, struct bfd_link_info *, asection *, const char *);
1782218822Sdimextern void _bfd_elf_init_1_index_section
1783130561Sobrien  (bfd *, struct bfd_link_info *);
1784218822Sdimextern void _bfd_elf_init_2_index_sections
1785218822Sdim  (bfd *, struct bfd_link_info *);
178633965Sjdp
1787130561Sobrienextern bfd_boolean _bfd_elfcore_make_pseudosection
1788130561Sobrien  (bfd *, char *, size_t, ufile_ptr);
178989857Sobrienextern char *_bfd_elfcore_strndup
1790130561Sobrien  (bfd *, char *, size_t);
179133965Sjdp
1792130561Sobrienextern Elf_Internal_Rela *_bfd_elf_link_read_relocs
1793130561Sobrien  (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean);
179433965Sjdp
1795130561Sobrienextern bfd_boolean _bfd_elf_link_size_reloc_section
1796130561Sobrien  (bfd *, Elf_Internal_Shdr *, asection *);
179733965Sjdp
1798130561Sobrienextern bfd_boolean _bfd_elf_link_output_relocs
1799218822Sdim  (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
1800218822Sdim   struct elf_link_hash_entry **);
180133965Sjdp
1802130561Sobrienextern bfd_boolean _bfd_elf_fix_symbol_flags
1803130561Sobrien  (struct elf_link_hash_entry *, struct elf_info_failed *);
180460484Sobrien
1805130561Sobrienextern bfd_boolean _bfd_elf_adjust_dynamic_symbol
1806130561Sobrien  (struct elf_link_hash_entry *, void *);
180733965Sjdp
1808218822Sdimextern bfd_boolean _bfd_elf_adjust_dynamic_copy
1809218822Sdim  (struct elf_link_hash_entry *, asection *);
1810218822Sdim
1811130561Sobrienextern bfd_boolean _bfd_elf_link_sec_merge_syms
1812130561Sobrien  (struct elf_link_hash_entry *, void *);
181389857Sobrien
1814130561Sobrienextern bfd_boolean _bfd_elf_dynamic_symbol_p
1815130561Sobrien  (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
181689857Sobrien
1817130561Sobrienextern bfd_boolean _bfd_elf_symbol_refs_local_p
1818130561Sobrien  (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
1819130561Sobrien
1820218822Sdimextern bfd_boolean bfd_elf_match_symbols_in_sections
1821218822Sdim  (asection *, asection *, struct bfd_link_info *);
1822218822Sdim
1823218822Sdimextern void bfd_elf_perform_complex_relocation
1824218822Sdim  (bfd *                   output_bfd ATTRIBUTE_UNUSED,
1825218822Sdim   struct bfd_link_info *  info,
1826218822Sdim   bfd *                   input_bfd,
1827218822Sdim   asection *              input_section,
1828218822Sdim   bfd_byte *              contents,
1829218822Sdim   Elf_Internal_Rela *     rel,
1830218822Sdim   Elf_Internal_Sym *      local_syms,
1831218822Sdim   asection **             local_sections);
1832218822Sdim
1833218822Sdimextern bfd_boolean _bfd_elf_setup_sections
1834218822Sdim  (bfd *);
1835218822Sdim
1836218822Sdimextern void _bfd_elf_set_osabi (bfd * , struct bfd_link_info *);
1837218822Sdim
183889857Sobrienextern const bfd_target *bfd_elf32_object_p
1839130561Sobrien  (bfd *);
184089857Sobrienextern const bfd_target *bfd_elf32_core_file_p
1841130561Sobrien  (bfd *);
184289857Sobrienextern char *bfd_elf32_core_file_failing_command
1843130561Sobrien  (bfd *);
184489857Sobrienextern int bfd_elf32_core_file_failing_signal
1845130561Sobrien  (bfd *);
1846130561Sobrienextern bfd_boolean bfd_elf32_core_file_matches_executable_p
1847130561Sobrien  (bfd *, bfd *);
184889857Sobrien
1849218822Sdimextern bfd_boolean bfd_elf32_swap_symbol_in
1850130561Sobrien  (bfd *, const void *, const void *, Elf_Internal_Sym *);
185133965Sjdpextern void bfd_elf32_swap_symbol_out
1852130561Sobrien  (bfd *, const Elf_Internal_Sym *, void *, void *);
185333965Sjdpextern void bfd_elf32_swap_reloc_in
1854130561Sobrien  (bfd *, const bfd_byte *, Elf_Internal_Rela *);
185533965Sjdpextern void bfd_elf32_swap_reloc_out
1856130561Sobrien  (bfd *, const Elf_Internal_Rela *, bfd_byte *);
185733965Sjdpextern void bfd_elf32_swap_reloca_in
1858130561Sobrien  (bfd *, const bfd_byte *, Elf_Internal_Rela *);
185933965Sjdpextern void bfd_elf32_swap_reloca_out
1860130561Sobrien  (bfd *, const Elf_Internal_Rela *, bfd_byte *);
186133965Sjdpextern void bfd_elf32_swap_phdr_in
1862130561Sobrien  (bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *);
186333965Sjdpextern void bfd_elf32_swap_phdr_out
1864130561Sobrien  (bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *);
186533965Sjdpextern void bfd_elf32_swap_dyn_in
1866130561Sobrien  (bfd *, const void *, Elf_Internal_Dyn *);
186733965Sjdpextern void bfd_elf32_swap_dyn_out
1868130561Sobrien  (bfd *, const Elf_Internal_Dyn *, void *);
186933965Sjdpextern long bfd_elf32_slurp_symbol_table
1870130561Sobrien  (bfd *, asymbol **, bfd_boolean);
1871130561Sobrienextern bfd_boolean bfd_elf32_write_shdrs_and_ehdr
1872130561Sobrien  (bfd *);
187333965Sjdpextern int bfd_elf32_write_out_phdrs
1874130561Sobrien  (bfd *, const Elf_Internal_Phdr *, unsigned int);
187577298Sobrienextern void bfd_elf32_write_relocs
1876130561Sobrien  (bfd *, asection *, void *);
1877130561Sobrienextern bfd_boolean bfd_elf32_slurp_reloc_table
1878130561Sobrien  (bfd *, asection *, asymbol **, bfd_boolean);
187933965Sjdp
188089857Sobrienextern const bfd_target *bfd_elf64_object_p
1881130561Sobrien  (bfd *);
188289857Sobrienextern const bfd_target *bfd_elf64_core_file_p
1883130561Sobrien  (bfd *);
188489857Sobrienextern char *bfd_elf64_core_file_failing_command
1885130561Sobrien  (bfd *);
188689857Sobrienextern int bfd_elf64_core_file_failing_signal
1887130561Sobrien  (bfd *);
1888130561Sobrienextern bfd_boolean bfd_elf64_core_file_matches_executable_p
1889130561Sobrien  (bfd *, bfd *);
189033965Sjdp
1891218822Sdimextern bfd_boolean bfd_elf64_swap_symbol_in
1892130561Sobrien  (bfd *, const void *, const void *, Elf_Internal_Sym *);
189333965Sjdpextern void bfd_elf64_swap_symbol_out
1894130561Sobrien  (bfd *, const Elf_Internal_Sym *, void *, void *);
189533965Sjdpextern void bfd_elf64_swap_reloc_in
1896130561Sobrien  (bfd *, const bfd_byte *, Elf_Internal_Rela *);
189733965Sjdpextern void bfd_elf64_swap_reloc_out
1898130561Sobrien  (bfd *, const Elf_Internal_Rela *, bfd_byte *);
189933965Sjdpextern void bfd_elf64_swap_reloca_in
1900130561Sobrien  (bfd *, const bfd_byte *, Elf_Internal_Rela *);
190133965Sjdpextern void bfd_elf64_swap_reloca_out
1902130561Sobrien  (bfd *, const Elf_Internal_Rela *, bfd_byte *);
190333965Sjdpextern void bfd_elf64_swap_phdr_in
1904130561Sobrien  (bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *);
190533965Sjdpextern void bfd_elf64_swap_phdr_out
1906130561Sobrien  (bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *);
190733965Sjdpextern void bfd_elf64_swap_dyn_in
1908130561Sobrien  (bfd *, const void *, Elf_Internal_Dyn *);
190933965Sjdpextern void bfd_elf64_swap_dyn_out
1910130561Sobrien  (bfd *, const Elf_Internal_Dyn *, void *);
191133965Sjdpextern long bfd_elf64_slurp_symbol_table
1912130561Sobrien  (bfd *, asymbol **, bfd_boolean);
1913130561Sobrienextern bfd_boolean bfd_elf64_write_shdrs_and_ehdr
1914130561Sobrien  (bfd *);
191533965Sjdpextern int bfd_elf64_write_out_phdrs
1916130561Sobrien  (bfd *, const Elf_Internal_Phdr *, unsigned int);
191777298Sobrienextern void bfd_elf64_write_relocs
1918130561Sobrien  (bfd *, asection *, void *);
1919130561Sobrienextern bfd_boolean bfd_elf64_slurp_reloc_table
1920130561Sobrien  (bfd *, asection *, asymbol **, bfd_boolean);
192133965Sjdp
1922218822Sdimextern bfd_boolean _bfd_elf_default_relocs_compatible
1923218822Sdim  (const bfd_target *, const bfd_target *);
1924218822Sdim
1925218822Sdimextern bfd_boolean _bfd_elf_relocs_compatible
1926218822Sdim  (const bfd_target *, const bfd_target *);
1927218822Sdim
1928218822Sdimextern struct elf_link_hash_entry *_bfd_elf_archive_symbol_lookup
1929218822Sdim  (bfd *, struct bfd_link_info *, const char *);
1930130561Sobrienextern bfd_boolean bfd_elf_link_add_symbols
1931130561Sobrien  (bfd *, struct bfd_link_info *);
1932130561Sobrienextern bfd_boolean _bfd_elf_add_dynamic_entry
1933130561Sobrien  (struct bfd_link_info *, bfd_vma, bfd_vma);
193433965Sjdp
1935130561Sobrienextern bfd_boolean bfd_elf_link_record_dynamic_symbol
1936130561Sobrien  (struct bfd_link_info *, struct elf_link_hash_entry *);
193760484Sobrien
1938130561Sobrienextern int bfd_elf_link_record_local_dynamic_symbol
1939130561Sobrien  (struct bfd_link_info *, bfd *, long);
1940130561Sobrien
1941218822Sdimextern void bfd_elf_link_mark_dynamic_symbol
1942218822Sdim  (struct bfd_link_info *, struct elf_link_hash_entry *,
1943218822Sdim   Elf_Internal_Sym *);
1944218822Sdim
1945130561Sobrienextern bfd_boolean _bfd_elf_close_and_cleanup
1946130561Sobrien  (bfd *);
1947218822Sdim
1948218822Sdimextern bfd_boolean _bfd_elf_common_definition
1949218822Sdim  (Elf_Internal_Sym *);
1950218822Sdim
1951218822Sdimextern unsigned int _bfd_elf_common_section_index
1952218822Sdim  (asection *);
1953218822Sdim
1954218822Sdimextern asection *_bfd_elf_common_section
1955218822Sdim  (asection *);
1956218822Sdim
1957218822Sdimextern void _bfd_dwarf2_cleanup_debug_info
1958218822Sdim  (bfd *);
1959218822Sdim
196060484Sobrienextern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
1961130561Sobrien  (bfd *, arelent *, struct bfd_symbol *, void *,
1962130561Sobrien   asection *, bfd *, char **);
196338889Sjdp
1964130561Sobrienextern bfd_boolean bfd_elf_final_link
1965130561Sobrien  (bfd *, struct bfd_link_info *);
196660484Sobrien
1967218822Sdimextern bfd_boolean bfd_elf_gc_mark_dynamic_ref_symbol
1968218822Sdim  (struct elf_link_hash_entry *h, void *inf);
1969218822Sdim
1970130561Sobrienextern bfd_boolean bfd_elf_gc_sections
1971130561Sobrien  (bfd *, struct bfd_link_info *);
197260484Sobrien
1973130561Sobrienextern bfd_boolean bfd_elf_gc_record_vtinherit
1974130561Sobrien  (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
197589857Sobrien
1976130561Sobrienextern bfd_boolean bfd_elf_gc_record_vtentry
1977130561Sobrien  (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
1978130561Sobrien
1979218822Sdimextern asection *_bfd_elf_gc_mark_hook
1980218822Sdim  (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
1981218822Sdim   struct elf_link_hash_entry *, Elf_Internal_Sym *);
1982218822Sdim
1983218822Sdimextern bfd_boolean _bfd_elf_gc_mark
1984218822Sdim  (struct bfd_link_info *, asection *,
1985218822Sdim   asection * (*) (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
1986218822Sdim		   struct elf_link_hash_entry *, Elf_Internal_Sym *));
1987218822Sdim
1988130561Sobrienextern bfd_boolean bfd_elf_gc_common_finalize_got_offsets
1989130561Sobrien  (bfd *, struct bfd_link_info *);
1990130561Sobrien
1991130561Sobrienextern bfd_boolean bfd_elf_gc_common_final_link
1992130561Sobrien  (bfd *, struct bfd_link_info *);
1993130561Sobrien
1994130561Sobrienextern bfd_boolean bfd_elf_reloc_symbol_deleted_p
1995130561Sobrien  (bfd_vma, void *);
1996130561Sobrien
1997218822Sdimextern struct elf_segment_map * _bfd_elf_make_dynamic_segment
1998218822Sdim  (bfd *, asection *);
1999218822Sdim
2000218822Sdimextern bfd_boolean _bfd_elf_map_sections_to_segments
2001218822Sdim  (bfd *, struct bfd_link_info *);
2002218822Sdim
2003218822Sdimextern bfd_boolean _bfd_elf_is_function_type (unsigned int);
2004218822Sdim
200589857Sobrien/* Exported interface for writing elf corefile notes. */
2006104834Sobrienextern char *elfcore_write_note
2007130561Sobrien  (bfd *, char *, int *, const char *, int, const void *, int);
2008104834Sobrienextern char *elfcore_write_prpsinfo
2009130561Sobrien  (bfd *, char *, int *, const char *, const char *);
2010104834Sobrienextern char *elfcore_write_prstatus
2011130561Sobrien  (bfd *, char *, int *, long, int, const void *);
2012104834Sobrienextern char * elfcore_write_pstatus
2013130561Sobrien  (bfd *, char *, int *, long, int, const void *);
2014104834Sobrienextern char *elfcore_write_prfpreg
2015130561Sobrien  (bfd *, char *, int *, const void *, int);
2016215679Sattilioextern char *elfcore_write_thrmisc
2017215679Sattilio  (bfd *, char *, int *, const char *, int);
2018104834Sobrienextern char *elfcore_write_prxfpreg
2019130561Sobrien  (bfd *, char *, int *, const void *, int);
2020104834Sobrienextern char *elfcore_write_lwpstatus
2021130561Sobrien  (bfd *, char *, int *, long, int, const void *);
202289857Sobrien
2023130561Sobrienextern bfd *_bfd_elf32_bfd_from_remote_memory
2024130561Sobrien  (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
2025218822Sdim   int (*target_read_memory) (bfd_vma, bfd_byte *, int));
2026130561Sobrienextern bfd *_bfd_elf64_bfd_from_remote_memory
2027130561Sobrien  (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
2028218822Sdim   int (*target_read_memory) (bfd_vma, bfd_byte *, int));
2029130561Sobrien
2030218822Sdimextern bfd_vma bfd_elf_obj_attr_size (bfd *);
2031218822Sdimextern void bfd_elf_set_obj_attr_contents (bfd *, bfd_byte *, bfd_vma);
2032218822Sdimextern int bfd_elf_get_obj_attr_int (bfd *, int, int);
2033218822Sdimextern void bfd_elf_add_obj_attr_int (bfd *, int, int, unsigned int);
2034218822Sdim#define bfd_elf_add_proc_attr_int(BFD, TAG, VALUE) \
2035218822Sdim  bfd_elf_add_obj_attr_int ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
2036218822Sdimextern void bfd_elf_add_obj_attr_string (bfd *, int, int, const char *);
2037218822Sdim#define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \
2038218822Sdim  bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
2039218822Sdimextern void bfd_elf_add_obj_attr_compat (bfd *, int, unsigned int,
2040218822Sdim					 const char *);
2041218822Sdim#define bfd_elf_add_proc_attr_compat(BFD, INTVAL, STRVAL) \
2042218822Sdim  bfd_elf_add_obj_attr_compat ((BFD), OBJ_ATTR_PROC, (INTVAL), (STRVAL))
2043218822Sdim
2044218822Sdimextern char *_bfd_elf_attr_strdup (bfd *, const char *);
2045218822Sdimextern void _bfd_elf_copy_obj_attributes (bfd *, bfd *);
2046218822Sdimextern int _bfd_elf_obj_attrs_arg_type (bfd *, int, int);
2047218822Sdimextern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *);
2048218822Sdimextern bfd_boolean _bfd_elf_merge_object_attributes (bfd *, bfd *);
2049218822Sdim
2050218822Sdim/* Large common section.  */
2051218822Sdimextern asection _bfd_elf_large_com_section;
2052218822Sdim
205360484Sobrien/* SH ELF specific routine.  */
205460484Sobrien
2055130561Sobrienextern bfd_boolean _sh_elf_set_mach_from_flags
2056130561Sobrien  (bfd *);
205760484Sobrien
2058130561Sobrien/* This is the condition under which finish_dynamic_symbol will be called.
2059130561Sobrien   If our finish_dynamic_symbol isn't called, we'll need to do something
2060130561Sobrien   about initializing any .plt and .got entries in relocate_section.  */
2061130561Sobrien#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
2062130561Sobrien  ((DYN)								\
2063218822Sdim   && ((SHARED) || !(H)->forced_local)					\
2064218822Sdim   && ((H)->dynindx != -1 || (H)->forced_local))
2065130561Sobrien
2066130561Sobrien/* This macro is to avoid lots of duplicated code in the body
2067130561Sobrien   of xxx_relocate_section() in the various elfxx-xxxx.c files.  */
2068130561Sobrien#define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel,	\
2069130561Sobrien				r_symndx, symtab_hdr, sym_hashes,	\
2070130561Sobrien				h, sec, relocation,			\
2071130561Sobrien				unresolved_reloc, warned)		\
2072130561Sobrien  do									\
2073130561Sobrien    {									\
2074130561Sobrien      /* It seems this can happen with erroneous or unsupported		\
2075130561Sobrien	 input (mixing a.out and elf in an archive, for example.)  */	\
2076130561Sobrien      if (sym_hashes == NULL)						\
2077130561Sobrien	return FALSE;							\
2078130561Sobrien									\
2079130561Sobrien      h = sym_hashes[r_symndx - symtab_hdr->sh_info];			\
2080130561Sobrien									\
2081130561Sobrien      while (h->root.type == bfd_link_hash_indirect			\
2082130561Sobrien	     || h->root.type == bfd_link_hash_warning)			\
2083130561Sobrien	h = (struct elf_link_hash_entry *) h->root.u.i.link;		\
2084130561Sobrien									\
2085130561Sobrien      warned = FALSE;							\
2086130561Sobrien      unresolved_reloc = FALSE;						\
2087130561Sobrien      relocation = 0;							\
2088130561Sobrien      if (h->root.type == bfd_link_hash_defined				\
2089130561Sobrien	  || h->root.type == bfd_link_hash_defweak)			\
2090130561Sobrien	{								\
2091130561Sobrien	  sec = h->root.u.def.section;					\
2092130561Sobrien	  if (sec == NULL						\
2093130561Sobrien	      || sec->output_section == NULL)				\
2094130561Sobrien	    /* Set a flag that will be cleared later if we find a	\
2095130561Sobrien	       relocation value for this symbol.  output_section	\
2096130561Sobrien	       is typically NULL for symbols satisfied by a shared	\
2097130561Sobrien	       library.  */						\
2098130561Sobrien	    unresolved_reloc = TRUE;					\
2099130561Sobrien	  else								\
2100130561Sobrien	    relocation = (h->root.u.def.value				\
2101130561Sobrien			  + sec->output_section->vma			\
2102130561Sobrien			  + sec->output_offset);			\
2103130561Sobrien	}								\
2104130561Sobrien      else if (h->root.type == bfd_link_hash_undefweak)			\
2105130561Sobrien	;								\
2106130561Sobrien      else if (info->unresolved_syms_in_objects == RM_IGNORE		\
2107130561Sobrien	       && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)		\
2108130561Sobrien	;								\
2109218822Sdim      else if (!info->relocatable)					\
2110130561Sobrien	{								\
2111130561Sobrien	  bfd_boolean err;						\
2112130561Sobrien	  err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR	\
2113130561Sobrien		 || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT);	\
2114130561Sobrien	  if (!info->callbacks->undefined_symbol (info,			\
2115130561Sobrien						  h->root.root.string,	\
2116130561Sobrien						  input_bfd,		\
2117130561Sobrien						  input_section,	\
2118130561Sobrien						  rel->r_offset, err))	\
2119130561Sobrien	    return FALSE;						\
2120130561Sobrien	  warned = TRUE;						\
2121130561Sobrien	}								\
2122130561Sobrien    }									\
2123130561Sobrien  while (0)
2124130561Sobrien
2125218822Sdim/* Will a symbol be bound to the the definition within the shared
2126218822Sdim   library, if any.  */
2127218822Sdim#define SYMBOLIC_BIND(INFO, H) \
2128218822Sdim    ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))
2129218822Sdim
213033965Sjdp#endif /* _LIBELF_H_ */
2131