Home | History | Annotate | Line # | Download | only in bfd
elf-bfd.h revision 1.10
      1 /* BFD back-end data structures for ELF files.
      2    Copyright (C) 1992-2022 Free Software Foundation, Inc.
      3    Written by Cygnus Support.
      4 
      5    This file is part of BFD, the Binary File Descriptor library.
      6 
      7    This program is free software; you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation; either version 3 of the License, or
     10    (at your option) any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program; if not, write to the Free Software
     19    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     20    MA 02110-1301, USA.  */
     21 
     22 #ifndef _LIBELF_H_
     23 #define _LIBELF_H_ 1
     24 
     25 #include <stdlib.h>
     26 
     27 #include "elf/common.h"
     28 #include "elf/external.h"
     29 #include "elf/internal.h"
     30 #include "bfdlink.h"
     31 
     32 #ifndef ENABLE_CHECKING
     33 #define ENABLE_CHECKING 0
     34 #endif
     35 
     36 #ifdef __cplusplus
     37 extern "C" {
     38 #endif
     39 
     40 /* The number of entries in a section is its size divided by the size
     41    of a single entry.  This is normally only applicable to reloc and
     42    symbol table sections.
     43    PR 9934: It is possible to have relocations that do not refer to
     44    symbols, thus it is also possible to have a relocation section in
     45    an object file, but no symbol table.  */
     46 #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_entsize > 0 ? (shdr)->sh_size / (shdr)->sh_entsize : 0)
     47 
     48 /* If size isn't specified as 64 or 32, NAME macro should fail.  */
     49 #ifndef NAME
     50 #if ARCH_SIZE == 64
     51 #define NAME(x, y) x ## 64 ## _ ## y
     52 #endif
     53 #if ARCH_SIZE == 32
     54 #define NAME(x, y) x ## 32 ## _ ## y
     55 #endif
     56 #endif
     57 
     58 #ifndef NAME
     59 #define NAME(x, y) x ## NOSIZE ## _ ## y
     60 #endif
     61 
     62 #define ElfNAME(X)	NAME(Elf,X)
     63 #define elfNAME(X)	NAME(elf,X)
     64 
     65 /* Information held for an ELF symbol.  The first field is the
     66    corresponding asymbol.  Every symbol is an ELF file is actually a
     67    pointer to this structure, although it is often handled as a
     68    pointer to an asymbol.  */
     69 
     70 typedef struct
     71 {
     72   /* The BFD symbol.  */
     73   asymbol symbol;
     74   /* ELF symbol information.  */
     75   Elf_Internal_Sym internal_elf_sym;
     76   /* Backend specific information.  */
     77   union
     78     {
     79       unsigned int hppa_arg_reloc;
     80       void *mips_extr;
     81       void *any;
     82     }
     83   tc_data;
     84 
     85   /* Version information.  This is from an Elf_Internal_Versym
     86      structure in a SHT_GNU_versym section.  It is zero if there is no
     87      version information.  */
     88   unsigned short version;
     89 
     90 } elf_symbol_type;
     91 
     92 struct elf_strtab_hash;
     94 struct got_entry;
     95 struct plt_entry;
     96 
     97 union gotplt_union
     98   {
     99     bfd_signed_vma refcount;
    100     bfd_vma offset;
    101     struct got_entry *glist;
    102     struct plt_entry *plist;
    103   };
    104 
    105 struct elf_link_virtual_table_entry
    106   {
    107     /* Virtual table entry use information.  This array is nominally of size
    108        size/sizeof(target_void_pointer), though we have to be able to assume
    109        and track a size while the symbol is still undefined.  It is indexed
    110        via offset/sizeof(target_void_pointer).  */
    111     size_t size;
    112     bool *used;
    113 
    114     /* Virtual table derivation info.  */
    115     struct elf_link_hash_entry *parent;
    116   };
    117 
    118 /* ELF symbol version.  */
    119 enum elf_symbol_version
    120   {
    121     unknown = 0,
    122     unversioned,
    123     versioned,
    124     versioned_hidden
    125   };
    126 
    127 /* ELF linker hash table entries.  */
    128 
    129 struct elf_link_hash_entry
    130 {
    131   struct bfd_link_hash_entry root;
    132 
    133   /* Symbol index in output file.  This is initialized to -1.  It is
    134      set to -2 if the symbol is used by a reloc.  It is set to -3 if
    135      this symbol is defined in a discarded section.  */
    136   long indx;
    137 
    138   /* Symbol index as a dynamic symbol.  Initialized to -1, and remains
    139      -1 if this is not a dynamic symbol.  */
    140   /* ??? Note that this is consistently used as a synonym for tests
    141      against whether we can perform various simplifying transformations
    142      to the code.  (E.g. changing a pc-relative jump to a PLT entry
    143      into a pc-relative jump to the target function.)  That test, which
    144      is often relatively complex, and someplaces wrong or incomplete,
    145      should really be replaced by a predicate in elflink.c.
    146 
    147      End result: this field -1 does not indicate that the symbol is
    148      not in the dynamic symbol table, but rather that the symbol is
    149      not visible outside this DSO.  */
    150   long dynindx;
    151 
    152   /* If this symbol requires an entry in the global offset table, the
    153      processor specific backend uses this field to track usage and
    154      final offset.  Two schemes are supported:  The first assumes that
    155      a symbol may only have one GOT entry, and uses REFCOUNT until
    156      size_dynamic_sections, at which point the contents of the .got is
    157      fixed.  Afterward, if OFFSET is -1, then the symbol does not
    158      require a global offset table entry.  The second scheme allows
    159      multiple GOT entries per symbol, managed via a linked list
    160      pointed to by GLIST.  */
    161   union gotplt_union got;
    162 
    163   /* Same, but tracks a procedure linkage table entry.  */
    164   union gotplt_union plt;
    165 
    166   /* Symbol size.  NB: All fields starting from here are cleared by
    167     _bfd_elf_link_hash_newfunc.  */
    168   bfd_size_type size;
    169 
    170   /* Track dynamic relocs copied for this symbol.  */
    171   struct elf_dyn_relocs *dyn_relocs;
    172 
    173   /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.).  */
    174   unsigned int type : 8;
    175 
    176   /* Symbol st_other value, symbol visibility.  */
    177   unsigned int other : 8;
    178 
    179   /* The symbol's st_target_internal value (see Elf_Internal_Sym).  */
    180   unsigned int target_internal : 8;
    181 
    182   /* Symbol is referenced by a non-shared object (other than the object
    183      in which it is defined).  */
    184   unsigned int ref_regular : 1;
    185   /* Symbol is defined by a non-shared object.  */
    186   unsigned int def_regular : 1;
    187   /* Symbol is referenced by a shared object.  */
    188   unsigned int ref_dynamic : 1;
    189   /* Symbol is defined by a shared object.  */
    190   unsigned int def_dynamic : 1;
    191   /* Symbol has a non-weak reference from a non-shared object (other than
    192      the object in which it is defined).  */
    193   unsigned int ref_regular_nonweak : 1;
    194   /* Symbol has a non-weak reference from a LTO IR object file.  */
    195   unsigned int ref_ir_nonweak : 1;
    196   /* Dynamic symbol has been adjustd.  */
    197   unsigned int dynamic_adjusted : 1;
    198   /* Symbol needs a copy reloc.  */
    199   unsigned int needs_copy : 1;
    200   /* Symbol needs a procedure linkage table entry.  */
    201   unsigned int needs_plt : 1;
    202   /* Symbol appears in a non-ELF input file.  */
    203   unsigned int non_elf : 1;
    204   /* Symbol version information.  */
    205   ENUM_BITFIELD (elf_symbol_version) versioned : 2;
    206   /* Symbol was forced to local scope due to a version script file.  */
    207   unsigned int forced_local : 1;
    208   /* Symbol was forced to be dynamic due to a version script file.  */
    209   unsigned int dynamic : 1;
    210   /* Symbol was marked during garbage collection.  */
    211   unsigned int mark : 1;
    212   /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
    213      not currently set by all the backends.  */
    214   unsigned int non_got_ref : 1;
    215   /* Symbol has a definition in a shared object.
    216      FIXME: There is no real need for this field if def_dynamic is never
    217      cleared and all places that test def_dynamic also test def_regular.  */
    218   unsigned int dynamic_def : 1;
    219   /* Symbol has a non-weak reference from a shared object.  */
    220   unsigned int ref_dynamic_nonweak : 1;
    221   /* Symbol is referenced with a relocation where C/C++ pointer equality
    222      matters.  */
    223   unsigned int pointer_equality_needed : 1;
    224   /* Symbol is a unique global symbol.  */
    225   unsigned int unique_global : 1;
    226   /* Symbol is defined by a shared library with non-default visibility
    227      in a read/write section.  */
    228   unsigned int protected_def : 1;
    229   /* Symbol is __start_SECNAME or __stop_SECNAME to mark section
    230      SECNAME.  */
    231   unsigned int start_stop : 1;
    232   /* Symbol is or was a weak defined symbol from a dynamic object with
    233      a strong defined symbol alias.  U.ALIAS points to a list of aliases,
    234      the definition having is_weakalias clear.  */
    235   unsigned int is_weakalias : 1;
    236 
    237   /* String table index in .dynstr if this is a dynamic symbol.  */
    238   unsigned long dynstr_index;
    239 
    240   union
    241   {
    242     /* Points to a circular list of non-function symbol aliases.  */
    243     struct elf_link_hash_entry *alias;
    244 
    245     /* Hash value of the name computed using the ELF hash function.
    246        Used part way through size_dynamic_sections, after we've finished
    247        with aliases.  */
    248     unsigned long elf_hash_value;
    249   } u;
    250 
    251   /* Version information.  */
    252   union
    253   {
    254     /* This field is used for a symbol which is not defined in a
    255        regular object.  It points to the version information read in
    256        from the dynamic object.  */
    257     Elf_Internal_Verdef *verdef;
    258     /* This field is used for a symbol which is defined in a regular
    259        object.  It is set up in size_dynamic_sections.  It points to
    260        the version information we should write out for this symbol.  */
    261     struct bfd_elf_version_tree *vertree;
    262   } verinfo;
    263 
    264   union
    265   {
    266     /* For __start_SECNAME and __stop_SECNAME symbols, record the first
    267        input section whose section name is SECNAME.  */
    268     asection *start_stop_section;
    269 
    270     /* Vtable information. */
    271     struct elf_link_virtual_table_entry *vtable;
    272   } u2;
    273 };
    274 
    275 /* Return the strong definition for a weak symbol with aliases.  */
    276 
    277 static inline struct elf_link_hash_entry *
    278 weakdef (struct elf_link_hash_entry *h)
    279 {
    280   while (h->is_weakalias)
    281     h = h->u.alias;
    282   return h;
    283 }
    284 
    285 /* Will references to this symbol always reference the symbol
    286    in this object?  */
    287 #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
    288   _bfd_elf_symbol_refs_local_p (H, INFO, 0)
    289 
    290 /* Will _calls_ to this symbol always call the version in this object?  */
    291 #define SYMBOL_CALLS_LOCAL(INFO, H) \
    292   _bfd_elf_symbol_refs_local_p (H, INFO, 1)
    293 
    294 /* Whether an undefined weak symbol should resolve to its link-time
    295    value, even in PIC or PIE objects.  The linker_def test is to
    296    handle symbols like __ehdr_start that may be undefweak in early
    297    stages of linking but are guaranteed to be defined later.  */
    298 #define UNDEFWEAK_NO_DYNAMIC_RELOC(INFO, H)		\
    299   ((H)->root.type == bfd_link_hash_undefweak		\
    300    && !(H)->root.linker_def				\
    301    && (ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT	\
    302        || (INFO)->dynamic_undefined_weak == 0))
    303 
    304 /* Common symbols that are turned into definitions don't have the
    305    DEF_REGULAR flag set, so they might appear to be undefined.
    306    Symbols defined in linker scripts also don't have DEF_REGULAR set.  */
    307 #define ELF_COMMON_DEF_P(H) \
    308   (!(H)->def_regular							\
    309    && !(H)->def_dynamic							\
    310    && (H)->root.type == bfd_link_hash_defined)
    311 
    312 /* Records local symbols to be emitted in the dynamic symbol table.  */
    313 
    314 struct elf_link_local_dynamic_entry
    315 {
    316   struct elf_link_local_dynamic_entry *next;
    317 
    318   /* The input bfd this symbol came from.  */
    319   bfd *input_bfd;
    320 
    321   /* The index of the local symbol being copied.  */
    322   long input_indx;
    323 
    324   /* The index in the outgoing dynamic symbol table.  */
    325   long dynindx;
    326 
    327   /* A copy of the input symbol.  */
    328   Elf_Internal_Sym isym;
    329 };
    330 
    331 struct elf_link_loaded_list
    332 {
    333   struct elf_link_loaded_list *next;
    334   bfd *abfd;
    335 };
    336 
    337 /* Structures used by the eh_frame optimization code.  */
    338 struct eh_cie_fde
    339 {
    340   union {
    341     struct {
    342       /* If REMOVED == 1, this is the CIE that the FDE originally used.
    343 	 The CIE belongs to the same .eh_frame input section as the FDE.
    344 
    345 	 If REMOVED == 0, this is the CIE that we have chosen to use for
    346 	 the output FDE.  The CIE's REMOVED field is also 0, but the CIE
    347 	 might belong to a different .eh_frame input section from the FDE.
    348 
    349 	 May be NULL to signify that the FDE should be discarded.  */
    350       struct eh_cie_fde *cie_inf;
    351       struct eh_cie_fde *next_for_section;
    352     } fde;
    353     struct {
    354       /* CIEs have three states:
    355 
    356 	 - REMOVED && !MERGED: Slated for removal because we haven't yet
    357 	   proven that an FDE needs it.  FULL_CIE, if nonnull, points to
    358 	   more detailed information about the CIE.
    359 
    360 	 - REMOVED && MERGED: We have merged this CIE with MERGED_WITH,
    361 	   which may not belong to the same input section.
    362 
    363 	 - !REMOVED: We have decided to keep this CIE.  SEC is the
    364 	   .eh_frame input section that contains the CIE.  */
    365       union {
    366 	struct cie *full_cie;
    367 	struct eh_cie_fde *merged_with;
    368 	asection *sec;
    369       } u;
    370 
    371       /* The offset of the personality data from the start of the CIE,
    372 	 or 0 if the CIE doesn't have any.  */
    373       unsigned int personality_offset : 8;
    374 
    375       /* Length of augmentation.  aug_str_len is the length of the
    376 	 string including null terminator.  aug_data_len is the length
    377 	 of the rest up to the initial insns.  */
    378       unsigned int aug_str_len : 3;
    379       unsigned int aug_data_len : 5;
    380 
    381       /* True if we have marked relocations associated with this CIE.  */
    382       unsigned int gc_mark : 1;
    383 
    384       /* True if we have decided to turn an absolute LSDA encoding into
    385 	 a PC-relative one.  */
    386       unsigned int make_lsda_relative : 1;
    387 
    388       /* True if we have decided to turn an absolute personality
    389 	 encoding into a PC-relative one.  */
    390       unsigned int make_per_encoding_relative : 1;
    391 
    392       /* True if the CIE contains personality data and if that
    393 	 data uses a PC-relative encoding.  Always true when
    394 	 make_per_encoding_relative is.  */
    395       unsigned int per_encoding_relative : 1;
    396 
    397       /* True if the CIE contains personality data aligned to a
    398 	 multiple of eight bytes.  */
    399       unsigned int per_encoding_aligned8 : 1;
    400 
    401       /* True if we need to add an 'R' (FDE encoding) entry to the
    402 	 CIE's augmentation data.  */
    403       unsigned int add_fde_encoding : 1;
    404 
    405       /* True if we have merged this CIE with another.  */
    406       unsigned int merged : 1;
    407 
    408       /* Unused bits.  */
    409       unsigned int pad1 : 9;
    410     } cie;
    411   } u;
    412   unsigned int reloc_index;
    413   unsigned int size;
    414   unsigned int offset;
    415   unsigned int new_offset;
    416   unsigned int fde_encoding : 8;
    417   unsigned int lsda_encoding : 8;
    418   unsigned int lsda_offset : 8;
    419 
    420   /* True if this entry represents a CIE, false if it represents an FDE.  */
    421   unsigned int cie : 1;
    422 
    423   /* True if this entry is currently marked for removal.  */
    424   unsigned int removed : 1;
    425 
    426   /* True if we need to add a 'z' (augmentation size) entry to the CIE's
    427      augmentation data, and an associated byte to each of the CIE's FDEs.  */
    428   unsigned int add_augmentation_size : 1;
    429 
    430   /* True if we have decided to convert absolute FDE relocations into
    431      relative ones.  This applies to the first relocation in the FDE,
    432      which is against the code that the FDE describes.  */
    433   unsigned int make_relative : 1;
    434 
    435   /* Unused bits.  */
    436   unsigned int pad1 : 4;
    437 
    438   unsigned int *set_loc;
    439 };
    440 
    441 struct eh_frame_sec_info
    442 {
    443   unsigned int count;
    444   struct cie *cies;
    445   struct eh_cie_fde entry[1];
    446 };
    447 
    448 struct eh_frame_array_ent
    449 {
    450   bfd_vma initial_loc;
    451   bfd_size_type range;
    452   bfd_vma fde;
    453 };
    454 
    455 struct htab;
    456 
    457 #define DWARF2_EH_HDR 1
    458 #define COMPACT_EH_HDR 2
    459 
    460 /* Endian-neutral code indicating that a function cannot be unwound.  */
    461 #define COMPACT_EH_CANT_UNWIND_OPCODE 0x015d5d01
    462 
    463 struct dwarf_eh_frame_hdr_info
    464 {
    465   struct htab *cies;
    466   unsigned int fde_count;
    467   /* TRUE if .eh_frame_hdr should contain the sorted search table.
    468      We build it if we successfully read all .eh_frame input sections
    469      and recognize them.  */
    470   bool table;
    471   struct eh_frame_array_ent *array;
    472 };
    473 
    474 struct compact_eh_frame_hdr_info
    475 {
    476   unsigned int allocated_entries;
    477   /* eh_frame_entry fragments.  */
    478   asection **entries;
    479 };
    480 
    481 struct eh_frame_hdr_info
    482 {
    483   asection *hdr_sec;
    484   unsigned int array_count;
    485   bool frame_hdr_is_compact;
    486   union
    487     {
    488       struct dwarf_eh_frame_hdr_info dwarf;
    489       struct compact_eh_frame_hdr_info compact;
    490     }
    491   u;
    492 };
    493 
    494 /* Additional information for each function (used at link time).  */
    495 struct sframe_func_bfdinfo
    496 {
    497   /* Whether the function has been discarded from the final output.  */
    498   bool func_deleted_p;
    499   /* Relocation offset.  */
    500   unsigned int func_r_offset;
    501   /* Relocation index.  */
    502   unsigned int func_reloc_index;
    503 };
    504 
    505 /* SFrame decoder info.
    506    Contains all information for a decoded .sframe section.  */
    507 struct sframe_dec_info
    508 {
    509   /* Decoder context.  */
    510   struct sframe_decoder_ctx *sfd_ctx;
    511   /* Number of function descriptor entries in this .sframe.  */
    512   unsigned int sfd_fde_count;
    513   /* Additional information for linking.  */
    514   struct sframe_func_bfdinfo *sfd_func_bfdinfo;
    515 };
    516 
    517 /* SFrame encoder info.
    518    Contains all information for an encoded .sframe section to be
    519    written out.  */
    520 struct sframe_enc_info
    521 {
    522   /* Encoder context.  */
    523   struct sframe_encoder_ctx *sfe_ctx;
    524   /* Output section.  */
    525   asection *sframe_section;
    526 };
    527 
    528 /* Enum used to identify target specific extensions to the elf_obj_tdata
    529    and elf_link_hash_table structures.  Note the enums deliberately start
    530    from 1 so that we can detect an uninitialized field.  The generic value
    531    is last so that additions to this enum do not need to modify more than
    532    one line.  */
    533 enum elf_target_id
    534 {
    535   AARCH64_ELF_DATA = 1,
    536   ALPHA_ELF_DATA,
    537   AMDGCN_ELF_DATA,
    538   ARC_ELF_DATA,
    539   ARM_ELF_DATA,
    540   AVR_ELF_DATA,
    541   BFIN_ELF_DATA,
    542   CRIS_ELF_DATA,
    543   CSKY_ELF_DATA,
    544   FRV_ELF_DATA,
    545   HPPA32_ELF_DATA,
    546   HPPA64_ELF_DATA,
    547   I386_ELF_DATA,
    548   IA64_ELF_DATA,
    549   LM32_ELF_DATA,
    550   LARCH_ELF_DATA,
    551   M32R_ELF_DATA,
    552   M68HC11_ELF_DATA,
    553   M68K_ELF_DATA,
    554   METAG_ELF_DATA,
    555   MICROBLAZE_ELF_DATA,
    556   MIPS_ELF_DATA,
    557   MN10300_ELF_DATA,
    558   NDS32_ELF_DATA,
    559   NIOS2_ELF_DATA,
    560   OR1K_ELF_DATA,
    561   PPC32_ELF_DATA,
    562   PPC64_ELF_DATA,
    563   PRU_ELF_DATA,
    564   S390_ELF_DATA,
    565   SH_ELF_DATA,
    566   SPARC_ELF_DATA,
    567   SPU_ELF_DATA,
    568   TIC6X_ELF_DATA,
    569   X86_64_ELF_DATA,
    570   XTENSA_ELF_DATA,
    571   TILEGX_ELF_DATA,
    572   TILEPRO_ELF_DATA,
    573   RISCV_ELF_DATA,
    574   GENERIC_ELF_DATA
    575 };
    576 
    577 struct elf_sym_strtab
    578 {
    579   Elf_Internal_Sym sym;
    580   unsigned long dest_index;
    581 };
    582 
    583 struct bfd_link_needed_list
    584 {
    585   struct bfd_link_needed_list *next;
    586   bfd *by;
    587   const char *name;
    588 };
    589 
    590 enum elf_target_os
    591 {
    592   is_normal,
    593   is_solaris,	/* Solaris.  */
    594   is_vxworks,	/* VxWorks.  */
    595   is_nacl	/* Native Client.  */
    596 };
    597 
    598 /* Used by bfd_sym_from_r_symndx to cache a small number of local
    599    symbols.  */
    600 #define LOCAL_SYM_CACHE_SIZE 32
    601 struct sym_cache
    602 {
    603   bfd *abfd;
    604   unsigned long indx[LOCAL_SYM_CACHE_SIZE];
    605   Elf_Internal_Sym sym[LOCAL_SYM_CACHE_SIZE];
    606 };
    607 
    608 /* ELF linker hash table.  */
    609 
    610 struct elf_link_hash_table
    611 {
    612   struct bfd_link_hash_table root;
    613 
    614   /* An identifier used to distinguish different target
    615      specific extensions to this structure.  */
    616   enum elf_target_id hash_table_id;
    617 
    618   /* Whether we have created the special dynamic sections required
    619      when linking against or generating a shared object.  */
    620   bool dynamic_sections_created;
    621 
    622   /* Whether dynamic relocations are present.  */
    623   bool dynamic_relocs;
    624 
    625   /* True if this target has relocatable executables, so needs dynamic
    626      section symbols.  */
    627   bool is_relocatable_executable;
    628 
    629   /* TRUE if there are IFUNC resolvers.  */
    630   bool ifunc_resolvers;
    631 
    632   /* TRUE if DT_PLTGOT is a required dynamic tag.  */
    633   bool dt_pltgot_required;
    634 
    635   /* TRUE if DT_JMPREL is a required dynamic tag.  */
    636   bool dt_jmprel_required;
    637 
    638   /* TRUE when we are handling DT_NEEDED entries.  */
    639   bool handling_dt_needed;
    640 
    641   /* The BFD used to hold special sections created by the linker.
    642      This will be the first BFD found which requires these sections to
    643      be created.  */
    644   bfd *dynobj;
    645 
    646   /* The value to use when initialising got.refcount/offset and
    647      plt.refcount/offset in an elf_link_hash_entry.  Set to zero when
    648      the values are refcounts.  Set to init_got_offset/init_plt_offset
    649      in size_dynamic_sections when the values may be offsets.  */
    650   union gotplt_union init_got_refcount;
    651   union gotplt_union init_plt_refcount;
    652 
    653   /* The value to use for got.refcount/offset and plt.refcount/offset
    654      when the values may be offsets.  Normally (bfd_vma) -1.  */
    655   union gotplt_union init_got_offset;
    656   union gotplt_union init_plt_offset;
    657 
    658   /* The number of symbols found in the link which is intended for the
    659      mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section.  */
    660   bfd_size_type dynsymcount;
    661   bfd_size_type local_dynsymcount;
    662 
    663   /* The string table of dynamic symbols, which becomes the .dynstr
    664      section.  */
    665   struct elf_strtab_hash *dynstr;
    666 
    667   /* The array size of the symbol string table, which becomes the
    668      .strtab section.  */
    669   bfd_size_type strtabsize;
    670 
    671   /* The array of strings, which becomes the .strtab section.  */
    672   struct elf_sym_strtab *strtab;
    673 
    674   /* The number of buckets in the hash table in the .hash section.
    675      This is based on the number of dynamic symbols.  */
    676   bfd_size_type bucketcount;
    677 
    678   /* A linked list of DT_NEEDED names found in dynamic objects
    679      included in the link.  */
    680   struct bfd_link_needed_list *needed;
    681 
    682   /* Sections in the output bfd that provides a section symbol
    683      to be used by relocations emitted against local symbols.
    684      Most targets will not use data_index_section.  */
    685   asection *text_index_section;
    686   asection *data_index_section;
    687 
    688   /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
    689   struct elf_link_hash_entry *hgot;
    690 
    691   /* The _PROCEDURE_LINKAGE_TABLE_ symbol.  */
    692   struct elf_link_hash_entry *hplt;
    693 
    694   /* The _DYNAMIC symbol.  */
    695   struct elf_link_hash_entry *hdynamic;
    696 
    697   /* A pointer to information used to merge SEC_MERGE sections.  */
    698   void *merge_info;
    699 
    700   /* Used to link stabs in sections.  */
    701   struct stab_info stab_info;
    702 
    703   /* Used by eh_frame code when editing .eh_frame.  */
    704   struct eh_frame_hdr_info eh_info;
    705 
    706   /* Used to link unwind data in .sframe sections.  */
    707   struct sframe_enc_info sfe_info;
    708 
    709   /* A linked list of local symbols to be added to .dynsym.  */
    710   struct elf_link_local_dynamic_entry *dynlocal;
    711 
    712   /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
    713      objects included in the link.  */
    714   struct bfd_link_needed_list *runpath;
    715 
    716   /* Cached first output tls section and size of PT_TLS segment.  */
    717   asection *tls_sec;
    718   bfd_size_type tls_size;  /* Bytes.  */
    719 
    720   /* The offset into splt of the PLT entry for the TLS descriptor
    721      resolver.  Special values are 0, if not necessary (or not found
    722      to be necessary yet), and -1 if needed but not determined
    723      yet.  */
    724   bfd_vma tlsdesc_plt;
    725 
    726   /* The GOT offset for the lazy trampoline.  Communicated to the
    727      loader via DT_TLSDESC_GOT.  The magic value (bfd_vma) -1
    728      indicates an offset is not allocated.  */
    729   bfd_vma tlsdesc_got;
    730 
    731   /* Target OS for linker output.  */
    732   enum elf_target_os target_os;
    733 
    734   /* A linked list of dynamic BFD's loaded in the link.  */
    735   struct elf_link_loaded_list *dyn_loaded;
    736 
    737   /* Small local sym cache.  */
    738   struct sym_cache sym_cache;
    739 
    740   /* Short-cuts to get to dynamic linker sections.  */
    741   asection *sgot;
    742   asection *sgotplt;
    743   asection *srelgot;
    744   asection *splt;
    745   asection *srelplt;
    746   asection *sdynbss;
    747   asection *srelbss;
    748   asection *sdynrelro;
    749   asection *sreldynrelro;
    750   asection *igotplt;
    751   asection *iplt;
    752   asection *irelplt;
    753   asection *irelifunc;
    754   asection *dynsym;
    755   asection *srelrdyn;
    756 };
    757 
    758 /* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
    759 
    760 static inline bool
    761 is_elf_hash_table (const struct bfd_link_hash_table *htab)
    762 {
    763   return htab->type == bfd_link_elf_hash_table;
    764 }
    765 
    766 /* Look up an entry in an ELF linker hash table.  */
    767 
    768 static inline struct elf_link_hash_entry *
    769 elf_link_hash_lookup (struct elf_link_hash_table *table, const char *string,
    770 		      bool create, bool copy, bool follow)
    771 {
    772   if (ENABLE_CHECKING && !is_elf_hash_table (&table->root))
    773     abort ();
    774   return (struct elf_link_hash_entry *)
    775     bfd_link_hash_lookup (&table->root, string, create, copy, follow);
    776 }
    777 
    778 /* Traverse an ELF linker hash table.  */
    779 
    780 static inline void
    781 elf_link_hash_traverse (struct elf_link_hash_table *table,
    782 			bool (*f) (struct elf_link_hash_entry *, void *),
    783 			void *info)
    784 {
    785   if (ENABLE_CHECKING && !is_elf_hash_table (&table->root))
    786     abort ();
    787   bfd_link_hash_traverse (&table->root,
    788 			  (bool (*) (struct bfd_link_hash_entry *, void *)) f,
    789 			  info);
    790 }
    791 
    792 /* Get the ELF linker hash table from a link_info structure.  */
    793 
    794 static inline struct elf_link_hash_table *
    795 elf_hash_table (const struct bfd_link_info *info)
    796 {
    797   return (struct elf_link_hash_table *) info->hash;
    798 }
    799 
    800 static inline enum elf_target_id
    801 elf_hash_table_id (const struct elf_link_hash_table *table)
    802 {
    803   return table->hash_table_id;
    804 }
    805 
    806 /* Constant information held for an ELF backend.  */
    808 
    809 struct elf_size_info {
    810   unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
    811   unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
    812 
    813   /* The size of entries in the .hash section.  */
    814   unsigned char sizeof_hash_entry;
    815 
    816   /* The number of internal relocations to allocate per external
    817      relocation entry.  */
    818   unsigned char int_rels_per_ext_rel;
    819   /* We use some fixed size arrays.  This should be large enough to
    820      handle all back-ends.  */
    821 #define MAX_INT_RELS_PER_EXT_REL 3
    822 
    823   unsigned char arch_size, log_file_align;
    824   unsigned char elfclass, ev_current;
    825   int (*write_out_phdrs)
    826     (bfd *, const Elf_Internal_Phdr *, unsigned int);
    827   bool (*write_shdrs_and_ehdr) (bfd *);
    828   bool (*checksum_contents)
    829     (bfd * , void (*) (const void *, size_t, void *), void *);
    830   void (*write_relocs)
    831     (bfd *, asection *, void *);
    832   bool (*swap_symbol_in)
    833     (bfd *, const void *, const void *, Elf_Internal_Sym *);
    834   void (*swap_symbol_out)
    835     (bfd *, const Elf_Internal_Sym *, void *, void *);
    836   bool (*slurp_reloc_table)
    837     (bfd *, asection *, asymbol **, bool);
    838   long (*slurp_symbol_table)
    839     (bfd *, asymbol **, bool);
    840   void (*swap_dyn_in)
    841     (bfd *, const void *, Elf_Internal_Dyn *);
    842   void (*swap_dyn_out)
    843     (bfd *, const Elf_Internal_Dyn *, void *);
    844 
    845   /* This function is called to swap in a REL relocation.  If an
    846      external relocation corresponds to more than one internal
    847      relocation, then all relocations are swapped in at once.  */
    848   void (*swap_reloc_in)
    849     (bfd *, const bfd_byte *, Elf_Internal_Rela *);
    850 
    851   /* This function is called to swap out a REL relocation.  */
    852   void (*swap_reloc_out)
    853     (bfd *, const Elf_Internal_Rela *, bfd_byte *);
    854 
    855   /* This function is called to swap in a RELA relocation.  If an
    856      external relocation corresponds to more than one internal
    857      relocation, then all relocations are swapped in at once.  */
    858   void (*swap_reloca_in)
    859     (bfd *, const bfd_byte *, Elf_Internal_Rela *);
    860 
    861   /* This function is called to swap out a RELA relocation.  */
    862   void (*swap_reloca_out)
    863     (bfd *, const Elf_Internal_Rela *, bfd_byte *);
    864 };
    865 
    866 #define elf_symbol_from(S) \
    867   ((((S)->flags & BSF_SYNTHETIC) == 0				\
    868     && (S)->the_bfd != NULL					\
    869     && (S)->the_bfd->xvec->flavour == bfd_target_elf_flavour	\
    870     && (S)->the_bfd->tdata.elf_obj_data != 0)			\
    871    ? (elf_symbol_type *) (S)					\
    872    : 0)
    873 
    874 enum elf_reloc_type_class {
    875   reloc_class_normal,
    876   reloc_class_relative,
    877   reloc_class_copy,
    878   reloc_class_ifunc,
    879   reloc_class_plt
    880 };
    881 
    882 struct elf_reloc_cookie
    883 {
    884   Elf_Internal_Rela *rels, *rel, *relend;
    885   Elf_Internal_Sym *locsyms;
    886   bfd *abfd;
    887   size_t locsymcount;
    888   size_t extsymoff;
    889   struct elf_link_hash_entry **sym_hashes;
    890   int r_sym_shift;
    891   bool bad_symtab;
    892 };
    893 
    894 /* The level of IRIX compatibility we're striving for.  */
    895 
    896 typedef enum {
    897   ict_none,
    898   ict_irix5,
    899   ict_irix6
    900 } irix_compat_t;
    901 
    902 /* Mapping of ELF section names and types.  */
    903 struct bfd_elf_special_section
    904 {
    905   const char *prefix;
    906   unsigned int prefix_length;
    907   /* 0 means name must match PREFIX exactly.
    908      -1 means name must start with PREFIX followed by an arbitrary string.
    909      -2 means name must match PREFIX exactly or consist of PREFIX followed
    910      by a dot then anything.
    911      > 0 means name must start with the first PREFIX_LENGTH chars of
    912      PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX.  */
    913   signed int suffix_length;
    914   unsigned int type;
    915   bfd_vma attr;
    916 };
    917 
    918 enum action_discarded
    919   {
    920     COMPLAIN = 1,
    921     PRETEND = 2
    922   };
    923 
    924 typedef asection * (*elf_gc_mark_hook_fn)
    925   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
    926    struct elf_link_hash_entry *, Elf_Internal_Sym *);
    927 
    928 enum elf_property_kind
    929  {
    930     /* A new property.  */
    931     property_unknown = 0,
    932     /* A property ignored by backend.  */
    933     property_ignored,
    934     /* A corrupt property reported by backend.  */
    935     property_corrupt,
    936     /* A property should be removed due to property merge.  */
    937     property_remove,
    938     /* A property which is a number.  */
    939     property_number
    940  };
    941 
    942 typedef struct elf_property
    943 {
    944   unsigned int pr_type;
    945   unsigned int pr_datasz;
    946   union
    947     {
    948       /* For property_number, this is a number.  */
    949       bfd_vma number;
    950       /* Add a new one if elf_property_kind is updated.  */
    951     } u;
    952   enum elf_property_kind pr_kind;
    953 } elf_property;
    954 
    955 typedef struct elf_property_list
    956 {
    957   struct elf_property_list *next;
    958   struct elf_property property;
    959 } elf_property_list;
    960 
    961 struct bfd_elf_section_reloc_data;
    962 
    963 struct elf_backend_data
    964 {
    965   /* The architecture for this backend.  */
    966   enum bfd_architecture arch;
    967 
    968   /* An identifier used to distinguish different target specific
    969      extensions to elf_obj_tdata and elf_link_hash_table structures.  */
    970   enum elf_target_id target_id;
    971 
    972   /* Target OS.  */
    973   enum elf_target_os target_os;
    974 
    975   /* The ELF machine code (EM_xxxx) for this backend.  */
    976   int elf_machine_code;
    977 
    978   /* EI_OSABI.  */
    979   int elf_osabi;
    980 
    981   /* The maximum page size for this backend.  */
    982   bfd_vma maxpagesize;
    983 
    984   /* The minimum page size for this backend.  An input object will not be
    985      considered page aligned unless its sections are correctly aligned for
    986      pages at least this large.  May be smaller than maxpagesize.  */
    987   bfd_vma minpagesize;
    988 
    989   /* The common page size for this backend.  */
    990   bfd_vma commonpagesize;
    991 
    992   /* The p_align value for this backend.  If it is set, p_align of
    993       PT_LOAD alignment will be to p_align by default.  */
    994   bfd_vma p_align;
    995 
    996   /* The BFD flags applied to sections created for dynamic linking.  */
    997   flagword dynamic_sec_flags;
    998 
    999   /* Architecture-specific data for this backend.
   1000      This is actually a pointer to some type like struct elf_ARCH_data.  */
   1001   const void *arch_data;
   1002 
   1003   /* A function to translate an ELF RELA relocation to a BFD arelent
   1004      structure.  Returns TRUE upon success, FALSE otherwise.  */
   1005   bool (*elf_info_to_howto)
   1006     (bfd *, arelent *, Elf_Internal_Rela *);
   1007 
   1008   /* A function to translate an ELF REL relocation to a BFD arelent
   1009      structure.  Returns TRUE upon success, FALSE otherwise.  */
   1010   bool (*elf_info_to_howto_rel)
   1011     (bfd *, arelent *, Elf_Internal_Rela *);
   1012 
   1013   /* A function to determine whether a symbol is global when
   1014      partitioning the symbol table into local and global symbols.
   1015      This should be NULL for most targets, in which case the correct
   1016      thing will be done.  MIPS ELF, at least on the Irix 5, has
   1017      special requirements.  */
   1018   bool (*elf_backend_sym_is_global)
   1019     (bfd *, asymbol *);
   1020 
   1021   /* The remaining functions are hooks which are called only if they
   1022      are not NULL.  */
   1023 
   1024   /* A function to permit a backend specific check on whether a
   1025      particular BFD format is relevant for an object file, and to
   1026      permit the backend to set any global information it wishes.  When
   1027      this is called elf_elfheader is set, but anything else should be
   1028      used with caution.  If this returns FALSE, the check_format
   1029      routine will return a bfd_error_wrong_format error.  */
   1030   bool (*elf_backend_object_p)
   1031     (bfd *);
   1032 
   1033   /* A function to do additional symbol processing when reading the
   1034      ELF symbol table.  This is where any processor-specific special
   1035      section indices are handled.  */
   1036   void (*elf_backend_symbol_processing)
   1037     (bfd *, asymbol *);
   1038 
   1039   /* A function to do additional symbol processing after reading the
   1040      entire ELF symbol table.  */
   1041   bool (*elf_backend_symbol_table_processing)
   1042     (bfd *, elf_symbol_type *, unsigned int);
   1043 
   1044   /* A function to set the type of the info field.  Processor-specific
   1045      types should be handled here.  */
   1046   int (*elf_backend_get_symbol_type)
   1047     (Elf_Internal_Sym *, int);
   1048 
   1049   /* A function to return the linker hash table entry of a symbol that
   1050      might be satisfied by an archive symbol.  */
   1051   struct bfd_link_hash_entry * (*elf_backend_archive_symbol_lookup)
   1052     (bfd *, struct bfd_link_info *, const char *);
   1053 
   1054   /* Return true if local section symbols should have a non-null st_name.
   1055      NULL implies false.  */
   1056   bool (*elf_backend_name_local_section_symbols)
   1057     (bfd *);
   1058 
   1059   /* A function to do additional processing on the ELF section header
   1060      just before writing it out.  This is used to set the flags and
   1061      type fields for some sections, or to actually write out data for
   1062      unusual sections.  */
   1063   bool (*elf_backend_section_processing)
   1064     (bfd *, Elf_Internal_Shdr *);
   1065 
   1066   /* A function to handle unusual section types when creating BFD
   1067      sections from ELF sections.  */
   1068   bool (*elf_backend_section_from_shdr)
   1069     (bfd *, Elf_Internal_Shdr *, const char *, int);
   1070 
   1071   /* A function to convert machine dependent ELF section header flags to
   1072      BFD internal section header flags.  */
   1073   bool (*elf_backend_section_flags)
   1074     (const Elf_Internal_Shdr *);
   1075 
   1076   /* A function that returns a struct containing ELF section flags and
   1077      type for the given BFD section.   */
   1078   const struct bfd_elf_special_section * (*get_sec_type_attr)
   1079     (bfd *, asection *);
   1080 
   1081   /* A function to handle unusual program segment types when creating BFD
   1082      sections from ELF program segments.  */
   1083   bool (*elf_backend_section_from_phdr)
   1084     (bfd *, Elf_Internal_Phdr *, int, const char *);
   1085 
   1086   /* A function to set up the ELF section header for a BFD section in
   1087      preparation for writing it out.  This is where the flags and type
   1088      fields are set for unusual sections.  */
   1089   bool (*elf_backend_fake_sections)
   1090     (bfd *, Elf_Internal_Shdr *, asection *);
   1091 
   1092   /* A function to get the ELF section index for a BFD section.  If
   1093      this returns TRUE, the section was found.  If it is a normal ELF
   1094      section, *RETVAL should be left unchanged.  If it is not a normal
   1095      ELF section *RETVAL should be set to the SHN_xxxx index.  */
   1096   bool (*elf_backend_section_from_bfd_section)
   1097     (bfd *, asection *, int *retval);
   1098 
   1099   /* If this field is not NULL, it is called by the add_symbols phase
   1100      of a link just before adding a symbol to the global linker hash
   1101      table.  It may modify any of the fields as it wishes.  If *NAME
   1102      is set to NULL, the symbol will be skipped rather than being
   1103      added to the hash table.  This function is responsible for
   1104      handling all processor dependent symbol bindings and section
   1105      indices, and must set at least *FLAGS and *SEC for each processor
   1106      dependent case; failure to do so will cause a link error.  */
   1107   bool (*elf_add_symbol_hook)
   1108     (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *,
   1109      const char **name, flagword *flags, asection **sec, bfd_vma *value);
   1110 
   1111   /* If this field is not NULL, it is called by the elf_link_output_sym
   1112      phase of a link for each symbol which will appear in the object file.
   1113      On error, this function returns 0.  1 is returned when the symbol
   1114      should be output, 2 is returned when the symbol should be discarded.  */
   1115   int (*elf_backend_link_output_symbol_hook)
   1116     (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
   1117      asection *, struct elf_link_hash_entry *);
   1118 
   1119   /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
   1120      linker the first time it encounters a dynamic object in the link.
   1121      This function must create any sections required for dynamic
   1122      linking.  The ABFD argument is a dynamic object.  The .interp,
   1123      .dynamic, .dynsym, .dynstr, and .hash functions have already been
   1124      created, and this function may modify the section flags if
   1125      desired.  This function will normally create the .got and .plt
   1126      sections, but different backends have different requirements.  */
   1127   bool (*elf_backend_create_dynamic_sections)
   1128     (bfd *abfd, struct bfd_link_info *info);
   1129 
   1130   /* When creating a shared library, determine whether to omit the
   1131      dynamic symbol for the section.  */
   1132   bool (*elf_backend_omit_section_dynsym)
   1133     (bfd *output_bfd, struct bfd_link_info *info, asection *osec);
   1134 
   1135   /* Return TRUE if relocations of targets are compatible to the extent
   1136      that CHECK_RELOCS will properly process them.  PR 4424.  */
   1137   bool (*relocs_compatible) (const bfd_target *, const bfd_target *);
   1138 
   1139   /* The CHECK_RELOCS function is called after all input files have been
   1140      opened.  It is called once for each section with relocs of an object
   1141      file.  The function must look through the relocs and do any special
   1142      handling required.  This generally means allocating space in the
   1143      global offset table, and perhaps allocating space for a reloc.  The
   1144      relocs are always passed as Rela structures; if the section
   1145      actually uses Rel structures, the r_addend field will always be
   1146      zero.  */
   1147   bool (*check_relocs)
   1148     (bfd *abfd, struct bfd_link_info *info, asection *o,
   1149      const Elf_Internal_Rela *relocs);
   1150 
   1151   /* The SIZE_RELATIVE_RELOCS function is called to size relative
   1152      relocations when mappig sections to segments.  */
   1153   bool (*size_relative_relocs)
   1154     (struct bfd_link_info *info, bool *need_layout);
   1155 
   1156   /* The FINISH_RELATIVE_RELOCS function is called to finish relative
   1157      relocations in bfd_elf_final_link.  */
   1158   bool (*finish_relative_relocs)
   1159     (struct bfd_link_info *info);
   1160 
   1161   /* The CHECK_DIRECTIVES function is called once per input file by
   1162      the add_symbols phase of the ELF backend linker.  The function
   1163      must inspect the bfd and create any additional symbols according
   1164      to any custom directives in the bfd.  */
   1165   bool (*check_directives)
   1166     (bfd *abfd, struct bfd_link_info *info);
   1167 
   1168   /* The NOTICE_AS_NEEDED function is called as the linker is about to
   1169      handle an as-needed lib (ACT = notice_as_needed), and after the
   1170      linker has decided to keep the lib (ACT = notice_needed) or when
   1171      the lib is not needed (ACT = notice_not_needed).  */
   1172   bool (*notice_as_needed)
   1173     (bfd *abfd, struct bfd_link_info *info, enum notice_asneeded_action act);
   1174 
   1175   /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
   1176      linker for every symbol which is defined by a dynamic object and
   1177      referenced by a regular object.  This is called after all the
   1178      input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
   1179      function has been called.  The hash table entry should be
   1180      bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
   1181      defined in a section from a dynamic object.  Dynamic object
   1182      sections are not included in the final link, and this function is
   1183      responsible for changing the value to something which the rest of
   1184      the link can deal with.  This will normally involve adding an
   1185      entry to the .plt or .got or some such section, and setting the
   1186      symbol to point to that.  */
   1187   bool (*elf_backend_adjust_dynamic_symbol)
   1188     (struct bfd_link_info *info, struct elf_link_hash_entry *h);
   1189 
   1190   /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
   1191      after all the linker input files have been seen but before the
   1192      section sizes have been set.  This is called after
   1193      ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS.  */
   1194   bool (*elf_backend_always_size_sections)
   1195     (bfd *output_bfd, struct bfd_link_info *info);
   1196 
   1197   /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
   1198      linker after all the linker input files have been seen but before
   1199      the sections sizes have been set.  This is called after
   1200      ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
   1201      It is only called when linking against a dynamic object.  It must
   1202      set the sizes of the dynamic sections, and may fill in their
   1203      contents as well.  The generic ELF linker can handle the .dynsym,
   1204      .dynstr and .hash sections.  This function must handle the
   1205      .interp section and any sections created by the
   1206      CREATE_DYNAMIC_SECTIONS entry point.  */
   1207   bool (*elf_backend_size_dynamic_sections)
   1208     (bfd *output_bfd, struct bfd_link_info *info);
   1209 
   1210   /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the
   1211      ELF backend linker to strip zero-sized dynamic sections after
   1212      the section sizes have been set.  */
   1213   bool (*elf_backend_strip_zero_sized_dynamic_sections)
   1214     (struct bfd_link_info *info);
   1215 
   1216   /* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
   1217      we keep to use as a base for relocs and symbols.  */
   1218   void (*elf_backend_init_index_section)
   1219     (bfd *output_bfd, struct bfd_link_info *info);
   1220 
   1221   /* The RELOCATE_SECTION function is called by the ELF backend linker
   1222      to handle the relocations for a section.
   1223 
   1224      The relocs are always passed as Rela structures; if the section
   1225      actually uses Rel structures, the r_addend field will always be
   1226      zero.
   1227 
   1228      This function is responsible for adjust the section contents as
   1229      necessary, and (if using Rela relocs and generating a
   1230      relocatable output file) adjusting the reloc addend as
   1231      necessary.
   1232 
   1233      This function does not have to worry about setting the reloc
   1234      address or the reloc symbol index.
   1235 
   1236      LOCAL_SYMS is a pointer to the swapped in local symbols.
   1237 
   1238      LOCAL_SECTIONS is an array giving the section in the input file
   1239      corresponding to the st_shndx field of each local symbol.
   1240 
   1241      The global hash table entry for the global symbols can be found
   1242      via elf_sym_hashes (input_bfd).
   1243 
   1244      When generating relocatable output, this function must handle
   1245      STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
   1246      going to be the section symbol corresponding to the output
   1247      section, which means that the addend must be adjusted
   1248      accordingly.
   1249 
   1250      Returns FALSE on error, TRUE on success, 2 if successful and
   1251      relocations should be written for this section.  */
   1252   int (*elf_backend_relocate_section)
   1253     (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd,
   1254      asection *input_section, bfd_byte *contents, Elf_Internal_Rela *relocs,
   1255      Elf_Internal_Sym *local_syms, asection **local_sections);
   1256 
   1257   /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
   1258      linker just before it writes a symbol out to the .dynsym section.
   1259      The processor backend may make any required adjustment to the
   1260      symbol.  It may also take the opportunity to set contents of the
   1261      dynamic sections.  Note that FINISH_DYNAMIC_SYMBOL is called on
   1262      all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
   1263      on those symbols which are defined by a dynamic object.  */
   1264   bool (*elf_backend_finish_dynamic_symbol)
   1265     (bfd *output_bfd, struct bfd_link_info *info,
   1266      struct elf_link_hash_entry *h, Elf_Internal_Sym *sym);
   1267 
   1268   /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
   1269      linker just before it writes all the dynamic sections out to the
   1270      output file.  The FINISH_DYNAMIC_SYMBOL will have been called on
   1271      all dynamic symbols.  */
   1272   bool (*elf_backend_finish_dynamic_sections)
   1273     (bfd *output_bfd, struct bfd_link_info *info);
   1274 
   1275   /* A function to do any beginning processing needed for the ELF file
   1276      before building the ELF headers and computing file positions.  */
   1277   void (*elf_backend_begin_write_processing)
   1278     (bfd *, struct bfd_link_info *);
   1279 
   1280   /* A function to do any final processing needed for the ELF file
   1281      before writing it out.  */
   1282   bool (*elf_backend_final_write_processing)
   1283     (bfd *);
   1284 
   1285   /* This function is called by get_program_header_size.  It should
   1286      return the number of additional program segments which this BFD
   1287      will need.  It should return -1 on error.  */
   1288   int (*elf_backend_additional_program_headers)
   1289     (bfd *, struct bfd_link_info *);
   1290 
   1291   /* This function is called to modify an existing segment map in a
   1292      backend specific fashion.  */
   1293   bool (*elf_backend_modify_segment_map)
   1294     (bfd *, struct bfd_link_info *);
   1295 
   1296   /* This function is called to modify program headers just before
   1297      they are written.  */
   1298   bool (*elf_backend_modify_headers)
   1299     (bfd *, struct bfd_link_info *);
   1300 
   1301   /* This function is called to see if the PHDR header should be
   1302      checked for validity.  */
   1303   bool (*elf_backend_allow_non_load_phdr)
   1304     (bfd *,  const Elf_Internal_Phdr *, unsigned);
   1305 
   1306   /* This function is called before section garbage collection to
   1307      mark entry symbol sections.  */
   1308   void (*gc_keep)
   1309     (struct bfd_link_info *);
   1310 
   1311   /* This function is called during section garbage collection to
   1312      mark sections that define global symbols.  */
   1313   bool (*gc_mark_dynamic_ref)
   1314     (struct elf_link_hash_entry *, void *);
   1315 
   1316   /* This function is called during section gc to discover the section a
   1317      particular relocation refers to.  */
   1318   elf_gc_mark_hook_fn gc_mark_hook;
   1319 
   1320   /* This function, if defined, is called after the first gc marking pass
   1321      to allow the backend to mark additional sections.  */
   1322   bool (*gc_mark_extra_sections)
   1323     (struct bfd_link_info *, elf_gc_mark_hook_fn);
   1324 
   1325   /* This function is called to initialise ELF file header info.
   1326      Customised versions can modify things like the OS and ABI version.  */
   1327   bool (*elf_backend_init_file_header)
   1328     (bfd *, struct bfd_link_info *);
   1329 
   1330   /* This function, if defined, prints a symbol to file and returns the
   1331      name of the symbol to be printed.  It should return NULL to fall
   1332      back to default symbol printing.  */
   1333   const char *(*elf_backend_print_symbol_all)
   1334     (bfd *, void *, asymbol *);
   1335 
   1336   /* This function, if defined, is called after all local symbols and
   1337      global symbols converted to locals are emitted into the symtab
   1338      section.  It allows the backend to emit special local symbols
   1339      not handled in the hash table.  */
   1340   bool (*elf_backend_output_arch_local_syms)
   1341     (bfd *, struct bfd_link_info *, void *,
   1342      int (*) (void *, const char *, Elf_Internal_Sym *, asection *,
   1343 	      struct elf_link_hash_entry *));
   1344 
   1345   /* This function, if defined, is called after all symbols are emitted
   1346      into the symtab section.  It allows the backend to emit special
   1347      global symbols not handled in the hash table.  */
   1348   bool (*elf_backend_output_arch_syms)
   1349     (bfd *, struct bfd_link_info *, void *,
   1350      int (*) (void *, const char *, Elf_Internal_Sym *, asection *,
   1351 	      struct elf_link_hash_entry *));
   1352 
   1353   /* Filter what symbols of the output file to include in the import
   1354      library if one is created.  */
   1355   unsigned int (*elf_backend_filter_implib_symbols)
   1356     (bfd *, struct bfd_link_info *, asymbol **, long);
   1357 
   1358   /* Copy any information related to dynamic linking from a pre-existing
   1359      symbol to a newly created symbol.  Also called to copy flags and
   1360      other back-end info to a weakdef, in which case the symbol is not
   1361      newly created and plt/got refcounts and dynamic indices should not
   1362      be copied.  */
   1363   void (*elf_backend_copy_indirect_symbol)
   1364     (struct bfd_link_info *, struct elf_link_hash_entry *,
   1365      struct elf_link_hash_entry *);
   1366 
   1367   /* Modify any information related to dynamic linking such that the
   1368      symbol is not exported.  */
   1369   void (*elf_backend_hide_symbol)
   1370     (struct bfd_link_info *, struct elf_link_hash_entry *, bool);
   1371 
   1372   /* A function to do additional symbol fixup, called by
   1373      _bfd_elf_fix_symbol_flags.  */
   1374   bool (*elf_backend_fixup_symbol)
   1375     (struct bfd_link_info *, struct elf_link_hash_entry *);
   1376 
   1377   /* Merge the backend specific symbol attribute.  */
   1378   void (*elf_backend_merge_symbol_attribute)
   1379     (struct elf_link_hash_entry *, unsigned int, bool, bool);
   1380 
   1381   /* This function, if defined, will return a string containing the
   1382      name of a target-specific dynamic tag.  */
   1383   char *(*elf_backend_get_target_dtag)
   1384     (bfd_vma);
   1385 
   1386   /* Decide whether an undefined symbol is special and can be ignored.
   1387      This is the case for OPTIONAL symbols on IRIX.  */
   1388   bool (*elf_backend_ignore_undef_symbol)
   1389     (struct elf_link_hash_entry *);
   1390 
   1391   /* Emit relocations.  Overrides default routine for emitting relocs,
   1392      except during a relocatable link, or if all relocs are being emitted.  */
   1393   bool (*elf_backend_emit_relocs)
   1394     (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
   1395      struct elf_link_hash_entry **);
   1396 
   1397   /* Update relocations.  It is allowed to change the number and the order.
   1398      In such a case hashes should be invalidated.  */
   1399   void (*elf_backend_update_relocs)
   1400     (asection *, struct bfd_elf_section_reloc_data *);
   1401 
   1402   /* Count relocations.  Not called for relocatable links
   1403      or if all relocs are being preserved in the output.  */
   1404   unsigned int (*elf_backend_count_relocs)
   1405     (struct bfd_link_info *, asection *);
   1406 
   1407   /* Count additionals relocations.  Called for relocatable links if
   1408      additional relocations needs to be created.  */
   1409   unsigned int (*elf_backend_count_additional_relocs)
   1410     (asection *);
   1411 
   1412   /* Say whether to sort relocs output by ld -r and ld --emit-relocs,
   1413      by r_offset.  If NULL, default to true.  */
   1414   bool (*sort_relocs_p)
   1415     (asection *);
   1416 
   1417   /* This function, if defined, is called when an NT_PRSTATUS note is found
   1418      in a core file.  */
   1419   bool (*elf_backend_grok_prstatus)
   1420     (bfd *, Elf_Internal_Note *);
   1421 
   1422   /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
   1423      note is found in a core file.  */
   1424   bool (*elf_backend_grok_psinfo)
   1425     (bfd *, Elf_Internal_Note *);
   1426 
   1427   /* This function, if defined, is called when a "FreeBSD" NT_PRSTATUS
   1428      note is found in a core file.  */
   1429   bool (*elf_backend_grok_freebsd_prstatus)
   1430     (bfd *, Elf_Internal_Note *);
   1431 
   1432   /* This function, if defined, is called to write a note to a corefile.  */
   1433   char *(*elf_backend_write_core_note)
   1434     (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
   1435 
   1436   /* This function, if defined, is called to convert target-specific
   1437      section flag names into hex values.  */
   1438   flagword (*elf_backend_lookup_section_flags_hook)
   1439     (char *);
   1440 
   1441   /* This function returns class of a reloc type.  */
   1442   enum elf_reloc_type_class (*elf_backend_reloc_type_class)
   1443   (const struct bfd_link_info *, const asection *, const Elf_Internal_Rela *);
   1444 
   1445   /* This function, if defined, removes information about discarded functions
   1446      from other sections which mention them.  */
   1447   bool (*elf_backend_discard_info)
   1448     (bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
   1449 
   1450   /* This function, if defined, signals that the function above has removed
   1451      the discarded relocations for this section.  */
   1452   bool (*elf_backend_ignore_discarded_relocs)
   1453     (asection *);
   1454 
   1455   /* What to do when ld finds relocations against symbols defined in
   1456      discarded sections.  */
   1457   unsigned int (*action_discarded)
   1458     (asection *);
   1459 
   1460   /* This function returns the width of FDE pointers in bytes, or 0 if
   1461      that can't be determined for some reason.  The default definition
   1462      goes by the bfd's EI_CLASS.  */
   1463   unsigned int (*elf_backend_eh_frame_address_size)
   1464     (bfd *, const asection *);
   1465 
   1466   /* These functions tell elf-eh-frame whether to attempt to turn
   1467      absolute or lsda encodings into pc-relative ones.  The default
   1468      definition enables these transformations.  */
   1469   bool (*elf_backend_can_make_relative_eh_frame)
   1470      (bfd *, struct bfd_link_info *, asection *);
   1471   bool (*elf_backend_can_make_lsda_relative_eh_frame)
   1472      (bfd *, struct bfd_link_info *, asection *);
   1473 
   1474   /* Tell linker to support multiple eh_frame sections.  */
   1475   bool elf_backend_can_make_multiple_eh_frame;
   1476 
   1477   /* This function returns an encoding after computing the encoded
   1478      value (and storing it in ENCODED) for the given OFFSET into OSEC,
   1479      to be stored in at LOC_OFFSET into the LOC_SEC input section.
   1480      The default definition chooses a 32-bit PC-relative encoding.  */
   1481   bfd_byte (*elf_backend_encode_eh_address)
   1482      (bfd *abfd, struct bfd_link_info *info,
   1483       asection *osec, bfd_vma offset,
   1484       asection *loc_sec, bfd_vma loc_offset,
   1485       bfd_vma *encoded);
   1486 
   1487   /* This function, if defined, may write out the given section.
   1488      Returns TRUE if it did so and FALSE if the caller should.  */
   1489   bool (*elf_backend_write_section)
   1490     (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
   1491 
   1492   /* This function, if defined, returns TRUE if it is section symbols
   1493      only that are considered local for the purpose of partitioning the
   1494      symbol table into local and global symbols.  This should be NULL
   1495      for most targets, in which case the correct thing will be done.
   1496      MIPS ELF, at least on the Irix 5, has special requirements.  */
   1497   bool (*elf_backend_elfsym_local_is_section)
   1498     (bfd *);
   1499 
   1500   /* The level of IRIX compatibility we're striving for.
   1501      MIPS ELF specific function.  */
   1502   irix_compat_t (*elf_backend_mips_irix_compat)
   1503     (bfd *);
   1504 
   1505   reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
   1506     (bfd *, unsigned int, bool);
   1507 
   1508   /* The swapping table to use when dealing with ECOFF information.
   1509      Used for the MIPS ELF .mdebug section.  */
   1510   const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
   1511 
   1512   /* This function implements `bfd_elf_bfd_from_remote_memory';
   1513      see elf.c, elfcode.h.  */
   1514   bfd *(*elf_backend_bfd_from_remote_memory)
   1515     (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
   1516      int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
   1517 				bfd_size_type len));
   1518 
   1519   bool (*elf_backend_core_find_build_id) (bfd *, bfd_vma);
   1520 
   1521   /* This function is used by `_bfd_elf_get_synthetic_symtab';
   1522      see elf.c.  */
   1523   bfd_vma (*plt_sym_val) (bfd_vma, const asection *, const arelent *);
   1524 
   1525   /* Is symbol defined in common section?  */
   1526   bool (*common_definition) (Elf_Internal_Sym *);
   1527 
   1528   /* Return a common section index for section.  */
   1529   unsigned int (*common_section_index) (asection *);
   1530 
   1531   /* Return a common section for section.  */
   1532   asection *(*common_section) (asection *);
   1533 
   1534   /* Return TRUE if we can merge 2 definitions.  */
   1535   bool (*merge_symbol) (struct elf_link_hash_entry *,
   1536 			       const Elf_Internal_Sym *, asection **,
   1537 			       bool, bool,
   1538 			       bfd *, const asection *);
   1539 
   1540   /* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
   1541   bool (*elf_hash_symbol) (struct elf_link_hash_entry *);
   1542 
   1543   /* If non-NULL, called to register the location of XLAT_LOC within
   1544      .MIPS.xhash at which real final dynindx for H will be written.
   1545      If XLAT_LOC is zero, the symbol is not included in
   1546      .MIPS.xhash and no dynindx will be written.  */
   1547   void (*record_xhash_symbol)
   1548     (struct elf_link_hash_entry *h, bfd_vma xlat_loc);
   1549 
   1550   /* Return TRUE if type is a function symbol type.  */
   1551   bool (*is_function_type) (unsigned int type);
   1552 
   1553   /* If the ELF symbol SYM might be a function in SEC, return the
   1554      function size and set *CODE_OFF to the function's entry point,
   1555      otherwise return zero.  */
   1556   bfd_size_type (*maybe_function_sym) (const asymbol *sym, asection *sec,
   1557 				       bfd_vma *code_off);
   1558 
   1559   /* Given NAME, the name of a relocation section stripped of its
   1560      .rel/.rela prefix, return the section in ABFD to which the
   1561      relocations apply.  */
   1562   asection *(*get_reloc_section) (bfd *abfd, const char *name);
   1563 
   1564   /* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
   1565      has a type >= SHT_LOOS.  Returns TRUE if the fields were initialised,
   1566      FALSE otherwise.  Can be called multiple times for a given section,
   1567      until it returns TRUE.  Most of the times it is called ISECTION will be
   1568      set to an input section that might be associated with the output section.
   1569      The last time that it is called, ISECTION will be set to NULL.  */
   1570   bool (*elf_backend_copy_special_section_fields)
   1571     (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *isection,
   1572      Elf_Internal_Shdr *osection);
   1573 
   1574   /* Used to handle bad SHF_LINK_ORDER input.  */
   1575   void (*link_order_error_handler) (const char *, ...);
   1576 
   1577   /* Name of the PLT relocation section.  */
   1578   const char *relplt_name;
   1579 
   1580   /* Alternate EM_xxxx machine codes for this backend.  */
   1581   int elf_machine_alt1;
   1582   int elf_machine_alt2;
   1583 
   1584   const struct elf_size_info *s;
   1585 
   1586   /* An array of target specific special sections.  */
   1587   const struct bfd_elf_special_section *special_sections;
   1588 
   1589   /* The size in bytes of the header for the GOT.  This includes the
   1590      so-called reserved entries on some systems.  */
   1591   bfd_vma got_header_size;
   1592 
   1593   /* The size of the GOT entry for the symbol pointed to by H if non-NULL,
   1594      otherwise by the local symbol with index SYMNDX in IBFD.  */
   1595   bfd_vma (*got_elt_size) (bfd *, struct bfd_link_info *,
   1596 			   struct elf_link_hash_entry *h,
   1597 			   bfd *ibfd, unsigned long symndx);
   1598 
   1599   /* The vendor name to use for a processor-standard attributes section.  */
   1600   const char *obj_attrs_vendor;
   1601 
   1602   /* The section name to use for a processor-standard attributes section.  */
   1603   const char *obj_attrs_section;
   1604 
   1605   /* Return 1, 2 or 3 to indicate what type of arguments a
   1606      processor-specific tag takes.  */
   1607   int (*obj_attrs_arg_type) (int);
   1608 
   1609   /* The section type to use for an attributes section.  */
   1610   unsigned int obj_attrs_section_type;
   1611 
   1612   /* This function determines the order in which any attributes are
   1613      written.  It must be defined for input in the range
   1614      LEAST_KNOWN_OBJ_ATTRIBUTE..NUM_KNOWN_OBJ_ATTRIBUTES-1 (this range
   1615      is used in order to make unity easy).  The returned value is the
   1616      actual tag number to place in the input position.  */
   1617   int (*obj_attrs_order) (int);
   1618 
   1619   /* Handle merging unknown attributes; either warn and return TRUE,
   1620      or give an error and return FALSE.  */
   1621   bool (*obj_attrs_handle_unknown) (bfd *, int);
   1622 
   1623   /* Parse GNU properties.  Return the property kind.  If the property
   1624      is corrupt, issue an error message and return property_corrupt.  */
   1625   enum elf_property_kind (*parse_gnu_properties) (bfd *, unsigned int,
   1626 						  bfd_byte *,
   1627 						  unsigned int);
   1628 
   1629   /* Merge GNU properties.  Return TRUE if property is updated.  */
   1630   bool (*merge_gnu_properties) (struct bfd_link_info *, bfd *, bfd *,
   1631 				       elf_property *, elf_property *);
   1632 
   1633   /* Set up GNU properties.  */
   1634   bfd *(*setup_gnu_properties) (struct bfd_link_info *);
   1635 
   1636   /* Fix up GNU properties.  */
   1637   void (*fixup_gnu_properties) (struct bfd_link_info *,
   1638 				elf_property_list **);
   1639 
   1640   /* Encoding used for compact EH tables.  */
   1641   int (*compact_eh_encoding) (struct bfd_link_info *);
   1642 
   1643   /* Opcode representing no unwind.  */
   1644   int (*cant_unwind_opcode) (struct bfd_link_info *);
   1645 
   1646   /* Called when emitting an ELF symbol whoes input version had an
   1647      ST_SHNDX field set to a value in the range SHN_LOPROC..SHN_HIOS.
   1648      Returns the value to be installed in the ST_SHNDX field of the
   1649      emitted symbol.  If not defined, the value is left unchanged.  */
   1650   unsigned int (*symbol_section_index) (bfd *, elf_symbol_type *);
   1651 
   1652   /* Called when a section has extra reloc sections.  */
   1653   bool (*init_secondary_reloc_section) (bfd *, Elf_Internal_Shdr *,
   1654 					const char *, unsigned int);
   1655 
   1656   /* Called when after loading the normal relocs for a section.  */
   1657   bool (*slurp_secondary_relocs) (bfd *, asection *, asymbol **, bool);
   1658 
   1659   /* Called after writing the normal relocs for a section.  */
   1660   bool (*write_secondary_relocs) (bfd *, asection *);
   1661 
   1662   /* This is non-zero if static TLS segments require a special alignment.  */
   1663   unsigned static_tls_alignment;
   1664 
   1665   /* Alignment for the PT_GNU_STACK segment.  */
   1666   unsigned stack_align;
   1667 
   1668   /* Flag bits to assign to a section of type SHT_STRTAB.  */
   1669   unsigned long elf_strtab_flags;
   1670 
   1671   /* This is TRUE if the linker should act like collect and gather
   1672      global constructors and destructors by name.  This is TRUE for
   1673      MIPS ELF because the Irix 5 tools can not handle the .init
   1674      section.  */
   1675   unsigned collect : 1;
   1676 
   1677   /* This is TRUE if the linker should ignore changes to the type of a
   1678      symbol.  This is TRUE for MIPS ELF because some Irix 5 objects
   1679      record undefined functions as STT_OBJECT although the definitions
   1680      are STT_FUNC.  */
   1681   unsigned type_change_ok : 1;
   1682 
   1683   /* Whether the backend may use REL relocations.  (Some backends use
   1684      both REL and RELA relocations, and this flag is set for those
   1685      backends.)  */
   1686   unsigned may_use_rel_p : 1;
   1687 
   1688   /* Whether the backend may use RELA relocations.  (Some backends use
   1689      both REL and RELA relocations, and this flag is set for those
   1690      backends.)  */
   1691   unsigned may_use_rela_p : 1;
   1692 
   1693   /* Whether the default relocation type is RELA.  If a backend with
   1694      this flag set wants REL relocations for a particular section,
   1695      it must note that explicitly.  Similarly, if this flag is clear,
   1696      and the backend wants RELA relocations for a particular
   1697      section.  */
   1698   unsigned default_use_rela_p : 1;
   1699 
   1700   /* True if PLT and copy relocations should be RELA by default.  */
   1701   unsigned rela_plts_and_copies_p : 1;
   1702 
   1703   /* Set if RELA relocations for a relocatable link can be handled by
   1704      generic code.  Backends that set this flag need do nothing in the
   1705      backend relocate_section routine for relocatable linking.  */
   1706   unsigned rela_normal : 1;
   1707 
   1708   /* Set if DT_REL/DT_RELA/DT_RELSZ/DT_RELASZ should not include PLT
   1709      relocations.  */
   1710   unsigned dtrel_excludes_plt : 1;
   1711 
   1712   /* TRUE if addresses "naturally" sign extend.  This is used when
   1713      swapping in from Elf32 when BFD64.  */
   1714   unsigned sign_extend_vma : 1;
   1715 
   1716   unsigned want_got_plt : 1;
   1717   unsigned plt_readonly : 1;
   1718   unsigned want_plt_sym : 1;
   1719   unsigned plt_not_loaded : 1;
   1720   unsigned plt_alignment : 4;
   1721   unsigned can_gc_sections : 1;
   1722   unsigned can_refcount : 1;
   1723   unsigned want_got_sym : 1;
   1724   unsigned want_dynbss : 1;
   1725   unsigned want_dynrelro : 1;
   1726 
   1727   /* Targets which do not support physical addressing often require
   1728      that the p_paddr field in the section header to be set to zero.
   1729      This field indicates whether this behavior is required.  */
   1730   unsigned want_p_paddr_set_to_zero : 1;
   1731 
   1732   /* Target has broken hardware and/or kernel that requires pages not
   1733      to be mapped twice with different permissions.  */
   1734   unsigned no_page_alias : 1;
   1735 
   1736   /* True if an object file lacking a .note.GNU-stack section
   1737      should be assumed to be requesting exec stack.  At least one
   1738      other file in the link needs to have a .note.GNU-stack section
   1739      for a PT_GNU_STACK segment to be created.  */
   1740   unsigned default_execstack : 1;
   1741 
   1742   /* True if elf_section_data(sec)->this_hdr.contents is sec->rawsize
   1743      in length rather than sec->size in length, if sec->rawsize is
   1744      non-zero and smaller than sec->size.  */
   1745   unsigned caches_rawsize : 1;
   1746 
   1747   /* Address of protected data defined in the shared library may be
   1748      external, i.e., due to copy relocation.   */
   1749   unsigned extern_protected_data : 1;
   1750 
   1751   /* True if `_bfd_elf_link_renumber_dynsyms' must be called even for
   1752      static binaries.  */
   1753   unsigned always_renumber_dynsyms : 1;
   1754 
   1755   /* True if the 32-bit Linux PRPSINFO structure's `pr_uid' and `pr_gid'
   1756      members use a 16-bit data type.  */
   1757   unsigned linux_prpsinfo32_ugid16 : 1;
   1758 
   1759   /* True if the 64-bit Linux PRPSINFO structure's `pr_uid' and `pr_gid'
   1760      members use a 16-bit data type.  */
   1761   unsigned linux_prpsinfo64_ugid16 : 1;
   1762 };
   1763 
   1764 /* Information about reloc sections associated with a bfd_elf_section_data
   1765    structure.  */
   1766 struct bfd_elf_section_reloc_data
   1767 {
   1768   /* The ELF header for the reloc section associated with this
   1769      section, if any.  */
   1770   Elf_Internal_Shdr *hdr;
   1771   /* The number of relocations currently assigned to HDR.  */
   1772   unsigned int count;
   1773   /* The ELF section number of the reloc section.  Only used for an
   1774      output file.  */
   1775   int idx;
   1776   /* Used by the backend linker to store the symbol hash table entries
   1777      associated with relocs against global symbols.  */
   1778   struct elf_link_hash_entry **hashes;
   1779 };
   1780 
   1781 /* Information stored for each BFD section in an ELF file.  This
   1782    structure is allocated by elf_new_section_hook.  */
   1783 
   1784 struct bfd_elf_section_data
   1785 {
   1786   /* The ELF header for this section.  */
   1787   Elf_Internal_Shdr this_hdr;
   1788 
   1789   /* INPUT_SECTION_FLAGS if specified in the linker script.  */
   1790   struct flag_info *section_flag_info;
   1791 
   1792   /* Information about the REL and RELA reloc sections associated
   1793      with this section, if any.  */
   1794   struct bfd_elf_section_reloc_data rel, rela;
   1795 
   1796   /* The ELF section number of this section.  */
   1797   int this_idx;
   1798 
   1799   /* Used by the backend linker when generating a shared library to
   1800      record the dynamic symbol index for a section symbol
   1801      corresponding to this section.  A value of 0 means that there is
   1802      no dynamic symbol for this section.  */
   1803   int dynindx;
   1804 
   1805   /* A pointer to the linked-to section for SHF_LINK_ORDER.  */
   1806   asection *linked_to;
   1807 
   1808   /* A pointer to the swapped relocs.  If the section uses REL relocs,
   1809      rather than RELA, all the r_addend fields will be zero.  This
   1810      pointer may be NULL.  It is used by the backend linker.  */
   1811   Elf_Internal_Rela *relocs;
   1812 
   1813   /* A pointer to a linked list tracking dynamic relocs copied for
   1814      local symbols.  */
   1815   void *local_dynrel;
   1816 
   1817   /* A pointer to the bfd section used for dynamic relocs.  */
   1818   asection *sreloc;
   1819 
   1820   union {
   1821     /* Group name, if this section is a member of a group.  */
   1822     const char *name;
   1823 
   1824     /* Group signature sym, if this is the SHT_GROUP section.  */
   1825     struct bfd_symbol *id;
   1826   } group;
   1827 
   1828   /* For a member of a group, points to the SHT_GROUP section.
   1829      NULL for the SHT_GROUP section itself and non-group sections.  */
   1830   asection *sec_group;
   1831 
   1832   /* A linked list of member sections in the group.  Circular when used by
   1833      the linker.  For the SHT_GROUP section, points at first member.  */
   1834   asection *next_in_group;
   1835 
   1836   /* The FDEs associated with this section.  The u.fde.next_in_section
   1837      field acts as a chain pointer.  */
   1838   struct eh_cie_fde *fde_list;
   1839 
   1840   /* Link from a text section to its .eh_frame_entry section.  */
   1841   asection *eh_frame_entry;
   1842 
   1843   /* TRUE if the section has secondary reloc sections associated with it.
   1844      FIXME: In the future it might be better to change this into a list
   1845      of secondary reloc sections, making lookup easier and faster.  */
   1846   bool has_secondary_relocs;
   1847 
   1848   /* A pointer used for various section optimizations.  */
   1849   void *sec_info;
   1850 };
   1851 
   1852 #define elf_section_data(sec) ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
   1853 #define elf_linked_to_section(sec) (elf_section_data(sec)->linked_to)
   1854 #define elf_section_type(sec)	(elf_section_data(sec)->this_hdr.sh_type)
   1855 #define elf_section_flags(sec)	(elf_section_data(sec)->this_hdr.sh_flags)
   1856 #define elf_section_info(sec)	(elf_section_data(sec)->this_hdr.sh_info)
   1857 #define elf_group_name(sec)	(elf_section_data(sec)->group.name)
   1858 #define elf_group_id(sec)	(elf_section_data(sec)->group.id)
   1859 #define elf_next_in_group(sec)	(elf_section_data(sec)->next_in_group)
   1860 #define elf_fde_list(sec)	(elf_section_data(sec)->fde_list)
   1861 #define elf_sec_group(sec)	(elf_section_data(sec)->sec_group)
   1862 #define elf_section_eh_frame_entry(sec)	(elf_section_data(sec)->eh_frame_entry)
   1863 
   1864 #define xvec_get_elf_backend_data(xvec) \
   1865   ((const struct elf_backend_data *) (xvec)->backend_data)
   1866 
   1867 #define get_elf_backend_data(abfd) \
   1868    xvec_get_elf_backend_data ((abfd)->xvec)
   1869 
   1870 /* The least object attributes (within an attributes subsection) known
   1871    for any target.  Some code assumes that the value 0 is not used and
   1872    the field for that attribute can instead be used as a marker to
   1873    indicate that attributes have been initialized.  */
   1874 #define LEAST_KNOWN_OBJ_ATTRIBUTE 2
   1875 
   1876 /* The maximum number of known object attributes for any target.  */
   1877 #define NUM_KNOWN_OBJ_ATTRIBUTES 77
   1878 
   1879 /* The value of an object attribute.  The type indicates whether the attribute
   1880    holds and integer, a string, or both.  It can also indicate that there can
   1881    be no default (i.e. all values must be written to file, even zero), or
   1882    that the value is in error and should not be written to file.  */
   1883 
   1884 typedef struct obj_attribute
   1885 {
   1886 #define ATTR_TYPE_FLAG_INT_VAL    (1 << 0)
   1887 #define ATTR_TYPE_FLAG_STR_VAL    (1 << 1)
   1888 #define ATTR_TYPE_FLAG_NO_DEFAULT (1 << 2)
   1889 #define ATTR_TYPE_FLAG_ERROR	  (1 << 3)
   1890 
   1891 #define ATTR_TYPE_HAS_INT_VAL(TYPE)	((TYPE) & ATTR_TYPE_FLAG_INT_VAL)
   1892 #define ATTR_TYPE_HAS_STR_VAL(TYPE)	((TYPE) & ATTR_TYPE_FLAG_STR_VAL)
   1893 #define ATTR_TYPE_HAS_NO_DEFAULT(TYPE)	((TYPE) & ATTR_TYPE_FLAG_NO_DEFAULT)
   1894 #define ATTR_TYPE_HAS_ERROR(TYPE)	((TYPE) & ATTR_TYPE_FLAG_ERROR)
   1895 
   1896   int type;
   1897   unsigned int i;
   1898   char *s;
   1899 } obj_attribute;
   1900 
   1901 typedef struct obj_attribute_list
   1902 {
   1903   struct obj_attribute_list *next;
   1904   unsigned int tag;
   1905   obj_attribute attr;
   1906 } obj_attribute_list;
   1907 
   1908 /* Object attributes may either be defined by the processor ABI, index
   1909    OBJ_ATTR_PROC in the *_obj_attributes arrays, or be GNU-specific
   1910    (and possibly also processor-specific), index OBJ_ATTR_GNU.  */
   1911 #define OBJ_ATTR_PROC 0
   1912 #define OBJ_ATTR_GNU 1
   1913 #define OBJ_ATTR_FIRST OBJ_ATTR_PROC
   1914 #define OBJ_ATTR_LAST OBJ_ATTR_GNU
   1915 
   1916 /* The following object attribute tags are taken as generic, for all
   1917    targets and for "gnu" where there is no target standard.  */
   1918 enum
   1919 {
   1920   Tag_NULL = 0,
   1921   Tag_File = 1,
   1922   Tag_Section = 2,
   1923   Tag_Symbol = 3,
   1924   Tag_compatibility = 32
   1925 };
   1926 
   1927 /* The following struct stores information about every SystemTap section
   1928    found in the object file.  */
   1929 struct sdt_note
   1930 {
   1931   struct sdt_note *next;
   1932   bfd_size_type size;
   1933   bfd_byte data[1];
   1934 };
   1935 
   1936 /* tdata information grabbed from an elf core file.  */
   1937 struct core_elf_obj_tdata
   1938 {
   1939   int signal;
   1940   int pid;
   1941   int lwpid;
   1942   char* program;
   1943   char* command;
   1944 };
   1945 
   1946 /* Extra tdata information held for output ELF BFDs.  */
   1947 struct output_elf_obj_tdata
   1948 {
   1949   struct elf_segment_map *seg_map;
   1950   struct elf_strtab_hash *strtab_ptr;
   1951 
   1952   /* STT_SECTION symbols for each section */
   1953   asymbol **section_syms;
   1954 
   1955   /* NT_GNU_BUILD_ID note type info.  */
   1956   struct
   1957   {
   1958     bool (*after_write_object_contents) (bfd *);
   1959     const char *style;
   1960     asection *sec;
   1961   } build_id;
   1962 
   1963   /* FDO_PACKAGING_METADATA note type info.  */
   1964   struct
   1965   {
   1966     bool (*after_write_object_contents) (bfd *);
   1967     const char *json;
   1968     asection *sec;
   1969   } package_metadata;
   1970 
   1971   /* Records the result of `get_program_header_size'.  */
   1972   bfd_size_type program_header_size;
   1973 
   1974   /* Used when laying out sections.  */
   1975   file_ptr next_file_pos;
   1976 
   1977   /* Linker information.  */
   1978   struct bfd_link_info *link_info;
   1979 
   1980   unsigned int num_section_syms;
   1981   unsigned int shstrtab_section, strtab_section;
   1982 
   1983   /* Segment flags for the PT_GNU_STACK segment.  */
   1984   unsigned int stack_flags;
   1985 
   1986   /* Used to determine if PT_GNU_SFRAME segment header should be
   1987      created.  */
   1988   asection *sframe;
   1989 
   1990   /* Used to determine if the e_flags field has been initialized */
   1991   bool flags_init;
   1992 };
   1993 
   1994 /* Indicate if the bfd contains SHF_GNU_MBIND/SHF_GNU_RETAIN sections or
   1995    symbols that have the STT_GNU_IFUNC symbol type or STB_GNU_UNIQUE
   1996    binding.  Used to set the osabi field in the ELF header structure.  */
   1997 enum elf_gnu_osabi
   1998 {
   1999   elf_gnu_osabi_mbind = 1 << 0,
   2000   elf_gnu_osabi_ifunc = 1 << 1,
   2001   elf_gnu_osabi_unique = 1 << 2,
   2002   elf_gnu_osabi_retain = 1 << 3,
   2003 };
   2004 
   2005 typedef struct elf_section_list
   2006 {
   2007   Elf_Internal_Shdr	     hdr;
   2008   unsigned int		     ndx;
   2009   struct elf_section_list *  next;
   2010 } elf_section_list;
   2011 
   2012 enum dynamic_lib_link_class {
   2013   DYN_NORMAL = 0,
   2014   DYN_AS_NEEDED = 1,
   2015   DYN_DT_NEEDED = 2,
   2016   DYN_NO_ADD_NEEDED = 4,
   2017   DYN_NO_NEEDED = 8
   2018 };
   2019 
   2020 /* Some private data is stashed away for future use using the tdata pointer
   2021    in the bfd structure.  */
   2022 
   2023 struct elf_obj_tdata
   2024 {
   2025   Elf_Internal_Ehdr elf_header[1];	/* Actual data, but ref like ptr */
   2026   Elf_Internal_Shdr **elf_sect_ptr;
   2027   Elf_Internal_Phdr *phdr;
   2028   Elf_Internal_Shdr symtab_hdr;
   2029   Elf_Internal_Shdr shstrtab_hdr;
   2030   Elf_Internal_Shdr strtab_hdr;
   2031   Elf_Internal_Shdr dynsymtab_hdr;
   2032   Elf_Internal_Shdr dynstrtab_hdr;
   2033   Elf_Internal_Shdr dynversym_hdr;
   2034   Elf_Internal_Shdr dynverref_hdr;
   2035   Elf_Internal_Shdr dynverdef_hdr;
   2036   elf_section_list * symtab_shndx_list;
   2037   bfd_vma gp;				/* The gp value */
   2038   unsigned int gp_size;			/* The gp size */
   2039   unsigned int num_elf_sections;	/* elf_sect_ptr size */
   2040   unsigned char *being_created;
   2041 
   2042   /* A mapping from external symbols to entries in the linker hash
   2043      table, used when linking.  This is indexed by the symbol index
   2044      minus the sh_info field of the symbol table header.  */
   2045   struct elf_link_hash_entry **sym_hashes;
   2046 
   2047   /* Track usage and final offsets of GOT entries for local symbols.
   2048      This array is indexed by symbol index.  Elements are used
   2049      identically to "got" in struct elf_link_hash_entry.  */
   2050   union
   2051     {
   2052       bfd_signed_vma *refcounts;
   2053       bfd_vma *offsets;
   2054       struct got_entry **ents;
   2055     } local_got;
   2056 
   2057   /* The linker ELF emulation code needs to let the backend ELF linker
   2058      know what filename should be used for a dynamic object if the
   2059      dynamic object is found using a search.  The emulation code then
   2060      sometimes needs to know what name was actually used.  Until the
   2061      file has been added to the linker symbol table, this field holds
   2062      the name the linker wants.  After it has been added, it holds the
   2063      name actually used, which will be the DT_SONAME entry if there is
   2064      one.  */
   2065   const char *dt_name;
   2066 
   2067   /* The linker emulation needs to know what audit libs
   2068      are used by a dynamic object.  */
   2069   const char *dt_audit;
   2070 
   2071   /* Used by find_nearest_line entry point.  */
   2072   void *line_info;
   2073 
   2074   /* A place to stash dwarf1 info for this bfd.  */
   2075   struct dwarf1_debug *dwarf1_find_line_info;
   2076 
   2077   /* A place to stash dwarf2 info for this bfd.  */
   2078   void *dwarf2_find_line_info;
   2079 
   2080   /* Stash away info for yet another find line/function variant.  */
   2081   void *elf_find_function_cache;
   2082 
   2083   /* Number of symbol version definitions we are about to emit.  */
   2084   unsigned int cverdefs;
   2085 
   2086   /* Number of symbol version references we are about to emit.  */
   2087   unsigned int cverrefs;
   2088 
   2089   /* Symbol version definitions in external objects.  */
   2090   Elf_Internal_Verdef *verdef;
   2091 
   2092   /* Symbol version references to external objects.  */
   2093   Elf_Internal_Verneed *verref;
   2094 
   2095   /* A pointer to the .eh_frame section.  */
   2096   asection *eh_frame_section;
   2097 
   2098   /* Symbol buffer.  */
   2099   void *symbuf;
   2100 
   2101   /* List of GNU properties.  Will be updated by setup_gnu_properties
   2102      after all input GNU properties are merged for output.  */
   2103   elf_property_list *properties;
   2104 
   2105   obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
   2106   obj_attribute_list *other_obj_attributes[2];
   2107 
   2108   /* Linked-list containing information about every Systemtap section
   2109      found in the object file.  Each section corresponds to one entry
   2110      in the list.  */
   2111   struct sdt_note *sdt_note_head;
   2112 
   2113   Elf_Internal_Shdr **group_sect_ptr;
   2114   unsigned int num_group;
   2115 
   2116   /* Index into group_sect_ptr, updated by setup_group when finding a
   2117      section's group.  Used to optimize subsequent group searches.  */
   2118   unsigned int group_search_offset;
   2119 
   2120   unsigned int symtab_section, dynsymtab_section;
   2121   unsigned int dynversym_section, dynverdef_section, dynverref_section;
   2122 
   2123   /* An identifier used to distinguish different target
   2124      specific extensions to this structure.  */
   2125   ENUM_BITFIELD (elf_target_id) object_id : 6;
   2126 
   2127   /* Whether a dyanmic object was specified normally on the linker
   2128      command line, or was specified when --as-needed was in effect,
   2129      or was found via a DT_NEEDED entry.  */
   2130   ENUM_BITFIELD (dynamic_lib_link_class) dyn_lib_class : 4;
   2131 
   2132   /* Whether the bfd uses OS specific bits that require ELFOSABI_GNU.  */
   2133   ENUM_BITFIELD (elf_gnu_osabi) has_gnu_osabi : 4;
   2134 
   2135   /* Whether if the bfd contains the GNU_PROPERTY_NO_COPY_ON_PROTECTED
   2136      property.  */
   2137   unsigned int has_no_copy_on_protected : 1;
   2138 
   2139   /* Whether if the bfd contains the
   2140      GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS property.  */
   2141   unsigned int has_indirect_extern_access : 1;
   2142 
   2143   /* Irix 5 often screws up the symbol table, sorting local symbols
   2144      after global symbols.  This flag is set if the symbol table in
   2145      this BFD appears to be screwed up.  If it is, we ignore the
   2146      sh_info field in the symbol table header, and always read all the
   2147      symbols.  */
   2148   unsigned int bad_symtab : 1;
   2149 
   2150   /* Set if DT_FLAGS_1 has DF_1_PIE set.  */
   2151   unsigned int is_pie : 1;
   2152 
   2153   /* Information grabbed from an elf core file.  */
   2154   struct core_elf_obj_tdata *core;
   2155 
   2156   /* More information held for output ELF BFDs.  */
   2157   struct output_elf_obj_tdata *o;
   2158 };
   2159 
   2160 #define elf_tdata(bfd)		((bfd) -> tdata.elf_obj_data)
   2161 
   2162 #define elf_object_id(bfd)	(elf_tdata(bfd) -> object_id)
   2163 #define elf_program_header_size(bfd) (elf_tdata(bfd) -> o->program_header_size)
   2164 #define elf_elfheader(bfd)	(elf_tdata(bfd) -> elf_header)
   2165 #define elf_elfsections(bfd)	(elf_tdata(bfd) -> elf_sect_ptr)
   2166 #define elf_numsections(bfd)	(elf_tdata(bfd) -> num_elf_sections)
   2167 #define elf_seg_map(bfd)	(elf_tdata(bfd) -> o->seg_map)
   2168 #define elf_link_info(bfd)	(elf_tdata(bfd) -> o->link_info)
   2169 #define elf_next_file_pos(bfd)	(elf_tdata(bfd) -> o->next_file_pos)
   2170 #define elf_stack_flags(bfd)	(elf_tdata(bfd) -> o->stack_flags)
   2171 #define elf_sframe(bfd)		(elf_tdata(bfd) -> o->sframe)
   2172 #define elf_shstrtab(bfd)	(elf_tdata(bfd) -> o->strtab_ptr)
   2173 #define elf_onesymtab(bfd)	(elf_tdata(bfd) -> symtab_section)
   2174 #define elf_symtab_shndx_list(bfd)	(elf_tdata(bfd) -> symtab_shndx_list)
   2175 #define elf_strtab_sec(bfd)	(elf_tdata(bfd) -> o->strtab_section)
   2176 #define elf_shstrtab_sec(bfd)	(elf_tdata(bfd) -> o->shstrtab_section)
   2177 #define elf_symtab_hdr(bfd)	(elf_tdata(bfd) -> symtab_hdr)
   2178 #define elf_dynsymtab(bfd)	(elf_tdata(bfd) -> dynsymtab_section)
   2179 #define elf_dynversym(bfd)	(elf_tdata(bfd) -> dynversym_section)
   2180 #define elf_dynverdef(bfd)	(elf_tdata(bfd) -> dynverdef_section)
   2181 #define elf_dynverref(bfd)	(elf_tdata(bfd) -> dynverref_section)
   2182 #define elf_eh_frame_section(bfd) \
   2183 				(elf_tdata(bfd) -> eh_frame_section)
   2184 #define elf_section_syms(bfd)	(elf_tdata(bfd) -> o->section_syms)
   2185 #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> o->num_section_syms)
   2186 #define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
   2187 #define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
   2188 #define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
   2189 #define elf_gp_size(bfd)	(elf_tdata(bfd) -> gp_size)
   2190 #define elf_sym_hashes(bfd)	(elf_tdata(bfd) -> sym_hashes)
   2191 #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
   2192 #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
   2193 #define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
   2194 #define elf_dt_name(bfd)	(elf_tdata(bfd) -> dt_name)
   2195 #define elf_dt_audit(bfd)	(elf_tdata(bfd) -> dt_audit)
   2196 #define elf_dyn_lib_class(bfd)	(elf_tdata(bfd) -> dyn_lib_class)
   2197 #define elf_bad_symtab(bfd)	(elf_tdata(bfd) -> bad_symtab)
   2198 #define elf_flags_init(bfd)	(elf_tdata(bfd) -> o->flags_init)
   2199 #define elf_known_obj_attributes(bfd) (elf_tdata (bfd) -> known_obj_attributes)
   2200 #define elf_other_obj_attributes(bfd) (elf_tdata (bfd) -> other_obj_attributes)
   2201 #define elf_known_obj_attributes_proc(bfd) \
   2202   (elf_known_obj_attributes (bfd) [OBJ_ATTR_PROC])
   2203 #define elf_other_obj_attributes_proc(bfd) \
   2204   (elf_other_obj_attributes (bfd) [OBJ_ATTR_PROC])
   2205 #define elf_properties(bfd) (elf_tdata (bfd) -> properties)
   2206 #define elf_has_no_copy_on_protected(bfd) \
   2207   (elf_tdata(bfd) -> has_no_copy_on_protected)
   2208 #define elf_has_indirect_extern_access(bfd) \
   2209   (elf_tdata(bfd) -> has_indirect_extern_access)
   2210 
   2211 extern void _bfd_elf_swap_verdef_in
   2213   (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *);
   2214 extern void _bfd_elf_swap_verdef_out
   2215   (bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *);
   2216 extern void _bfd_elf_swap_verdaux_in
   2217   (bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *);
   2218 extern void _bfd_elf_swap_verdaux_out
   2219   (bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *);
   2220 extern void _bfd_elf_swap_verneed_in
   2221   (bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *);
   2222 extern void _bfd_elf_swap_verneed_out
   2223   (bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *);
   2224 extern void _bfd_elf_swap_vernaux_in
   2225   (bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *);
   2226 extern void _bfd_elf_swap_vernaux_out
   2227   (bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *);
   2228 extern void _bfd_elf_swap_versym_in
   2229   (bfd *, const Elf_External_Versym *, Elf_Internal_Versym *);
   2230 extern void _bfd_elf_swap_versym_out
   2231   (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *);
   2232 
   2233 extern unsigned int _bfd_elf_section_from_bfd_section
   2234   (bfd *, asection *);
   2235 extern char *bfd_elf_string_from_elf_section
   2236   (bfd *, unsigned, unsigned);
   2237 extern Elf_Internal_Sym *bfd_elf_get_elf_syms
   2238   (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
   2239    Elf_External_Sym_Shndx *);
   2240 extern char * bfd_elf_get_str_section (bfd *, unsigned int);
   2241 extern const char *bfd_elf_sym_name
   2242   (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *);
   2243 
   2244 extern bool _bfd_elf_copy_private_bfd_data
   2245   (bfd *, bfd *);
   2246 extern bool _bfd_elf_print_private_bfd_data
   2247   (bfd *, void *);
   2248 const char * _bfd_elf_get_symbol_version_string
   2249   (bfd *, asymbol *, bool, bool *);
   2250 extern void bfd_elf_print_symbol
   2251   (bfd *, void *, asymbol *, bfd_print_symbol_type);
   2252 
   2253 extern unsigned int _bfd_elf_eh_frame_address_size
   2254   (bfd *, const asection *);
   2255 extern bfd_byte _bfd_elf_encode_eh_address
   2256   (bfd *abfd, struct bfd_link_info *info, asection *osec, bfd_vma offset,
   2257    asection *loc_sec, bfd_vma loc_offset, bfd_vma *encoded);
   2258 extern bool _bfd_elf_can_make_relative
   2259   (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
   2260 
   2261 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
   2262   (const struct bfd_link_info *, const asection *,
   2263    const Elf_Internal_Rela *);
   2264 extern bfd_vma _bfd_elf_rela_local_sym
   2265   (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
   2266 extern bfd_vma _bfd_elf_rel_local_sym
   2267   (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
   2268 extern bfd_vma _bfd_elf_section_offset
   2269   (bfd *, struct bfd_link_info *, asection *, bfd_vma);
   2270 
   2271 extern unsigned long bfd_elf_hash
   2272   (const char *);
   2273 extern unsigned long bfd_elf_gnu_hash
   2274   (const char *);
   2275 
   2276 extern bfd_reloc_status_type bfd_elf_generic_reloc
   2277   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
   2278 extern bool bfd_elf_allocate_object
   2279   (bfd *, size_t, enum elf_target_id);
   2280 extern bool bfd_elf_make_object
   2281   (bfd *);
   2282 extern bool bfd_elf_mkcorefile
   2283   (bfd *);
   2284 extern bool _bfd_elf_make_section_from_shdr
   2285   (bfd *, Elf_Internal_Shdr *, const char *, int);
   2286 extern bool _bfd_elf_make_section_from_phdr
   2287   (bfd *, Elf_Internal_Phdr *, int, const char *);
   2288 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
   2289   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
   2290 extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
   2291   (bfd *);
   2292 extern void _bfd_elf_link_hash_table_free
   2293   (bfd *);
   2294 extern void _bfd_elf_link_hash_copy_indirect
   2295   (struct bfd_link_info *, struct elf_link_hash_entry *,
   2296    struct elf_link_hash_entry *);
   2297 extern void _bfd_elf_link_hash_hide_symbol
   2298   (struct bfd_link_info *, struct elf_link_hash_entry *, bool);
   2299 extern void _bfd_elf_link_hide_symbol
   2300   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
   2301 extern bool _bfd_elf_link_hash_fixup_symbol
   2302   (struct bfd_link_info *, struct elf_link_hash_entry *);
   2303 extern bool _bfd_elf_link_hash_table_init
   2304   (struct elf_link_hash_table *, bfd *,
   2305    struct bfd_hash_entry *(*)
   2306      (struct bfd_hash_entry *, struct bfd_hash_table *, const char *),
   2307    unsigned int, enum elf_target_id);
   2308 extern bool _bfd_elf_slurp_version_tables
   2309   (bfd *, bool);
   2310 extern bool _bfd_elf_merge_sections
   2311   (bfd *, struct bfd_link_info *);
   2312 extern bool _bfd_elf_match_sections_by_type
   2313   (bfd *, const asection *, bfd *, const asection *);
   2314 extern bool bfd_elf_is_group_section
   2315   (bfd *, const struct bfd_section *);
   2316 extern const char *bfd_elf_group_name
   2317   (bfd *, const struct bfd_section *);
   2318 extern bool _bfd_elf_section_already_linked
   2319   (bfd *, asection *, struct bfd_link_info *);
   2320 extern void bfd_elf_set_group_contents
   2321   (bfd *, asection *, void *);
   2322 extern unsigned int _bfd_elf_filter_global_symbols
   2323   (bfd *, struct bfd_link_info *, asymbol **, long);
   2324 extern asection *_bfd_elf_check_kept_section
   2325   (asection *, struct bfd_link_info *);
   2326 #define _bfd_elf_link_just_syms _bfd_generic_link_just_syms
   2327 extern void _bfd_elf_copy_link_hash_symbol_type
   2328   (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
   2329 extern bool _bfd_elf_size_group_sections
   2330   (struct bfd_link_info *);
   2331 extern bool _bfd_elf_fixup_group_sections
   2332 (bfd *, asection *);
   2333 extern bool _bfd_elf_copy_private_header_data
   2334   (bfd *, bfd *);
   2335 extern bool _bfd_elf_copy_private_symbol_data
   2336   (bfd *, asymbol *, bfd *, asymbol *);
   2337 #define _bfd_generic_init_private_section_data \
   2338   _bfd_elf_init_private_section_data
   2339 extern bool _bfd_elf_init_private_section_data
   2340   (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
   2341 extern bool _bfd_elf_copy_private_section_data
   2342   (bfd *, asection *, bfd *, asection *);
   2343 extern bool _bfd_elf_write_object_contents
   2344   (bfd *);
   2345 extern bool _bfd_elf_write_corefile_contents
   2346   (bfd *);
   2347 extern bool _bfd_elf_set_section_contents
   2348   (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
   2349 extern long _bfd_elf_get_symtab_upper_bound
   2350   (bfd *);
   2351 extern long _bfd_elf_canonicalize_symtab
   2352   (bfd *, asymbol **);
   2353 extern long _bfd_elf_get_dynamic_symtab_upper_bound
   2354   (bfd *);
   2355 extern long _bfd_elf_canonicalize_dynamic_symtab
   2356   (bfd *, asymbol **);
   2357 extern long _bfd_elf_get_synthetic_symtab
   2358   (bfd *, long, asymbol **, long, asymbol **, asymbol **);
   2359 extern long _bfd_elf_get_reloc_upper_bound
   2360   (bfd *, sec_ptr);
   2361 extern long _bfd_elf_canonicalize_reloc
   2362   (bfd *, sec_ptr, arelent **, asymbol **);
   2363 extern asection * _bfd_elf_get_dynamic_reloc_section
   2364   (bfd *, asection *, bool);
   2365 extern asection * _bfd_elf_make_dynamic_reloc_section
   2366   (asection *, bfd *, unsigned int, bfd *, bool);
   2367 extern long _bfd_elf_get_dynamic_reloc_upper_bound
   2368   (bfd *);
   2369 extern long _bfd_elf_canonicalize_dynamic_reloc
   2370   (bfd *, arelent **, asymbol **);
   2371 extern asymbol *_bfd_elf_make_empty_symbol
   2372   (bfd *);
   2373 extern void _bfd_elf_get_symbol_info
   2374   (bfd *, asymbol *, symbol_info *);
   2375 extern bool _bfd_elf_is_local_label_name
   2376   (bfd *, const char *);
   2377 extern alent *_bfd_elf_get_lineno
   2378   (bfd *, asymbol *);
   2379 extern bool _bfd_elf_set_arch_mach
   2380   (bfd *, enum bfd_architecture, unsigned long);
   2381 extern bool _bfd_elf_find_nearest_line
   2382   (bfd *, asymbol **, asection *, bfd_vma,
   2383    const char **, const char **, unsigned int *, unsigned int *);
   2384 extern bool _bfd_elf_find_nearest_line_with_alt
   2385   (bfd *, const char *, asymbol **, asection *, bfd_vma,
   2386    const char **, const char **, unsigned int *, unsigned int *);
   2387 extern bool _bfd_elf_find_line
   2388   (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
   2389 extern bool _bfd_elf_find_inliner_info
   2390   (bfd *, const char **, const char **, unsigned int *);
   2391 extern asymbol *_bfd_elf_find_function
   2392   (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **);
   2393 #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
   2394 #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
   2395 extern int _bfd_elf_sizeof_headers
   2396   (bfd *, struct bfd_link_info *);
   2397 extern bool _bfd_elf_new_section_hook
   2398   (bfd *, asection *);
   2399 extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
   2400   (const char *, const struct bfd_elf_special_section *, unsigned int);
   2401 extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
   2402   (bfd *, asection *);
   2403 
   2404 extern bool _bfd_elf_link_hide_sym_by_version
   2405   (struct bfd_link_info *, struct elf_link_hash_entry *);
   2406 
   2407 /* If the target doesn't have reloc handling written yet:  */
   2408 extern bool _bfd_elf_no_info_to_howto
   2409   (bfd *, arelent *, Elf_Internal_Rela *);
   2410 
   2411 extern bool bfd_section_from_shdr
   2412   (bfd *, unsigned int shindex);
   2413 extern bool bfd_section_from_phdr
   2414   (bfd *, Elf_Internal_Phdr *, int);
   2415 
   2416 extern int _bfd_elf_symbol_from_bfd_symbol
   2417   (bfd *, asymbol **);
   2418 
   2419 extern Elf_Internal_Sym *bfd_sym_from_r_symndx
   2420   (struct sym_cache *, bfd *, unsigned long);
   2421 extern asection *bfd_section_from_elf_index
   2422   (bfd *, unsigned int);
   2423 
   2424 extern struct elf_strtab_hash * _bfd_elf_strtab_init
   2425   (void);
   2426 extern void _bfd_elf_strtab_free
   2427   (struct elf_strtab_hash *);
   2428 extern size_t _bfd_elf_strtab_add
   2429   (struct elf_strtab_hash *, const char *, bool);
   2430 extern void _bfd_elf_strtab_addref
   2431   (struct elf_strtab_hash *, size_t);
   2432 extern void _bfd_elf_strtab_delref
   2433   (struct elf_strtab_hash *, size_t);
   2434 extern unsigned int _bfd_elf_strtab_refcount
   2435   (struct elf_strtab_hash *, size_t);
   2436 extern void _bfd_elf_strtab_clear_all_refs
   2437   (struct elf_strtab_hash *);
   2438 extern void *_bfd_elf_strtab_save
   2439   (struct elf_strtab_hash *);
   2440 extern void _bfd_elf_strtab_restore
   2441   (struct elf_strtab_hash *, void *);
   2442 extern bfd_size_type _bfd_elf_strtab_size
   2443   (struct elf_strtab_hash *);
   2444 extern bfd_size_type _bfd_elf_strtab_len
   2445   (struct elf_strtab_hash *);
   2446 extern bfd_size_type _bfd_elf_strtab_offset
   2447   (struct elf_strtab_hash *, size_t);
   2448 extern const char * _bfd_elf_strtab_str
   2449   (struct elf_strtab_hash *, size_t idx, bfd_size_type *offset);
   2450 extern bool _bfd_elf_strtab_emit
   2451   (bfd *, struct elf_strtab_hash *);
   2452 extern void _bfd_elf_strtab_finalize
   2453   (struct elf_strtab_hash *);
   2454 
   2455 extern bool bfd_elf_parse_eh_frame_entries
   2456   (bfd *, struct bfd_link_info *);
   2457 extern bool _bfd_elf_parse_eh_frame_entry
   2458   (struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
   2459 extern void _bfd_elf_parse_eh_frame
   2460   (bfd *, struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
   2461 extern bool _bfd_elf_end_eh_frame_parsing
   2462   (struct bfd_link_info *info);
   2463 
   2464 extern bool _bfd_elf_discard_section_eh_frame
   2465   (bfd *, struct bfd_link_info *, asection *,
   2466    bool (*) (bfd_vma, void *), struct elf_reloc_cookie *);
   2467 extern bool _bfd_elf_adjust_eh_frame_global_symbol
   2468   (struct elf_link_hash_entry *, void *);
   2469 extern bool _bfd_elf_discard_section_eh_frame_hdr
   2470   (struct bfd_link_info *);
   2471 extern bfd_vma _bfd_elf_eh_frame_section_offset
   2472   (bfd *, struct bfd_link_info *, asection *, bfd_vma);
   2473 extern bool _bfd_elf_write_section_eh_frame
   2474   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
   2475 bool _bfd_elf_write_section_eh_frame_entry
   2476   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
   2477 extern bool _bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *);
   2478 extern bool _bfd_elf_write_section_eh_frame_hdr
   2479   (bfd *, struct bfd_link_info *);
   2480 extern bool _bfd_elf_eh_frame_present
   2481   (struct bfd_link_info *);
   2482 extern bool _bfd_elf_eh_frame_entry_present
   2483   (struct bfd_link_info *);
   2484 extern bool _bfd_elf_maybe_strip_eh_frame_hdr
   2485   (struct bfd_link_info *);
   2486 
   2487 extern bool _bfd_elf_sframe_present
   2488   (struct bfd_link_info *);
   2489 extern bool _bfd_elf_parse_sframe
   2490   (bfd *, struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
   2491 extern bool _bfd_elf_discard_section_sframe
   2492   (asection *, bool (*) (bfd_vma, void *), struct elf_reloc_cookie *);
   2493 extern bool _bfd_elf_merge_section_sframe
   2494   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
   2495 extern bool _bfd_elf_write_section_sframe
   2496   (bfd *, struct bfd_link_info *);
   2497 extern bool _bfd_elf_set_section_sframe (bfd *, struct bfd_link_info *);
   2498 
   2499 extern bool _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
   2500 
   2501 extern long _bfd_elf_link_lookup_local_dynindx
   2502   (struct bfd_link_info *, bfd *, long);
   2503 extern bool _bfd_elf_compute_section_file_positions
   2504   (bfd *, struct bfd_link_info *);
   2505 extern file_ptr _bfd_elf_assign_file_position_for_section
   2506   (Elf_Internal_Shdr *, file_ptr, bool);
   2507 extern bool _bfd_elf_modify_headers
   2508   (bfd *, struct bfd_link_info *);
   2509 
   2510 extern bool _bfd_elf_validate_reloc
   2511   (bfd *, arelent *);
   2512 
   2513 extern bool bfd_elf_record_link_assignment
   2514   (bfd *, struct bfd_link_info *, const char *, bool,
   2515    bool);
   2516 extern bool bfd_elf_stack_segment_size (bfd *, struct bfd_link_info *,
   2517 					const char *, bfd_vma);
   2518 extern bool bfd_elf_size_dynamic_sections
   2519   (bfd *, const char *, const char *, const char *, const char *, const char *,
   2520    const char * const *, struct bfd_link_info *, struct bfd_section **);
   2521 extern bool bfd_elf_size_dynsym_hash_dynstr
   2522   (bfd *, struct bfd_link_info *);
   2523 extern bool bfd_elf_get_bfd_needed_list
   2524   (bfd *, struct bfd_link_needed_list **);
   2525 extern struct bfd_link_needed_list *bfd_elf_get_needed_list
   2526   (bfd *, struct bfd_link_info *);
   2527 extern void bfd_elf_set_dt_needed_name
   2528   (bfd *, const char *);
   2529 extern const char *bfd_elf_get_dt_soname
   2530   (bfd *);
   2531 extern void bfd_elf_set_dyn_lib_class
   2532   (bfd *, enum dynamic_lib_link_class);
   2533 extern int bfd_elf_get_dyn_lib_class
   2534   (bfd *);
   2535 extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
   2536   (bfd *, struct bfd_link_info *);
   2537 extern int bfd_elf_discard_info
   2538   (bfd *, struct bfd_link_info *);
   2539 extern unsigned int _bfd_elf_default_action_discarded
   2540   (struct bfd_section *);
   2541 extern struct bfd_section *_bfd_elf_tls_setup
   2542   (bfd *, struct bfd_link_info *);
   2543 
   2544 extern bool _bfd_elf_link_create_dynamic_sections
   2545   (bfd *, struct bfd_link_info *);
   2546 extern bool _bfd_elf_omit_section_dynsym_default
   2547   (bfd *, struct bfd_link_info *, asection *);
   2548 extern bool _bfd_elf_omit_section_dynsym_all
   2549   (bfd *, struct bfd_link_info *, asection *);
   2550 extern bool _bfd_elf_create_dynamic_sections
   2551   (bfd *, struct bfd_link_info *);
   2552 extern bool _bfd_elf_create_got_section
   2553   (bfd *, struct bfd_link_info *);
   2554 extern asection *_bfd_elf_section_for_symbol
   2555   (struct elf_reloc_cookie *, unsigned long, bool);
   2556 extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
   2557   (bfd *, struct bfd_link_info *, asection *, const char *);
   2558 extern void _bfd_elf_init_1_index_section
   2559   (bfd *, struct bfd_link_info *);
   2560 extern void _bfd_elf_init_2_index_sections
   2561   (bfd *, struct bfd_link_info *);
   2562 
   2563 extern bool _bfd_elfcore_make_pseudosection
   2564   (bfd *, char *, size_t, ufile_ptr);
   2565 extern char *_bfd_elfcore_strndup
   2566   (bfd *, char *, size_t);
   2567 
   2568 extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
   2569   (bfd *, asection *, void *, Elf_Internal_Rela *, bool);
   2570 extern Elf_Internal_Rela *_bfd_elf_link_info_read_relocs
   2571   (bfd *, struct bfd_link_info *, asection *, void *, Elf_Internal_Rela *,
   2572    bool);
   2573 
   2574 extern bool _bfd_elf_link_output_relocs
   2575   (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
   2576    struct elf_link_hash_entry **);
   2577 
   2578 extern bool _bfd_elf_adjust_dynamic_copy
   2579   (struct bfd_link_info *, struct elf_link_hash_entry *, asection *);
   2580 
   2581 extern bool _bfd_elf_dynamic_symbol_p
   2582   (struct elf_link_hash_entry *, struct bfd_link_info *, bool);
   2583 
   2584 extern bool _bfd_elf_symbol_refs_local_p
   2585   (struct elf_link_hash_entry *, struct bfd_link_info *, bool);
   2586 
   2587 extern bfd_reloc_status_type bfd_elf_perform_complex_relocation
   2588   (bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma);
   2589 
   2590 extern bool _bfd_elf_setup_sections
   2591   (bfd *);
   2592 
   2593 extern struct bfd_link_hash_entry *bfd_elf_define_start_stop
   2594   (struct bfd_link_info *, const char *, asection *);
   2595 
   2596 extern bool _bfd_elf_init_file_header (bfd *, struct bfd_link_info *);
   2597 
   2598 extern bool _bfd_elf_final_write_processing (bfd *);
   2599 
   2600 extern bfd_cleanup bfd_elf32_object_p
   2601   (bfd *);
   2602 extern bfd_cleanup bfd_elf32_core_file_p
   2603   (bfd *);
   2604 extern char *bfd_elf32_core_file_failing_command
   2605   (bfd *);
   2606 extern int bfd_elf32_core_file_failing_signal
   2607   (bfd *);
   2608 extern bool bfd_elf32_core_file_matches_executable_p
   2609   (bfd *, bfd *);
   2610 extern int bfd_elf32_core_file_pid
   2611   (bfd *);
   2612 extern bool _bfd_elf32_core_find_build_id
   2613   (bfd *, bfd_vma);
   2614 
   2615 extern bool bfd_elf32_swap_symbol_in
   2616   (bfd *, const void *, const void *, Elf_Internal_Sym *);
   2617 extern void bfd_elf32_swap_symbol_out
   2618   (bfd *, const Elf_Internal_Sym *, void *, void *);
   2619 extern void bfd_elf32_swap_reloc_in
   2620   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
   2621 extern void bfd_elf32_swap_reloc_out
   2622   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
   2623 extern void bfd_elf32_swap_reloca_in
   2624   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
   2625 extern void bfd_elf32_swap_reloca_out
   2626   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
   2627 extern void bfd_elf32_swap_phdr_in
   2628   (bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *);
   2629 extern void bfd_elf32_swap_phdr_out
   2630   (bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *);
   2631 extern void bfd_elf32_swap_dyn_in
   2632   (bfd *, const void *, Elf_Internal_Dyn *);
   2633 extern void bfd_elf32_swap_dyn_out
   2634   (bfd *, const Elf_Internal_Dyn *, void *);
   2635 extern long bfd_elf32_slurp_symbol_table
   2636   (bfd *, asymbol **, bool);
   2637 extern bool bfd_elf32_write_shdrs_and_ehdr
   2638   (bfd *);
   2639 extern int bfd_elf32_write_out_phdrs
   2640   (bfd *, const Elf_Internal_Phdr *, unsigned int);
   2641 extern bool bfd_elf32_checksum_contents
   2642   (bfd * , void (*) (const void *, size_t, void *), void *);
   2643 extern void bfd_elf32_write_relocs
   2644   (bfd *, asection *, void *);
   2645 extern bool bfd_elf32_slurp_reloc_table
   2646   (bfd *, asection *, asymbol **, bool);
   2647 
   2648 extern bfd_cleanup bfd_elf64_object_p
   2649   (bfd *);
   2650 extern bfd_cleanup bfd_elf64_core_file_p
   2651   (bfd *);
   2652 extern char *bfd_elf64_core_file_failing_command
   2653   (bfd *);
   2654 extern int bfd_elf64_core_file_failing_signal
   2655   (bfd *);
   2656 extern bool bfd_elf64_core_file_matches_executable_p
   2657   (bfd *, bfd *);
   2658 extern int bfd_elf64_core_file_pid
   2659   (bfd *);
   2660 extern bool _bfd_elf64_core_find_build_id
   2661   (bfd *, bfd_vma);
   2662 
   2663 extern bool bfd_elf64_swap_symbol_in
   2664   (bfd *, const void *, const void *, Elf_Internal_Sym *);
   2665 extern void bfd_elf64_swap_symbol_out
   2666   (bfd *, const Elf_Internal_Sym *, void *, void *);
   2667 extern void bfd_elf64_swap_reloc_in
   2668   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
   2669 extern void bfd_elf64_swap_reloc_out
   2670   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
   2671 extern void bfd_elf64_swap_reloca_in
   2672   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
   2673 extern void bfd_elf64_swap_reloca_out
   2674   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
   2675 extern void bfd_elf64_swap_phdr_in
   2676   (bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *);
   2677 extern void bfd_elf64_swap_phdr_out
   2678   (bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *);
   2679 extern void bfd_elf64_swap_dyn_in
   2680   (bfd *, const void *, Elf_Internal_Dyn *);
   2681 extern void bfd_elf64_swap_dyn_out
   2682   (bfd *, const Elf_Internal_Dyn *, void *);
   2683 extern long bfd_elf64_slurp_symbol_table
   2684   (bfd *, asymbol **, bool);
   2685 extern bool bfd_elf64_write_shdrs_and_ehdr
   2686   (bfd *);
   2687 extern int bfd_elf64_write_out_phdrs
   2688   (bfd *, const Elf_Internal_Phdr *, unsigned int);
   2689 extern bool bfd_elf64_checksum_contents
   2690   (bfd * , void (*) (const void *, size_t, void *), void *);
   2691 extern void bfd_elf64_write_relocs
   2692   (bfd *, asection *, void *);
   2693 extern bool bfd_elf64_slurp_reloc_table
   2694   (bfd *, asection *, asymbol **, bool);
   2695 
   2696 extern bool _bfd_elf_default_relocs_compatible
   2697   (const bfd_target *, const bfd_target *);
   2698 
   2699 extern bool _bfd_elf_relocs_compatible
   2700   (const bfd_target *, const bfd_target *);
   2701 extern bool _bfd_elf_notice_as_needed
   2702   (bfd *, struct bfd_link_info *, enum notice_asneeded_action);
   2703 
   2704 extern struct bfd_link_hash_entry *_bfd_elf_archive_symbol_lookup
   2705   (bfd *, struct bfd_link_info *, const char *);
   2706 extern bool bfd_elf_link_add_symbols
   2707   (bfd *, struct bfd_link_info *);
   2708 extern bool _bfd_elf_add_dynamic_entry
   2709   (struct bfd_link_info *, bfd_vma, bfd_vma);
   2710 extern bool _bfd_elf_strip_zero_sized_dynamic_sections
   2711   (struct bfd_link_info *);
   2712 extern int bfd_elf_add_dt_needed_tag
   2713   (bfd *, struct bfd_link_info *);
   2714 extern bool _bfd_elf_link_check_relocs
   2715   (bfd *, struct bfd_link_info *);
   2716 extern bool _bfd_elf_link_iterate_on_relocs
   2717  (bfd *, struct bfd_link_info *,
   2718   bool (*) (bfd *, struct bfd_link_info *, asection *,
   2719 	    const Elf_Internal_Rela *));
   2720 
   2721 extern bool bfd_elf_link_record_dynamic_symbol
   2722   (struct bfd_link_info *, struct elf_link_hash_entry *);
   2723 
   2724 extern int bfd_elf_link_record_local_dynamic_symbol
   2725   (struct bfd_link_info *, bfd *, long);
   2726 
   2727 extern bool _bfd_elf_close_and_cleanup
   2728   (bfd *);
   2729 
   2730 extern bool _bfd_elf_common_definition
   2731   (Elf_Internal_Sym *);
   2732 
   2733 extern unsigned int _bfd_elf_common_section_index
   2734   (asection *);
   2735 
   2736 extern asection *_bfd_elf_common_section
   2737   (asection *);
   2738 
   2739 extern bfd_vma _bfd_elf_default_got_elt_size
   2740 (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, bfd *,
   2741  unsigned long);
   2742 
   2743 extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
   2744   (bfd *, arelent *, struct bfd_symbol *, void *,
   2745    asection *, bfd *, char **);
   2746 
   2747 extern bool bfd_elf_final_link
   2748   (bfd *, struct bfd_link_info *);
   2749 
   2750 extern void _bfd_elf_gc_keep
   2751   (struct bfd_link_info *info);
   2752 
   2753 extern bool bfd_elf_gc_mark_dynamic_ref_symbol
   2754   (struct elf_link_hash_entry *h, void *inf);
   2755 
   2756 extern bool bfd_elf_gc_sections
   2757   (bfd *, struct bfd_link_info *);
   2758 
   2759 extern bool bfd_elf_gc_record_vtinherit
   2760   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
   2761 
   2762 extern bool bfd_elf_gc_record_vtentry
   2763   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
   2764 
   2765 extern asection *_bfd_elf_gc_mark_hook
   2766   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
   2767    struct elf_link_hash_entry *, Elf_Internal_Sym *);
   2768 
   2769 extern asection *_bfd_elf_gc_mark_rsec
   2770   (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn,
   2771    struct elf_reloc_cookie *, bool *);
   2772 
   2773 extern bool _bfd_elf_gc_mark_reloc
   2774   (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn,
   2775    struct elf_reloc_cookie *);
   2776 
   2777 extern bool _bfd_elf_gc_mark_fdes
   2778   (struct bfd_link_info *, asection *, asection *, elf_gc_mark_hook_fn,
   2779    struct elf_reloc_cookie *);
   2780 
   2781 extern bool _bfd_elf_gc_mark
   2782   (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn);
   2783 
   2784 extern bool _bfd_elf_gc_mark_extra_sections
   2785   (struct bfd_link_info *, elf_gc_mark_hook_fn);
   2786 
   2787 extern bool bfd_elf_gc_common_finalize_got_offsets
   2788   (bfd *, struct bfd_link_info *);
   2789 
   2790 extern bool bfd_elf_gc_common_final_link
   2791   (bfd *, struct bfd_link_info *);
   2792 
   2793 extern bool bfd_elf_reloc_symbol_deleted_p
   2794   (bfd_vma, void *);
   2795 
   2796 extern struct elf_segment_map * _bfd_elf_make_dynamic_segment
   2797   (bfd *, asection *);
   2798 
   2799 extern bool _bfd_elf_map_sections_to_segments
   2800   (bfd *, struct bfd_link_info *, bool *);
   2801 
   2802 extern bool _bfd_elf_is_function_type (unsigned int);
   2803 
   2804 extern bfd_size_type _bfd_elf_maybe_function_sym (const asymbol *, asection *,
   2805 						  bfd_vma *);
   2806 
   2807 extern asection *_bfd_elf_plt_get_reloc_section (bfd *, const char *);
   2808 
   2809 extern int bfd_elf_get_default_section_type (flagword);
   2810 
   2811 extern bool bfd_elf_lookup_section_flags
   2812   (struct bfd_link_info *, struct flag_info *, asection *);
   2813 
   2814 extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
   2815   (bfd * abfd, asection * section);
   2816 
   2817 /* PowerPC @tls opcode transform/validate.  */
   2818 extern unsigned int _bfd_elf_ppc_at_tls_transform
   2819   (unsigned int, unsigned int);
   2820 /* PowerPC @tprel opcode transform/validate.  */
   2821 extern unsigned int _bfd_elf_ppc_at_tprel_transform
   2822   (unsigned int, unsigned int);
   2823 /* PowerPC elf_object_p tweak.  */
   2824 extern bool _bfd_elf_ppc_set_arch (bfd *);
   2825 /* PowerPC .gnu.attributes handling common to both 32-bit and 64-bit.  */
   2826 extern bool _bfd_elf_ppc_merge_fp_attributes
   2827   (bfd *, struct bfd_link_info *);
   2828 
   2829 /* Return an upper bound on the number of bytes required to store a
   2830    copy of ABFD's program header table entries.  Return -1 if an error
   2831    occurs; bfd_get_error will return an appropriate code.  */
   2832 extern long bfd_get_elf_phdr_upper_bound
   2833   (bfd *abfd);
   2834 
   2835 /* Copy ABFD's program header table entries to *PHDRS.  The entries
   2836    will be stored as an array of Elf_Internal_Phdr structures, as
   2837    defined in include/elf/internal.h.  To find out how large the
   2838    buffer needs to be, call bfd_get_elf_phdr_upper_bound.
   2839 
   2840    Return the number of program header table entries read, or -1 if an
   2841    error occurs; bfd_get_error will return an appropriate code.  */
   2842 extern int bfd_get_elf_phdrs
   2843   (bfd *abfd, void *phdrs);
   2844 
   2845 /* Exported interface for writing elf corefile notes.  */
   2846 extern char *elfcore_write_note
   2847   (bfd *, char *, int *, const char *, int, const void *, int);
   2848 extern char *elfcore_write_prpsinfo
   2849   (bfd *, char *, int *, const char *, const char *);
   2850 extern char *elfcore_write_prstatus
   2851   (bfd *, char *, int *, long, int, const void *);
   2852 extern char * elfcore_write_pstatus
   2853   (bfd *, char *, int *, long, int, const void *);
   2854 extern char *elfcore_write_prfpreg
   2855   (bfd *, char *, int *, const void *, int);
   2856 extern char *elfcore_write_prxfpreg
   2857   (bfd *, char *, int *, const void *, int);
   2858 extern char *elfcore_write_xstatereg
   2859   (bfd *, char *, int *, const void *, int);
   2860 extern char *elfcore_write_x86_segbases
   2861   (bfd *, char *, int *, const void *, int);
   2862 extern char *elfcore_write_ppc_vmx
   2863   (bfd *, char *, int *, const void *, int);
   2864 extern char *elfcore_write_ppc_vsx
   2865   (bfd *, char *, int *, const void *, int);
   2866 extern char *elfcore_write_ppc_tar
   2867   (bfd *, char *, int *, const void *, int);
   2868 extern char *elfcore_write_ppc_ppr
   2869   (bfd *, char *, int *, const void *, int);
   2870 extern char *elfcore_write_ppc_dscr
   2871   (bfd *, char *, int *, const void *, int);
   2872 extern char *elfcore_write_ppc_ebb
   2873   (bfd *, char *, int *, const void *, int);
   2874 extern char *elfcore_write_ppc_pmu
   2875   (bfd *, char *, int *, const void *, int);
   2876 extern char *elfcore_write_ppc_tm_cgpr
   2877   (bfd *, char *, int *, const void *, int);
   2878 extern char *elfcore_write_ppc_tm_cfpr
   2879   (bfd *, char *, int *, const void *, int);
   2880 extern char *elfcore_write_ppc_tm_cvmx
   2881   (bfd *, char *, int *, const void *, int);
   2882 extern char *elfcore_write_ppc_tm_cvsx
   2883   (bfd *, char *, int *, const void *, int);
   2884 extern char *elfcore_write_ppc_tm_spr
   2885   (bfd *, char *, int *, const void *, int);
   2886 extern char *elfcore_write_ppc_tm_ctar
   2887   (bfd *, char *, int *, const void *, int);
   2888 extern char *elfcore_write_ppc_tm_cppr
   2889   (bfd *, char *, int *, const void *, int);
   2890 extern char *elfcore_write_ppc_tm_cdscr
   2891   (bfd *, char *, int *, const void *, int);
   2892 extern char *elfcore_write_s390_timer
   2893   (bfd *, char *, int *, const void *, int);
   2894 extern char *elfcore_write_s390_todcmp
   2895   (bfd *, char *, int *, const void *, int);
   2896 extern char *elfcore_write_s390_todpreg
   2897   (bfd *, char *, int *, const void *, int);
   2898 extern char *elfcore_write_s390_ctrs
   2899   (bfd *, char *, int *, const void *, int);
   2900 extern char *elfcore_write_s390_prefix
   2901   (bfd *, char *, int *, const void *, int);
   2902 extern char *elfcore_write_s390_last_break
   2903   (bfd *, char *, int *, const void *, int);
   2904 extern char *elfcore_write_s390_system_call
   2905   (bfd *, char *, int *, const void *, int);
   2906 extern char *elfcore_write_s390_tdb
   2907   (bfd *, char *, int *, const void *, int);
   2908 extern char *elfcore_write_s390_vxrs_low
   2909   (bfd *, char *, int *, const void *, int);
   2910 extern char *elfcore_write_s390_vxrs_high
   2911   (bfd *, char *, int *, const void *, int);
   2912 extern char *elfcore_write_s390_gs_cb
   2913   (bfd *, char *, int *, const void *, int);
   2914 extern char *elfcore_write_s390_gs_bc
   2915   (bfd *, char *, int *, const void *, int);
   2916 extern char *elfcore_write_arm_vfp
   2917   (bfd *, char *, int *, const void *, int);
   2918 extern char *elfcore_write_aarch_tls
   2919   (bfd *, char *, int *, const void *, int);
   2920 extern char *elfcore_write_aarch_hw_break
   2921   (bfd *, char *, int *, const void *, int);
   2922 extern char *elfcore_write_aarch_hw_watch
   2923   (bfd *, char *, int *, const void *, int);
   2924 extern char *elfcore_write_aarch_sve
   2925   (bfd *, char *, int *, const void *, int);
   2926 extern char *elfcore_write_aarch_pauth
   2927   (bfd *, char *, int *, const void *, int);
   2928 extern char *elfcore_write_aarch_mte
   2929   (bfd *, char *, int *, const void *, int);
   2930 extern char *elfcore_write_arc_v2
   2931   (bfd *, char *, int *, const void *, int);
   2932 extern char *elfcore_write_riscv_csr
   2933   (bfd *, char *, int *, const void *, int);
   2934 extern char *elfcore_write_gdb_tdesc
   2935   (bfd *, char *, int *, const void *, int);
   2936 extern char *elfcore_write_lwpstatus
   2937   (bfd *, char *, int *, long, int, const void *);
   2938 extern char *elfcore_write_register_note
   2939   (bfd *, char *, int *, const char *, const void *, int);
   2940 extern char *elfcore_write_file_note
   2941   (bfd *, char *, int *, const void*, int);
   2942 extern char *elfcore_write_loongarch_cpucfg
   2943   (bfd *, char *, int *, const void*, int);
   2944 extern char *elfcore_write_loongarch_lbt
   2945   (bfd *, char *, int *, const void*, int);
   2946 extern char *elfcore_write_loongarch_lsx
   2947   (bfd *, char *, int *, const void*, int);
   2948 extern char *elfcore_write_loongarch_lasx
   2949   (bfd *, char *, int *, const void*, int);
   2950 
   2951 /* Internal structure which holds information to be included in the
   2952    PRPSINFO section of Linux core files.
   2953 
   2954    This is an "internal" structure in the sense that it should be used
   2955    to pass information to BFD (via the `elfcore_write_linux_prpsinfo'
   2956    function), so things like endianess shouldn't be an issue.  This
   2957    structure will eventually be converted in one of the
   2958    `elf_external_linux_*' structures and written out to an output bfd
   2959    by one of the functions declared below.  */
   2960 
   2961 struct elf_internal_linux_prpsinfo
   2962   {
   2963     char pr_state;			/* Numeric process state.  */
   2964     char pr_sname;			/* Char for pr_state.  */
   2965     char pr_zomb;			/* Zombie.  */
   2966     char pr_nice;			/* Nice val.  */
   2967     unsigned long pr_flag;		/* Flags.  */
   2968     unsigned int pr_uid;
   2969     unsigned int pr_gid;
   2970     int pr_pid, pr_ppid, pr_pgrp, pr_sid;
   2971     char pr_fname[16 + 1];		/* Filename of executable.  */
   2972     char pr_psargs[80 + 1];		/* Initial part of arg list.  */
   2973   };
   2974 
   2975 /* Linux/most 32-bit archs.  */
   2976 extern char *elfcore_write_linux_prpsinfo32
   2977   (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
   2978 
   2979 /* Linux/most 64-bit archs.  */
   2980 extern char *elfcore_write_linux_prpsinfo64
   2981   (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
   2982 
   2983 extern bfd *_bfd_elf32_bfd_from_remote_memory
   2984   (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
   2985    int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
   2986 extern bfd *_bfd_elf64_bfd_from_remote_memory
   2987   (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
   2988    int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
   2989 
   2990 extern bfd_vma bfd_elf_obj_attr_size (bfd *);
   2991 extern void bfd_elf_set_obj_attr_contents (bfd *, bfd_byte *, bfd_vma);
   2992 extern int bfd_elf_get_obj_attr_int (bfd *, int, unsigned int);
   2993 extern void bfd_elf_add_obj_attr_int (bfd *, int, unsigned int, unsigned int);
   2994 #define bfd_elf_add_proc_attr_int(BFD, TAG, VALUE) \
   2995   bfd_elf_add_obj_attr_int ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
   2996 extern void bfd_elf_add_obj_attr_string (bfd *, int, unsigned int, const char *);
   2997 #define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \
   2998   bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
   2999 extern void bfd_elf_add_obj_attr_int_string (bfd *, int, unsigned int,
   3000 					     unsigned int, const char *);
   3001 #define bfd_elf_add_proc_attr_int_string(BFD, TAG, INTVAL, STRVAL) \
   3002   bfd_elf_add_obj_attr_int_string ((BFD), OBJ_ATTR_PROC, (TAG), \
   3003 				   (INTVAL), (STRVAL))
   3004 
   3005 extern char *_bfd_elf_attr_strdup (bfd *, const char *);
   3006 extern void _bfd_elf_copy_obj_attributes (bfd *, bfd *);
   3007 extern int _bfd_elf_obj_attrs_arg_type (bfd *, int, unsigned int);
   3008 extern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *);
   3009 extern bool _bfd_elf_merge_object_attributes
   3010   (bfd *, struct bfd_link_info *);
   3011 extern bool _bfd_elf_merge_unknown_attribute_low (bfd *, bfd *, int);
   3012 extern bool _bfd_elf_merge_unknown_attribute_list (bfd *, bfd *);
   3013 extern Elf_Internal_Shdr *_bfd_elf_single_rel_hdr (asection *sec);
   3014 extern bool elf_read_notes (bfd *, file_ptr, bfd_size_type, size_t);
   3015 
   3016 extern bool _bfd_elf_parse_gnu_properties
   3017   (bfd *, Elf_Internal_Note *);
   3018 extern elf_property * _bfd_elf_get_property
   3019   (bfd *, unsigned int, unsigned int);
   3020 extern bfd *_bfd_elf_link_setup_gnu_properties
   3021   (struct bfd_link_info *);
   3022 extern bfd_size_type _bfd_elf_convert_gnu_property_size
   3023   (bfd *, bfd *);
   3024 extern bool _bfd_elf_convert_gnu_properties
   3025   (bfd *, asection *, bfd *, bfd_byte **, bfd_size_type *);
   3026 
   3027 /* The linker may need to keep track of the number of relocs that it
   3028    decides to copy as dynamic relocs in check_relocs for each symbol.
   3029    This is so that it can later discard them if they are found to be
   3030    unnecessary.  We can store the information in a field extending the
   3031    regular ELF linker hash table.  */
   3032 
   3033 struct elf_dyn_relocs
   3034 {
   3035   struct elf_dyn_relocs *next;
   3036 
   3037   /* The input section of the reloc.  */
   3038   asection *sec;
   3039 
   3040   /* Total number of relocs copied for the input section.  */
   3041   bfd_size_type count;
   3042 
   3043   /* Number of pc-relative relocs copied for the input section.  */
   3044   bfd_size_type pc_count;
   3045 };
   3046 
   3047 extern bool _bfd_elf_create_ifunc_sections
   3048   (bfd *, struct bfd_link_info *);
   3049 extern bool _bfd_elf_allocate_ifunc_dyn_relocs
   3050   (struct bfd_link_info *, struct elf_link_hash_entry *,
   3051    struct elf_dyn_relocs **, unsigned int, unsigned int,
   3052    unsigned int, bool);
   3053 
   3054 extern void elf_append_rela (bfd *, asection *, Elf_Internal_Rela *);
   3055 extern void elf_append_rel (bfd *, asection *, Elf_Internal_Rela *);
   3056 
   3057 extern bfd_vma elf64_r_info (bfd_vma, bfd_vma);
   3058 extern bfd_vma elf64_r_sym (bfd_vma);
   3059 extern bfd_vma elf32_r_info (bfd_vma, bfd_vma);
   3060 extern bfd_vma elf32_r_sym (bfd_vma);
   3061 
   3062 extern bool is_debuginfo_file (bfd *);
   3063 
   3064 
   3065 extern bool _bfd_elf_init_secondary_reloc_section
   3066   (bfd *, Elf_Internal_Shdr *, const char *, unsigned int);
   3067 extern bool _bfd_elf_slurp_secondary_reloc_section
   3068   (bfd *, asection *, asymbol **, bool);
   3069 extern bool _bfd_elf_copy_special_section_fields
   3070   (const bfd *, bfd *, const Elf_Internal_Shdr *, Elf_Internal_Shdr *);
   3071 extern bool _bfd_elf_write_secondary_reloc_section
   3072   (bfd *, asection *);
   3073 extern unsigned int _bfd_elf_symbol_section_index
   3074   (bfd *, elf_symbol_type *);
   3075 
   3076 extern asection *_bfd_elf_readonly_dynrelocs
   3077   (struct elf_link_hash_entry *);
   3078 extern bool _bfd_elf_maybe_set_textrel
   3079   (struct elf_link_hash_entry *, void *);
   3080 
   3081 extern bool _bfd_elf_add_dynamic_tags
   3082   (bfd *, struct bfd_link_info *, bool);
   3083 
   3084 /* Large common section.  */
   3085 extern asection _bfd_elf_large_com_section;
   3086 
   3087 /* Hash for local symbol with the first section id, ID, in the input
   3088    file and the local symbol index, SYM.  */
   3089 #define ELF_LOCAL_SYMBOL_HASH(ID, SYM) \
   3090   (((((ID) & 0xffU) << 24) | (((ID) & 0xff00) << 8)) \
   3091    ^ (SYM) ^ (((ID) & 0xffff0000U) >> 16))
   3092 
   3093 /* This is the condition under which finish_dynamic_symbol will be called.
   3094    If our finish_dynamic_symbol isn't called, we'll need to do something
   3095    about initializing any .plt and .got entries in relocate_section.  */
   3096 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
   3097   ((DYN)								\
   3098    && ((SHARED) || !(H)->forced_local)					\
   3099    && ((H)->dynindx != -1 || (H)->forced_local))
   3100 
   3101 /* This macro is to avoid lots of duplicated code in the body
   3102    of xxx_relocate_section() in the various elfxx-xxxx.c files.  */
   3103 #define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel,	\
   3104 				r_symndx, symtab_hdr, sym_hashes,	\
   3105 				h, sec, relocation,			\
   3106 				unresolved_reloc, warned, ignored)	\
   3107   do									\
   3108     {									\
   3109       /* It seems this can happen with erroneous or unsupported		\
   3110 	 input (mixing a.out and elf in an archive, for example.)  */	\
   3111       if (sym_hashes == NULL)						\
   3112 	return false;							\
   3113 									\
   3114       h = sym_hashes[r_symndx - symtab_hdr->sh_info];			\
   3115 									\
   3116       if (info->wrap_hash != NULL					\
   3117 	  && (input_section->flags & SEC_DEBUGGING) != 0)		\
   3118 	h = ((struct elf_link_hash_entry *)				\
   3119 	     unwrap_hash_lookup (info, input_bfd, &h->root));		\
   3120 									\
   3121       while (h->root.type == bfd_link_hash_indirect			\
   3122 	     || h->root.type == bfd_link_hash_warning)			\
   3123 	h = (struct elf_link_hash_entry *) h->root.u.i.link;		\
   3124 									\
   3125       warned = false;							\
   3126       ignored = false;							\
   3127       unresolved_reloc = false;						\
   3128       relocation = 0;							\
   3129       if (h->root.type == bfd_link_hash_defined				\
   3130 	  || h->root.type == bfd_link_hash_defweak)			\
   3131 	{								\
   3132 	  sec = h->root.u.def.section;					\
   3133 	  if (sec == NULL						\
   3134 	      || sec->output_section == NULL)				\
   3135 	    /* Set a flag that will be cleared later if we find a	\
   3136 	       relocation value for this symbol.  output_section	\
   3137 	       is typically NULL for symbols satisfied by a shared	\
   3138 	       library.  */						\
   3139 	    unresolved_reloc = true;					\
   3140 	  else								\
   3141 	    relocation = (h->root.u.def.value				\
   3142 			  + sec->output_section->vma			\
   3143 			  + sec->output_offset);			\
   3144 	}								\
   3145       else if (h->root.type == bfd_link_hash_undefweak)			\
   3146 	;								\
   3147       else if (info->unresolved_syms_in_objects == RM_IGNORE		\
   3148 	       && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)		\
   3149 	ignored = true;							\
   3150       else if (!bfd_link_relocatable (info))				\
   3151 	{								\
   3152 	  bool err = ((info->unresolved_syms_in_objects == RM_DIAGNOSE	\
   3153 		       && !info->warn_unresolved_syms)			\
   3154 		      || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT);	\
   3155 	  (*info->callbacks->undefined_symbol) (info,			\
   3156 						h->root.root.string,	\
   3157 						input_bfd,		\
   3158 						input_section,		\
   3159 						rel->r_offset, err);	\
   3160 	  warned = true;						\
   3161 	}								\
   3162       (void) unresolved_reloc;						\
   3163       (void) warned;							\
   3164       (void) ignored;							\
   3165     }									\
   3166   while (0)
   3167 
   3168 /* This macro is to avoid lots of duplicated code in the body of the
   3169    loop over relocations in xxx_relocate_section() in the various
   3170    elfxx-xxxx.c files.
   3171 
   3172    Handle relocations against symbols from removed linkonce sections,
   3173    or sections discarded by a linker script.  When doing a relocatable
   3174    link, we remove such relocations.  Otherwise, we just want the
   3175    section contents zeroed and avoid any special processing.  */
   3176 #define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section,	\
   3177 					rel, count, relend,		\
   3178 					howto, index, contents)		\
   3179   {									\
   3180     int i_;								\
   3181     _bfd_clear_contents (howto, input_bfd, input_section,		\
   3182 			 contents, rel[index].r_offset);		\
   3183 									\
   3184     if (bfd_link_relocatable (info)					\
   3185 	&& (input_section->flags & SEC_DEBUGGING))			\
   3186       {									\
   3187 	/* Only remove relocations in debug sections since other	\
   3188 	   sections may require relocations.  */			\
   3189 	Elf_Internal_Shdr *rel_hdr;					\
   3190 									\
   3191 	rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); \
   3192 									\
   3193 	/* Avoid empty output section.  */				\
   3194 	if (rel_hdr->sh_size > rel_hdr->sh_entsize)			\
   3195 	  {								\
   3196 	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
   3197 	    rel_hdr = _bfd_elf_single_rel_hdr (input_section);		\
   3198 	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
   3199 									\
   3200 	    memmove (rel, rel + count,					\
   3201 		     (relend - rel - count) * sizeof (*rel));		\
   3202 									\
   3203 	    input_section->reloc_count -= count;			\
   3204 	    relend -= count;						\
   3205 	    rel--;							\
   3206 	    continue;							\
   3207 	  }								\
   3208       }									\
   3209 									\
   3210     for (i_ = 0; i_ < count; i_++)					\
   3211       {									\
   3212 	rel[i_].r_info = 0;						\
   3213 	rel[i_].r_addend = 0;						\
   3214       }									\
   3215     rel += count - 1;							\
   3216     continue;								\
   3217   }
   3218 
   3219 /* Will a symbol be bound to the definition within the shared
   3220    library, if any.  A unique symbol can never be bound locally.  */
   3221 #define SYMBOLIC_BIND(INFO, H) \
   3222     (!(H)->unique_global \
   3223      && ((INFO)->symbolic \
   3224 	 || (H)->start_stop \
   3225 	 || ((INFO)->dynamic && !(H)->dynamic)))
   3226 
   3227 /* Determine if a section contains CTF data, using its name.  */
   3228 static inline bool
   3229 bfd_section_is_ctf (const asection *sec)
   3230 {
   3231   const char *name = bfd_section_name (sec);
   3232   return startswith (name, ".ctf") && (name[4] == 0 || name[4] == '.');
   3233 }
   3234 
   3235 #ifdef __cplusplus
   3236 }
   3237 #endif
   3238 #endif /* _LIBELF_H_ */
   3239