Back to index

cell-binutils  2.17cvs20070401
elf-bfd.h
Go to the documentation of this file.
00001 /* BFD back-end data structures for ELF files.
00002    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
00003    2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
00004    Written by Cygnus Support.
00005 
00006    This file is part of BFD, the Binary File Descriptor library.
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00021 
00022 #ifndef _LIBELF_H_
00023 #define _LIBELF_H_ 1
00024 
00025 #include "elf/common.h"
00026 #include "elf/internal.h"
00027 #include "elf/external.h"
00028 #include "bfdlink.h"
00029 
00030 /* The number of entries in a section is its size divided by the size
00031    of a single entry.  This is normally only applicable to reloc and
00032    symbol table sections.  */
00033 #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
00034 
00035 /* If size isn't specified as 64 or 32, NAME macro should fail.  */
00036 #ifndef NAME
00037 #if ARCH_SIZE == 64
00038 #define NAME(x, y) x ## 64 ## _ ## y
00039 #endif
00040 #if ARCH_SIZE == 32
00041 #define NAME(x, y) x ## 32 ## _ ## y
00042 #endif
00043 #endif
00044 
00045 #ifndef NAME
00046 #define NAME(x, y) x ## NOSIZE ## _ ## y
00047 #endif
00048 
00049 #define ElfNAME(X)   NAME(Elf,X)
00050 #define elfNAME(X)   NAME(elf,X)
00051 
00052 /* Information held for an ELF symbol.  The first field is the
00053    corresponding asymbol.  Every symbol is an ELF file is actually a
00054    pointer to this structure, although it is often handled as a
00055    pointer to an asymbol.  */
00056 
00057 typedef struct
00058 {
00059   /* The BFD symbol.  */
00060   asymbol symbol;
00061   /* ELF symbol information.  */
00062   Elf_Internal_Sym internal_elf_sym;
00063   /* Backend specific information.  */
00064   union
00065     {
00066       unsigned int hppa_arg_reloc;
00067       void *mips_extr;
00068       void *any;
00069     }
00070   tc_data;
00071 
00072   /* Version information.  This is from an Elf_Internal_Versym
00073      structure in a SHT_GNU_versym section.  It is zero if there is no
00074      version information.  */
00075   unsigned short version;
00076 
00077 } elf_symbol_type;
00078 
00079 struct elf_strtab_hash;
00080 struct got_entry;
00081 struct plt_entry;
00082 
00083 /* ELF linker hash table entries.  */
00084 
00085 struct elf_link_hash_entry
00086 {
00087   struct bfd_link_hash_entry root;
00088 
00089   /* Symbol index in output file.  This is initialized to -1.  It is
00090      set to -2 if the symbol is used by a reloc.  */
00091   long indx;
00092 
00093   /* Symbol index as a dynamic symbol.  Initialized to -1, and remains
00094      -1 if this is not a dynamic symbol.  */
00095   /* ??? Note that this is consistently used as a synonym for tests
00096      against whether we can perform various simplifying transformations
00097      to the code.  (E.g. changing a pc-relative jump to a PLT entry
00098      into a pc-relative jump to the target function.)  That test, which
00099      is often relatively complex, and someplaces wrong or incomplete,
00100      should really be replaced by a predicate in elflink.c.
00101 
00102      End result: this field -1 does not indicate that the symbol is
00103      not in the dynamic symbol table, but rather that the symbol is
00104      not visible outside this DSO.  */
00105   long dynindx;
00106 
00107   /* If this symbol requires an entry in the global offset table, the
00108      processor specific backend uses this field to track usage and
00109      final offset.  Two schemes are supported:  The first assumes that
00110      a symbol may only have one GOT entry, and uses REFCOUNT until
00111      size_dynamic_sections, at which point the contents of the .got is
00112      fixed.  Afterward, if OFFSET is -1, then the symbol does not
00113      require a global offset table entry.  The second scheme allows
00114      multiple GOT entries per symbol, managed via a linked list
00115      pointed to by GLIST.  */
00116   union gotplt_union
00117     {
00118       bfd_signed_vma refcount;
00119       bfd_vma offset;
00120       struct got_entry *glist;
00121       struct plt_entry *plist;
00122     } got;
00123 
00124   /* Same, but tracks a procedure linkage table entry.  */
00125   union gotplt_union plt;
00126 
00127   /* Symbol size.  */
00128   bfd_size_type size;
00129 
00130   /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.).  */
00131   unsigned int type : 8;
00132 
00133   /* Symbol st_other value, symbol visibility.  */
00134   unsigned int other : 8;
00135 
00136   /* Symbol is referenced by a non-shared object.  */
00137   unsigned int ref_regular : 1;
00138   /* Symbol is defined by a non-shared object.  */
00139   unsigned int def_regular : 1;
00140   /* Symbol is referenced by a shared object.  */
00141   unsigned int ref_dynamic : 1;
00142   /* Symbol is defined by a shared object.  */
00143   unsigned int def_dynamic : 1;
00144   /* Symbol has a non-weak reference from a non-shared object.  */
00145   unsigned int ref_regular_nonweak : 1;
00146   /* Dynamic symbol has been adjustd.  */
00147   unsigned int dynamic_adjusted : 1;
00148   /* Symbol needs a copy reloc.  */
00149   unsigned int needs_copy : 1;
00150   /* Symbol needs a procedure linkage table entry.  */
00151   unsigned int needs_plt : 1;
00152   /* Symbol appears in a non-ELF input file.  */
00153   unsigned int non_elf : 1;
00154   /* Symbol should be marked as hidden in the version information.  */
00155   unsigned int hidden : 1;
00156   /* Symbol was forced to local scope due to a version script file.  */
00157   unsigned int forced_local : 1;
00158   /* Symbol was forced to be dynamic due to a version script file.  */
00159   unsigned int dynamic : 1;
00160   /* Symbol was marked during garbage collection.  */
00161   unsigned int mark : 1;
00162   /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
00163      not currently set by all the backends.  */
00164   unsigned int non_got_ref : 1;
00165   /* Symbol has a definition in a shared object.
00166      FIXME: There is no real need for this field if def_dynamic is never
00167      cleared and all places that test def_dynamic also test def_regular.  */
00168   unsigned int dynamic_def : 1;
00169   /* Symbol is weak in all shared objects.  */
00170   unsigned int dynamic_weak : 1;
00171   /* Symbol is referenced with a relocation where C/C++ pointer equality
00172      matters.  */
00173   unsigned int pointer_equality_needed : 1;
00174 
00175   /* String table index in .dynstr if this is a dynamic symbol.  */
00176   unsigned long dynstr_index;
00177 
00178   union
00179   {
00180     /* If this is a weak defined symbol from a dynamic object, this
00181        field points to a defined symbol with the same value, if there is
00182        one.  Otherwise it is NULL.  */
00183     struct elf_link_hash_entry *weakdef;
00184 
00185     /* Hash value of the name computed using the ELF hash function.
00186        Used part way through size_dynamic_sections, after we've finished
00187        with weakdefs.  */
00188     unsigned long elf_hash_value;
00189   } u;
00190 
00191   /* Version information.  */
00192   union
00193   {
00194     /* This field is used for a symbol which is not defined in a
00195        regular object.  It points to the version information read in
00196        from the dynamic object.  */
00197     Elf_Internal_Verdef *verdef;
00198     /* This field is used for a symbol which is defined in a regular
00199        object.  It is set up in size_dynamic_sections.  It points to
00200        the version information we should write out for this symbol.  */
00201     struct bfd_elf_version_tree *vertree;
00202   } verinfo;
00203 
00204   struct
00205   {
00206     /* Virtual table entry use information.  This array is nominally of size
00207        size/sizeof(target_void_pointer), though we have to be able to assume
00208        and track a size while the symbol is still undefined.  It is indexed
00209        via offset/sizeof(target_void_pointer).  */
00210     size_t size;
00211     bfd_boolean *used;
00212 
00213     /* Virtual table derivation info.  */
00214     struct elf_link_hash_entry *parent;
00215   } *vtable;
00216 };
00217 
00218 /* Will references to this symbol always reference the symbol
00219    in this object?  STV_PROTECTED is excluded from the visibility test
00220    here so that function pointer comparisons work properly.  Since
00221    function symbols not defined in an app are set to their .plt entry,
00222    it's necessary for shared libs to also reference the .plt even
00223    though the symbol is really local to the shared lib.  */
00224 #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
00225   _bfd_elf_symbol_refs_local_p (H, INFO, 0)
00226 
00227 /* Will _calls_ to this symbol always call the version in this object?  */
00228 #define SYMBOL_CALLS_LOCAL(INFO, H) \
00229   _bfd_elf_symbol_refs_local_p (H, INFO, 1)
00230 
00231 /* Common symbols that are turned into definitions don't have the
00232    DEF_REGULAR flag set, so they might appear to be undefined.  */
00233 #define ELF_COMMON_DEF_P(H) \
00234   (!(H)->def_regular                                           \
00235    && !(H)->def_dynamic                                               \
00236    && (H)->root.type == bfd_link_hash_defined)
00237 
00238 /* Records local symbols to be emitted in the dynamic symbol table.  */
00239 
00240 struct elf_link_local_dynamic_entry
00241 {
00242   struct elf_link_local_dynamic_entry *next;
00243 
00244   /* The input bfd this symbol came from.  */
00245   bfd *input_bfd;
00246 
00247   /* The index of the local symbol being copied.  */
00248   long input_indx;
00249 
00250   /* The index in the outgoing dynamic symbol table.  */
00251   long dynindx;
00252 
00253   /* A copy of the input symbol.  */
00254   Elf_Internal_Sym isym;
00255 };
00256 
00257 struct elf_link_loaded_list
00258 {
00259   struct elf_link_loaded_list *next;
00260   bfd *abfd;
00261 };
00262 
00263 /* Structures used by the eh_frame optimization code.  */
00264 struct eh_cie_fde
00265 {
00266   /* For FDEs, this points to the CIE used.  */
00267   struct eh_cie_fde *cie_inf;
00268   unsigned int size;
00269   unsigned int offset;
00270   unsigned int new_offset;
00271   unsigned char fde_encoding;
00272   unsigned char lsda_encoding;
00273   unsigned char lsda_offset;
00274   unsigned int cie : 1;
00275   unsigned int removed : 1;
00276   unsigned int add_augmentation_size : 1;
00277   unsigned int add_fde_encoding : 1;
00278   unsigned int make_relative : 1;
00279   unsigned int make_lsda_relative : 1;
00280   unsigned int need_lsda_relative : 1;
00281   unsigned int per_encoding_relative : 1;
00282   unsigned int *set_loc;
00283 };
00284 
00285 struct eh_frame_sec_info
00286 {
00287   unsigned int count;
00288   struct eh_cie_fde entry[1];
00289 };
00290 
00291 struct eh_frame_array_ent
00292 {
00293   bfd_vma initial_loc;
00294   bfd_vma fde;
00295 };
00296 
00297 struct htab;
00298 
00299 struct eh_frame_hdr_info
00300 {
00301   struct htab *cies;
00302   asection *hdr_sec;
00303   unsigned int fde_count, array_count;
00304   struct eh_frame_array_ent *array;
00305   /* TRUE if .eh_frame_hdr should contain the sorted search table.
00306      We build it if we successfully read all .eh_frame input sections
00307      and recognize them.  */
00308   bfd_boolean table;
00309   bfd_boolean offsets_adjusted;
00310 };
00311 
00312 /* ELF linker hash table.  */
00313 
00314 struct elf_link_hash_table
00315 {
00316   struct bfd_link_hash_table root;
00317 
00318   /* Whether we have created the special dynamic sections required
00319      when linking against or generating a shared object.  */
00320   bfd_boolean dynamic_sections_created;
00321 
00322   /* True if this target has relocatable executables, so needs dynamic
00323      section symbols.  */
00324   bfd_boolean is_relocatable_executable;
00325 
00326   /* The BFD used to hold special sections created by the linker.
00327      This will be the first BFD found which requires these sections to
00328      be created.  */
00329   bfd *dynobj;
00330 
00331   /* The value to use when initialising got.refcount/offset and
00332      plt.refcount/offset in an elf_link_hash_entry.  Set to zero when
00333      the values are refcounts.  Set to init_got_offset/init_plt_offset
00334      in size_dynamic_sections when the values may be offsets.  */
00335   union gotplt_union init_got_refcount;
00336   union gotplt_union init_plt_refcount;
00337 
00338   /* The value to use for got.refcount/offset and plt.refcount/offset
00339      when the values may be offsets.  Normally (bfd_vma) -1.  */
00340   union gotplt_union init_got_offset;
00341   union gotplt_union init_plt_offset;
00342 
00343   /* The number of symbols found in the link which must be put into
00344      the .dynsym section.  */
00345   bfd_size_type dynsymcount;
00346 
00347   /* The string table of dynamic symbols, which becomes the .dynstr
00348      section.  */
00349   struct elf_strtab_hash *dynstr;
00350 
00351   /* The number of buckets in the hash table in the .hash section.
00352      This is based on the number of dynamic symbols.  */
00353   bfd_size_type bucketcount;
00354 
00355   /* A linked list of DT_NEEDED names found in dynamic objects
00356      included in the link.  */
00357   struct bfd_link_needed_list *needed;
00358 
00359   /* Sections in the output bfd that provides a section symbol
00360      to be used by relocations emitted against local symbols.
00361      Most targets will not use data_index_section.  */
00362   asection *text_index_section;
00363   asection *data_index_section;
00364 
00365   /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
00366   struct elf_link_hash_entry *hgot;
00367 
00368   /* The _PROCEDURE_LINKAGE_TABLE_ symbol.  */
00369   struct elf_link_hash_entry *hplt;
00370 
00371   /* A pointer to information used to merge SEC_MERGE sections.  */
00372   void *merge_info;
00373 
00374   /* Used to link stabs in sections.  */
00375   struct stab_info stab_info;
00376 
00377   /* Used by eh_frame code when editing .eh_frame.  */
00378   struct eh_frame_hdr_info eh_info;
00379 
00380   /* A linked list of local symbols to be added to .dynsym.  */
00381   struct elf_link_local_dynamic_entry *dynlocal;
00382 
00383   /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
00384      objects included in the link.  */
00385   struct bfd_link_needed_list *runpath;
00386 
00387   /* Cached first output tls section and size of PT_TLS segment.  */
00388   asection *tls_sec;
00389   bfd_size_type tls_size;
00390 
00391   /* A linked list of BFD's loaded in the link.  */
00392   struct elf_link_loaded_list *loaded;
00393 };
00394 
00395 /* Look up an entry in an ELF linker hash table.  */
00396 
00397 #define elf_link_hash_lookup(table, string, create, copy, follow)     \
00398   ((struct elf_link_hash_entry *)                              \
00399    bfd_link_hash_lookup (&(table)->root, (string), (create),          \
00400                       (copy), (follow)))
00401 
00402 /* Traverse an ELF linker hash table.  */
00403 
00404 #define elf_link_hash_traverse(table, func, info)                     \
00405   (bfd_link_hash_traverse                                      \
00406    (&(table)->root,                                            \
00407     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),  \
00408     (info)))
00409 
00410 /* Get the ELF linker hash table from a link_info structure.  */
00411 
00412 #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
00413 
00414 /* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
00415 #define is_elf_hash_table(htab)                                       \
00416   (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
00417 
00418 /* Used by bfd_section_from_r_symndx to cache a small number of local
00419    symbol to section mappings.  */
00420 #define LOCAL_SYM_CACHE_SIZE 32
00421 struct sym_sec_cache
00422 {
00423   bfd *abfd;
00424   unsigned long indx[LOCAL_SYM_CACHE_SIZE];
00425   asection *sec[LOCAL_SYM_CACHE_SIZE];
00426 };
00427 
00428 /* Constant information held for an ELF backend.  */
00429 
00430 struct elf_size_info {
00431   unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
00432   unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
00433 
00434   /* The size of entries in the .hash section.  */
00435   unsigned char sizeof_hash_entry;
00436 
00437   /* The number of internal relocations to allocate per external
00438      relocation entry.  */
00439   unsigned char int_rels_per_ext_rel;
00440   /* We use some fixed size arrays.  This should be large enough to
00441      handle all back-ends.  */
00442 #define MAX_INT_RELS_PER_EXT_REL 3
00443 
00444   unsigned char arch_size, log_file_align;
00445   unsigned char elfclass, ev_current;
00446   int (*write_out_phdrs)
00447     (bfd *, const Elf_Internal_Phdr *, unsigned int);
00448   bfd_boolean
00449     (*write_shdrs_and_ehdr) (bfd *);
00450   void (*write_relocs)
00451     (bfd *, asection *, void *);
00452   bfd_boolean (*swap_symbol_in)
00453     (bfd *, const void *, const void *, Elf_Internal_Sym *);
00454   void (*swap_symbol_out)
00455     (bfd *, const Elf_Internal_Sym *, void *, void *);
00456   bfd_boolean (*slurp_reloc_table)
00457     (bfd *, asection *, asymbol **, bfd_boolean);
00458   long (*slurp_symbol_table)
00459     (bfd *, asymbol **, bfd_boolean);
00460   void (*swap_dyn_in)
00461     (bfd *, const void *, Elf_Internal_Dyn *);
00462   void (*swap_dyn_out)
00463     (bfd *, const Elf_Internal_Dyn *, void *);
00464 
00465   /* This function is called to swap in a REL relocation.  If an
00466      external relocation corresponds to more than one internal
00467      relocation, then all relocations are swapped in at once.  */
00468   void (*swap_reloc_in)
00469     (bfd *, const bfd_byte *, Elf_Internal_Rela *);
00470 
00471   /* This function is called to swap out a REL relocation.  */
00472   void (*swap_reloc_out)
00473     (bfd *, const Elf_Internal_Rela *, bfd_byte *);
00474 
00475   /* This function is called to swap in a RELA relocation.  If an
00476      external relocation corresponds to more than one internal
00477      relocation, then all relocations are swapped in at once.  */
00478   void (*swap_reloca_in)
00479     (bfd *, const bfd_byte *, Elf_Internal_Rela *);
00480 
00481   /* This function is called to swap out a RELA relocation.  */
00482   void (*swap_reloca_out)
00483     (bfd *, const Elf_Internal_Rela *, bfd_byte *);
00484 };
00485 
00486 #define elf_symbol_from(ABFD,S) \
00487        (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
00488          && (S)->the_bfd->tdata.elf_obj_data != 0) \
00489         ? (elf_symbol_type *) (S) \
00490         : 0)
00491 
00492 enum elf_reloc_type_class {
00493   reloc_class_normal,
00494   reloc_class_relative,
00495   reloc_class_plt,
00496   reloc_class_copy
00497 };
00498 
00499 struct elf_reloc_cookie
00500 {
00501   Elf_Internal_Rela *rels, *rel, *relend;
00502   Elf_Internal_Sym *locsyms;
00503   bfd *abfd;
00504   size_t locsymcount;
00505   size_t extsymoff;
00506   struct elf_link_hash_entry **sym_hashes;
00507   int r_sym_shift;
00508   bfd_boolean bad_symtab;
00509 };
00510 
00511 /* The level of IRIX compatibility we're striving for.  */
00512 
00513 typedef enum {
00514   ict_none,
00515   ict_irix5,
00516   ict_irix6
00517 } irix_compat_t;
00518 
00519 /* Mapping of ELF section names and types.  */
00520 struct bfd_elf_special_section
00521 {
00522   const char *prefix;
00523   int prefix_length;
00524   /* 0 means name must match PREFIX exactly.
00525      -1 means name must start with PREFIX followed by an arbitrary string.
00526      -2 means name must match PREFIX exactly or consist of PREFIX followed
00527      by a dot then anything.
00528      > 0 means name must start with the first PREFIX_LENGTH chars of
00529      PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX.  */
00530   int suffix_length;
00531   int type;
00532   int attr;
00533 };
00534 
00535 enum action_discarded
00536   {
00537     COMPLAIN = 1,
00538     PRETEND = 2
00539   };
00540 
00541 typedef asection * (*elf_gc_mark_hook_fn)
00542   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
00543    struct elf_link_hash_entry *, Elf_Internal_Sym *);
00544 
00545 struct elf_backend_data
00546 {
00547   /* The architecture for this backend.  */
00548   enum bfd_architecture arch;
00549 
00550   /* The ELF machine code (EM_xxxx) for this backend.  */
00551   int elf_machine_code;
00552 
00553   /* EI_OSABI. */
00554   int elf_osabi;
00555 
00556   /* The maximum page size for this backend.  */
00557   bfd_vma maxpagesize;
00558 
00559   /* The minimum page size for this backend.  An input object will not be
00560      considered page aligned unless its sections are correctly aligned for
00561      pages at least this large.  May be smaller than maxpagesize.  */
00562   bfd_vma minpagesize;
00563 
00564   /* The common page size for this backend.  */
00565   bfd_vma commonpagesize;
00566 
00567   /* The BFD flags applied to sections created for dynamic linking.  */
00568   flagword dynamic_sec_flags;
00569 
00570   /* A function to translate an ELF RELA relocation to a BFD arelent
00571      structure.  */
00572   void (*elf_info_to_howto)
00573     (bfd *, arelent *, Elf_Internal_Rela *);
00574 
00575   /* A function to translate an ELF REL relocation to a BFD arelent
00576      structure.  */
00577   void (*elf_info_to_howto_rel)
00578     (bfd *, arelent *, Elf_Internal_Rela *);
00579 
00580   /* A function to determine whether a symbol is global when
00581      partitioning the symbol table into local and global symbols.
00582      This should be NULL for most targets, in which case the correct
00583      thing will be done.  MIPS ELF, at least on the Irix 5, has
00584      special requirements.  */
00585   bfd_boolean (*elf_backend_sym_is_global)
00586     (bfd *, asymbol *);
00587 
00588   /* The remaining functions are hooks which are called only if they
00589      are not NULL.  */
00590 
00591   /* A function to permit a backend specific check on whether a
00592      particular BFD format is relevant for an object file, and to
00593      permit the backend to set any global information it wishes.  When
00594      this is called elf_elfheader is set, but anything else should be
00595      used with caution.  If this returns FALSE, the check_format
00596      routine will return a bfd_error_wrong_format error.  */
00597   bfd_boolean (*elf_backend_object_p)
00598     (bfd *);
00599 
00600   /* A function to do additional symbol processing when reading the
00601      ELF symbol table.  This is where any processor-specific special
00602      section indices are handled.  */
00603   void (*elf_backend_symbol_processing)
00604     (bfd *, asymbol *);
00605 
00606   /* A function to do additional symbol processing after reading the
00607      entire ELF symbol table.  */
00608   bfd_boolean (*elf_backend_symbol_table_processing)
00609     (bfd *, elf_symbol_type *, unsigned int);
00610 
00611   /* A function to set the type of the info field.  Processor-specific
00612      types should be handled here.  */
00613   int (*elf_backend_get_symbol_type)
00614     (Elf_Internal_Sym *, int);
00615 
00616   /* A function to return the linker hash table entry of a symbol that
00617      might be satisfied by an archive symbol.  */
00618   struct elf_link_hash_entry * (*elf_backend_archive_symbol_lookup)
00619     (bfd *, struct bfd_link_info *, const char *);
00620 
00621   /* Return true if local section symbols should have a non-null st_name.
00622      NULL implies false.  */
00623   bfd_boolean (*elf_backend_name_local_section_symbols)
00624     (bfd *);
00625 
00626   /* A function to do additional processing on the ELF section header
00627      just before writing it out.  This is used to set the flags and
00628      type fields for some sections, or to actually write out data for
00629      unusual sections.  */
00630   bfd_boolean (*elf_backend_section_processing)
00631     (bfd *, Elf_Internal_Shdr *);
00632 
00633   /* A function to handle unusual section types when creating BFD
00634      sections from ELF sections.  */
00635   bfd_boolean (*elf_backend_section_from_shdr)
00636     (bfd *, Elf_Internal_Shdr *, const char *, int);
00637 
00638   /* A function to convert machine dependent ELF section header flags to
00639      BFD internal section header flags.  */
00640   bfd_boolean (*elf_backend_section_flags)
00641     (flagword *, const Elf_Internal_Shdr *);
00642 
00643   /* A function that returns a struct containing ELF section flags and
00644      type for the given BFD section.   */
00645   const struct bfd_elf_special_section * (*get_sec_type_attr)
00646     (bfd *, asection *);
00647 
00648   /* A function to handle unusual program segment types when creating BFD
00649      sections from ELF program segments.  */
00650   bfd_boolean (*elf_backend_section_from_phdr)
00651     (bfd *, Elf_Internal_Phdr *, int, const char *);
00652 
00653   /* A function to set up the ELF section header for a BFD section in
00654      preparation for writing it out.  This is where the flags and type
00655      fields are set for unusual sections.  */
00656   bfd_boolean (*elf_backend_fake_sections)
00657     (bfd *, Elf_Internal_Shdr *, asection *);
00658 
00659   /* A function to get the ELF section index for a BFD section.  If
00660      this returns TRUE, the section was found.  If it is a normal ELF
00661      section, *RETVAL should be left unchanged.  If it is not a normal
00662      ELF section *RETVAL should be set to the SHN_xxxx index.  */
00663   bfd_boolean (*elf_backend_section_from_bfd_section)
00664     (bfd *, asection *, int *retval);
00665 
00666   /* If this field is not NULL, it is called by the add_symbols phase
00667      of a link just before adding a symbol to the global linker hash
00668      table.  It may modify any of the fields as it wishes.  If *NAME
00669      is set to NULL, the symbol will be skipped rather than being
00670      added to the hash table.  This function is responsible for
00671      handling all processor dependent symbol bindings and section
00672      indices, and must set at least *FLAGS and *SEC for each processor
00673      dependent case; failure to do so will cause a link error.  */
00674   bfd_boolean (*elf_add_symbol_hook)
00675     (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *,
00676      const char **name, flagword *flags, asection **sec, bfd_vma *value);
00677 
00678   /* If this field is not NULL, it is called by the elf_link_output_sym
00679      phase of a link for each symbol which will appear in the object file.  */
00680   bfd_boolean (*elf_backend_link_output_symbol_hook)
00681     (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
00682      asection *, struct elf_link_hash_entry *);
00683 
00684   /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
00685      linker the first time it encounters a dynamic object in the link.
00686      This function must create any sections required for dynamic
00687      linking.  The ABFD argument is a dynamic object.  The .interp,
00688      .dynamic, .dynsym, .dynstr, and .hash functions have already been
00689      created, and this function may modify the section flags if
00690      desired.  This function will normally create the .got and .plt
00691      sections, but different backends have different requirements.  */
00692   bfd_boolean (*elf_backend_create_dynamic_sections)
00693     (bfd *abfd, struct bfd_link_info *info);
00694 
00695   /* When creating a shared library, determine whether to omit the
00696      dynamic symbol for the section.  */
00697   bfd_boolean (*elf_backend_omit_section_dynsym)
00698     (bfd *output_bfd, struct bfd_link_info *info, asection *osec);
00699 
00700   /* The CHECK_RELOCS function is called by the add_symbols phase of
00701      the ELF backend linker.  It is called once for each section with
00702      relocs of an object file, just after the symbols for the object
00703      file have been added to the global linker hash table.  The
00704      function must look through the relocs and do any special handling
00705      required.  This generally means allocating space in the global
00706      offset table, and perhaps allocating space for a reloc.  The
00707      relocs are always passed as Rela structures; if the section
00708      actually uses Rel structures, the r_addend field will always be
00709      zero.  */
00710   bfd_boolean (*check_relocs)
00711     (bfd *abfd, struct bfd_link_info *info, asection *o,
00712      const Elf_Internal_Rela *relocs);
00713 
00714   /* The CHECK_DIRECTIVES function is called once per input file by
00715      the add_symbols phase of the ELF backend linker.  The function
00716      must inspect the bfd and create any additional symbols according
00717      to any custom directives in the bfd.  */
00718   bfd_boolean (*check_directives)
00719     (bfd *abfd, struct bfd_link_info *info);
00720 
00721   /* The AS_NEEDED_CLEANUP function is called once per --as-needed
00722      input file that was not needed by the add_symbols phase of the
00723      ELF backend linker.  The function must undo any target specific
00724      changes in the symbol hash table.  */
00725   bfd_boolean (*as_needed_cleanup)
00726     (bfd *abfd, struct bfd_link_info *info);
00727 
00728   /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
00729      linker for every symbol which is defined by a dynamic object and
00730      referenced by a regular object.  This is called after all the
00731      input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
00732      function has been called.  The hash table entry should be
00733      bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
00734      defined in a section from a dynamic object.  Dynamic object
00735      sections are not included in the final link, and this function is
00736      responsible for changing the value to something which the rest of
00737      the link can deal with.  This will normally involve adding an
00738      entry to the .plt or .got or some such section, and setting the
00739      symbol to point to that.  */
00740   bfd_boolean (*elf_backend_adjust_dynamic_symbol)
00741     (struct bfd_link_info *info, struct elf_link_hash_entry *h);
00742 
00743   /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
00744      after all the linker input files have been seen but before the
00745      section sizes have been set.  This is called after
00746      ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS.  */
00747   bfd_boolean (*elf_backend_always_size_sections)
00748     (bfd *output_bfd, struct bfd_link_info *info);
00749 
00750   /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
00751      linker after all the linker input files have been seen but before
00752      the sections sizes have been set.  This is called after
00753      ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
00754      It is only called when linking against a dynamic object.  It must
00755      set the sizes of the dynamic sections, and may fill in their
00756      contents as well.  The generic ELF linker can handle the .dynsym,
00757      .dynstr and .hash sections.  This function must handle the
00758      .interp section and any sections created by the
00759      CREATE_DYNAMIC_SECTIONS entry point.  */
00760   bfd_boolean (*elf_backend_size_dynamic_sections)
00761     (bfd *output_bfd, struct bfd_link_info *info);
00762 
00763   /* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
00764      we keep to use as a base for relocs and symbols.  */
00765   void (*elf_backend_init_index_section)
00766     (bfd *output_bfd, struct bfd_link_info *info);
00767 
00768   /* The RELOCATE_SECTION function is called by the ELF backend linker
00769      to handle the relocations for a section.
00770 
00771      The relocs are always passed as Rela structures; if the section
00772      actually uses Rel structures, the r_addend field will always be
00773      zero.
00774 
00775      This function is responsible for adjust the section contents as
00776      necessary, and (if using Rela relocs and generating a
00777      relocatable output file) adjusting the reloc addend as
00778      necessary.
00779 
00780      This function does not have to worry about setting the reloc
00781      address or the reloc symbol index.
00782 
00783      LOCAL_SYMS is a pointer to the swapped in local symbols.
00784 
00785      LOCAL_SECTIONS is an array giving the section in the input file
00786      corresponding to the st_shndx field of each local symbol.
00787 
00788      The global hash table entry for the global symbols can be found
00789      via elf_sym_hashes (input_bfd).
00790 
00791      When generating relocatable output, this function must handle
00792      STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
00793      going to be the section symbol corresponding to the output
00794      section, which means that the addend must be adjusted
00795      accordingly.  */
00796   bfd_boolean (*elf_backend_relocate_section)
00797     (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd,
00798      asection *input_section, bfd_byte *contents, Elf_Internal_Rela *relocs,
00799      Elf_Internal_Sym *local_syms, asection **local_sections);
00800 
00801   /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
00802      linker just before it writes a symbol out to the .dynsym section.
00803      The processor backend may make any required adjustment to the
00804      symbol.  It may also take the opportunity to set contents of the
00805      dynamic sections.  Note that FINISH_DYNAMIC_SYMBOL is called on
00806      all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
00807      on those symbols which are defined by a dynamic object.  */
00808   bfd_boolean (*elf_backend_finish_dynamic_symbol)
00809     (bfd *output_bfd, struct bfd_link_info *info,
00810      struct elf_link_hash_entry *h, Elf_Internal_Sym *sym);
00811 
00812   /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
00813      linker just before it writes all the dynamic sections out to the
00814      output file.  The FINISH_DYNAMIC_SYMBOL will have been called on
00815      all dynamic symbols.  */
00816   bfd_boolean (*elf_backend_finish_dynamic_sections)
00817     (bfd *output_bfd, struct bfd_link_info *info);
00818 
00819   /* A function to do any beginning processing needed for the ELF file
00820      before building the ELF headers and computing file positions.  */
00821   void (*elf_backend_begin_write_processing)
00822     (bfd *, struct bfd_link_info *);
00823 
00824   /* A function to do any final processing needed for the ELF file
00825      before writing it out.  The LINKER argument is TRUE if this BFD
00826      was created by the ELF backend linker.  */
00827   void (*elf_backend_final_write_processing)
00828     (bfd *, bfd_boolean linker);
00829 
00830   /* This function is called by get_program_header_size.  It should
00831      return the number of additional program segments which this BFD
00832      will need.  It should return -1 on error.  */
00833   int (*elf_backend_additional_program_headers)
00834     (bfd *, struct bfd_link_info *);
00835 
00836   /* This function is called to modify an existing segment map in a
00837      backend specific fashion.  */
00838   bfd_boolean (*elf_backend_modify_segment_map)
00839     (bfd *, struct bfd_link_info *);
00840 
00841   /* This function is called to modify program headers just before
00842      they are written.  */
00843   bfd_boolean (*elf_backend_modify_program_headers)
00844     (bfd *, struct bfd_link_info *);
00845 
00846   /* This function is called during section garbage collection to
00847      mark sections that define global symbols.  */
00848   bfd_boolean (*gc_mark_dynamic_ref)
00849     (struct elf_link_hash_entry *h, void *inf);
00850 
00851   /* This function is called during section gc to discover the section a
00852      particular relocation refers to.  */
00853   elf_gc_mark_hook_fn gc_mark_hook;
00854 
00855   /* This function, if defined, is called after the first gc marking pass
00856      to allow the backend to mark additional sections.  */
00857   bfd_boolean (*gc_mark_extra_sections)
00858     (struct bfd_link_info *info, elf_gc_mark_hook_fn gc_mark_hook);
00859 
00860   /* This function, if defined, is called during the sweep phase of gc
00861      in order that a backend might update any data structures it might
00862      be maintaining.  */
00863   bfd_boolean (*gc_sweep_hook)
00864     (bfd *abfd, struct bfd_link_info *info, asection *o,
00865      const Elf_Internal_Rela *relocs);
00866 
00867   /* This function, if defined, is called after the ELF headers have
00868      been created.  This allows for things like the OS and ABI versions
00869      to be changed.  */
00870   void (*elf_backend_post_process_headers)
00871     (bfd *, struct bfd_link_info *);
00872 
00873   /* This function, if defined, prints a symbol to file and returns the
00874      name of the symbol to be printed.  It should return NULL to fall
00875      back to default symbol printing.  */
00876   const char *(*elf_backend_print_symbol_all)
00877     (bfd *, void *, asymbol *);
00878 
00879   /* This function, if defined, is called after all local symbols and
00880      global symbols converted to locals are emitted into the symtab
00881      section.  It allows the backend to emit special local symbols
00882      not handled in the hash table.  */
00883   bfd_boolean (*elf_backend_output_arch_local_syms)
00884     (bfd *, struct bfd_link_info *, void *,
00885      bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
00886                     struct elf_link_hash_entry *));
00887 
00888   /* This function, if defined, is called after all symbols are emitted
00889      into the symtab section.  It allows the backend to emit special
00890      global symbols not handled in the hash table.  */
00891   bfd_boolean (*elf_backend_output_arch_syms)
00892     (bfd *, struct bfd_link_info *, void *,
00893      bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
00894                     struct elf_link_hash_entry *));
00895 
00896   /* Copy any information related to dynamic linking from a pre-existing
00897      symbol to a newly created symbol.  Also called to copy flags and
00898      other back-end info to a weakdef, in which case the symbol is not
00899      newly created and plt/got refcounts and dynamic indices should not
00900      be copied.  */
00901   void (*elf_backend_copy_indirect_symbol)
00902     (struct bfd_link_info *, struct elf_link_hash_entry *,
00903      struct elf_link_hash_entry *);
00904 
00905   /* Modify any information related to dynamic linking such that the
00906      symbol is not exported.  */
00907   void (*elf_backend_hide_symbol)
00908     (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
00909 
00910   /* A function to do additional symbol fixup, called by
00911      _bfd_elf_fix_symbol_flags.  */
00912   bfd_boolean (*elf_backend_fixup_symbol)
00913     (struct bfd_link_info *, struct elf_link_hash_entry *);
00914 
00915   /* Merge the backend specific symbol attribute.  */
00916   void (*elf_backend_merge_symbol_attribute)
00917     (struct elf_link_hash_entry *, const Elf_Internal_Sym *, bfd_boolean,
00918      bfd_boolean);
00919 
00920   /* Decide whether an undefined symbol is special and can be ignored.
00921      This is the case for OPTIONAL symbols on IRIX.  */
00922   bfd_boolean (*elf_backend_ignore_undef_symbol)
00923     (struct elf_link_hash_entry *);
00924 
00925   /* Emit relocations.  Overrides default routine for emitting relocs,
00926      except during a relocatable link, or if all relocs are being emitted.  */
00927   bfd_boolean (*elf_backend_emit_relocs)
00928     (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
00929      struct elf_link_hash_entry **);
00930 
00931   /* Count relocations.  Not called for relocatable links
00932      or if all relocs are being preserved in the output.  */
00933   unsigned int (*elf_backend_count_relocs)
00934     (asection *, Elf_Internal_Rela *);
00935 
00936   /* This function, if defined, is called when an NT_PRSTATUS note is found
00937      in a core file.  */
00938   bfd_boolean (*elf_backend_grok_prstatus)
00939     (bfd *, Elf_Internal_Note *);
00940 
00941   /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
00942      note is found in a core file.  */
00943   bfd_boolean (*elf_backend_grok_psinfo)
00944     (bfd *, Elf_Internal_Note *);
00945 
00946   /* This function, if defined, is called to write a note to a corefile.  */
00947   char *(*elf_backend_write_core_note)
00948     (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
00949 
00950   /* Functions to print VMAs.  Special code to handle 64 bit ELF files.  */
00951   void (* elf_backend_sprintf_vma)
00952     (bfd *, char *, bfd_vma);
00953   void (* elf_backend_fprintf_vma)
00954     (bfd *, void *, bfd_vma);
00955 
00956   /* This function returns class of a reloc type.  */
00957   enum elf_reloc_type_class (*elf_backend_reloc_type_class)
00958     (const Elf_Internal_Rela *);
00959 
00960   /* This function, if defined, removes information about discarded functions
00961      from other sections which mention them.  */
00962   bfd_boolean (*elf_backend_discard_info)
00963     (bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
00964 
00965   /* This function, if defined, signals that the function above has removed
00966      the discarded relocations for this section.  */
00967   bfd_boolean (*elf_backend_ignore_discarded_relocs)
00968     (asection *);
00969 
00970   /* What to do when ld finds relocations against symbols defined in
00971      discarded sections.  */
00972   unsigned int (*action_discarded)
00973     (asection *);
00974 
00975   /* This function returns the width of FDE pointers in bytes, or 0 if
00976      that can't be determined for some reason.  The default definition
00977      goes by the bfd's EI_CLASS.  */
00978   unsigned int (*elf_backend_eh_frame_address_size)
00979     (bfd *, asection *);
00980 
00981   /* These functions tell elf-eh-frame whether to attempt to turn
00982      absolute or lsda encodings into pc-relative ones.  The default
00983      definition enables these transformations.  */
00984   bfd_boolean (*elf_backend_can_make_relative_eh_frame)
00985      (bfd *, struct bfd_link_info *, asection *);
00986   bfd_boolean (*elf_backend_can_make_lsda_relative_eh_frame)
00987      (bfd *, struct bfd_link_info *, asection *);
00988 
00989   /* This function returns an encoding after computing the encoded
00990      value (and storing it in ENCODED) for the given OFFSET into OSEC,
00991      to be stored in at LOC_OFFSET into the LOC_SEC input section.
00992      The default definition chooses a 32-bit PC-relative encoding.  */
00993   bfd_byte (*elf_backend_encode_eh_address)
00994      (bfd *abfd, struct bfd_link_info *info,
00995       asection *osec, bfd_vma offset,
00996       asection *loc_sec, bfd_vma loc_offset,
00997       bfd_vma *encoded);
00998 
00999   /* This function, if defined, may write out the given section.
01000      Returns TRUE if it did so and FALSE if the caller should.  */
01001   bfd_boolean (*elf_backend_write_section)
01002     (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
01003 
01004   /* The level of IRIX compatibility we're striving for.
01005      MIPS ELF specific function.  */
01006   irix_compat_t (*elf_backend_mips_irix_compat)
01007     (bfd *);
01008 
01009   reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
01010     (unsigned int, bfd_boolean);
01011 
01012   /* The swapping table to use when dealing with ECOFF information.
01013      Used for the MIPS ELF .mdebug section.  */
01014   const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
01015 
01016   /* This function implements `bfd_elf_bfd_from_remote_memory';
01017      see elf.c, elfcode.h.  */
01018   bfd *(*elf_backend_bfd_from_remote_memory)
01019      (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
01020       int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
01021 
01022   /* This function is used by `_bfd_elf_get_synthetic_symtab';
01023      see elf.c.  */
01024   bfd_vma (*plt_sym_val) (bfd_vma, const asection *, const arelent *);
01025 
01026   /* Is symbol defined in common section?  */
01027   bfd_boolean (*common_definition) (Elf_Internal_Sym *);
01028 
01029   /* Return a common section index for section.  */
01030   unsigned int (*common_section_index) (asection *);
01031 
01032   /* Return a common section for section.  */
01033   asection *(*common_section) (asection *);
01034 
01035   /* Return TRUE if we can merge 2 definitions.  */
01036   bfd_boolean (*merge_symbol) (struct bfd_link_info *,
01037                             struct elf_link_hash_entry **,
01038                             struct elf_link_hash_entry *,
01039                             Elf_Internal_Sym *, asection **,
01040                             bfd_vma *, unsigned int *,
01041                             bfd_boolean *, bfd_boolean *,
01042                             bfd_boolean *, bfd_boolean *,
01043                             bfd_boolean *, bfd_boolean *,
01044                             bfd_boolean *, bfd_boolean *,
01045                             bfd *, asection **,
01046                             bfd_boolean *, bfd_boolean *,
01047                             bfd_boolean *, bfd_boolean *,
01048                             bfd *, asection **);
01049 
01050   /* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
01051   bfd_boolean (*elf_hash_symbol) (struct elf_link_hash_entry *);
01052 
01053   /* Used to handle bad SHF_LINK_ORDER input.  */
01054   bfd_error_handler_type link_order_error_handler;
01055 
01056   /* Name of the PLT relocation section.  */
01057   const char *relplt_name;
01058 
01059   /* Alternate EM_xxxx machine codes for this backend.  */
01060   int elf_machine_alt1;
01061   int elf_machine_alt2;
01062 
01063   const struct elf_size_info *s;
01064 
01065   /* An array of target specific special sections.  */
01066   const struct bfd_elf_special_section *special_sections;
01067 
01068   /* The size in bytes of the header for the GOT.  This includes the
01069      so-called reserved entries on some systems.  */
01070   bfd_vma got_header_size;
01071 
01072   /* This is TRUE if the linker should act like collect and gather
01073      global constructors and destructors by name.  This is TRUE for
01074      MIPS ELF because the Irix 5 tools can not handle the .init
01075      section.  */
01076   unsigned collect : 1;
01077 
01078   /* This is TRUE if the linker should ignore changes to the type of a
01079      symbol.  This is TRUE for MIPS ELF because some Irix 5 objects
01080      record undefined functions as STT_OBJECT although the definitions
01081      are STT_FUNC.  */
01082   unsigned type_change_ok : 1;
01083 
01084   /* Whether the backend may use REL relocations.  (Some backends use
01085      both REL and RELA relocations, and this flag is set for those
01086      backends.)  */
01087   unsigned may_use_rel_p : 1;
01088 
01089   /* Whether the backend may use RELA relocations.  (Some backends use
01090      both REL and RELA relocations, and this flag is set for those
01091      backends.)  */
01092   unsigned may_use_rela_p : 1;
01093 
01094   /* Whether the default relocation type is RELA.  If a backend with
01095      this flag set wants REL relocations for a particular section,
01096      it must note that explicitly.  Similarly, if this flag is clear,
01097      and the backend wants RELA relocations for a particular
01098      section.  */
01099   unsigned default_use_rela_p : 1;
01100 
01101   /* Set if RELA relocations for a relocatable link can be handled by
01102      generic code.  Backends that set this flag need do nothing in the
01103      backend relocate_section routine for relocatable linking.  */
01104   unsigned rela_normal : 1;
01105 
01106   /* TRUE if addresses "naturally" sign extend.  This is used when
01107      swapping in from Elf32 when BFD64.  */
01108   unsigned sign_extend_vma : 1;
01109 
01110   unsigned want_got_plt : 1;
01111   unsigned plt_readonly : 1;
01112   unsigned want_plt_sym : 1;
01113   unsigned plt_not_loaded : 1;
01114   unsigned plt_alignment : 4;
01115   unsigned can_gc_sections : 1;
01116   unsigned can_refcount : 1;
01117   unsigned want_got_sym : 1;
01118   unsigned want_dynbss : 1;
01119 
01120   /* Targets which do not support physical addressing often require
01121      that the p_paddr field in the section header to be set to zero.
01122      This field indicates whether this behavior is required.  */
01123   unsigned want_p_paddr_set_to_zero : 1;
01124 
01125   /* True if an object file lacking a .note.GNU-stack section
01126      should be assumed to be requesting exec stack.  At least one
01127      other file in the link needs to have a .note.GNU-stack section
01128      for a PT_GNU_STACK segment to be created.  */
01129   unsigned default_execstack : 1;
01130 };
01131 
01132 /* Information stored for each BFD section in an ELF file.  This
01133    structure is allocated by elf_new_section_hook.  */
01134 
01135 struct bfd_elf_section_data
01136 {
01137   /* The ELF header for this section.  */
01138   Elf_Internal_Shdr this_hdr;
01139 
01140   /* The ELF header for the reloc section associated with this
01141      section, if any.  */
01142   Elf_Internal_Shdr rel_hdr;
01143 
01144   /* If there is a second reloc section associated with this section,
01145      as can happen on Irix 6, this field points to the header.  */
01146   Elf_Internal_Shdr *rel_hdr2;
01147 
01148   /* The number of relocations currently assigned to REL_HDR.  */
01149   unsigned int rel_count;
01150 
01151   /* The number of relocations currently assigned to REL_HDR2.  */
01152   unsigned int rel_count2;
01153 
01154   /* The ELF section number of this section.  */
01155   int this_idx;
01156 
01157   /* The ELF section number of the reloc section indicated by
01158      REL_HDR if any.  Only used for an output file.  */
01159   int rel_idx;
01160 
01161   /* The ELF section number of the reloc section indicated by
01162      REL_HDR2 if any.  Only used for an output file.  */
01163   int rel_idx2;
01164 
01165   /* Used by the backend linker when generating a shared library to
01166      record the dynamic symbol index for a section symbol
01167      corresponding to this section.  A value of 0 means that there is
01168      no dynamic symbol for this section.  */
01169   int dynindx;
01170 
01171   /* A pointer to the linked-to section for SHF_LINK_ORDER.  */
01172   asection *linked_to;
01173 
01174   /* Used by the backend linker to store the symbol hash table entries
01175      associated with relocs against global symbols.  */
01176   struct elf_link_hash_entry **rel_hashes;
01177 
01178   /* A pointer to the swapped relocs.  If the section uses REL relocs,
01179      rather than RELA, all the r_addend fields will be zero.  This
01180      pointer may be NULL.  It is used by the backend linker.  */
01181   Elf_Internal_Rela *relocs;
01182 
01183   /* A pointer to a linked list tracking dynamic relocs copied for
01184      local symbols.  */
01185   void *local_dynrel;
01186 
01187   /* A pointer to the bfd section used for dynamic relocs.  */
01188   asection *sreloc;
01189 
01190   union {
01191     /* Group name, if this section is a member of a group.  */
01192     const char *name;
01193 
01194     /* Group signature sym, if this is the SHT_GROUP section.  */
01195     struct bfd_symbol *id;
01196   } group;
01197 
01198   /* For a member of a group, points to the SHT_GROUP section.
01199      NULL for the SHT_GROUP section itself and non-group sections.  */
01200   asection *sec_group;
01201 
01202   /* A linked list of member sections in the group.  Circular when used by
01203      the linker.  For the SHT_GROUP section, points at first member.  */
01204   asection *next_in_group;
01205 
01206   /* A pointer used for various section optimizations.  */
01207   void *sec_info;
01208 };
01209 
01210 #define elf_section_data(sec)  ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
01211 #define elf_linked_to_section(sec) (elf_section_data(sec)->linked_to)
01212 #define elf_section_type(sec)  (elf_section_data(sec)->this_hdr.sh_type)
01213 #define elf_section_flags(sec) (elf_section_data(sec)->this_hdr.sh_flags)
01214 #define elf_group_name(sec)    (elf_section_data(sec)->group.name)
01215 #define elf_group_id(sec)      (elf_section_data(sec)->group.id)
01216 #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
01217 #define elf_sec_group(sec)  (elf_section_data(sec)->sec_group)
01218 
01219 #define xvec_get_elf_backend_data(xvec) \
01220   ((struct elf_backend_data *) (xvec)->backend_data)
01221 
01222 #define get_elf_backend_data(abfd) \
01223    xvec_get_elf_backend_data ((abfd)->xvec)
01224 
01225 /* This struct is used to pass information to routines called via
01226    elf_link_hash_traverse which must return failure.  */
01227 
01228 struct elf_info_failed
01229 {
01230   bfd_boolean failed;
01231   struct bfd_link_info *info;
01232   struct bfd_elf_version_tree *verdefs;
01233 };
01234 
01235 /* This structure is used to pass information to
01236    _bfd_elf_link_assign_sym_version.  */
01237 
01238 struct elf_assign_sym_version_info
01239 {
01240   /* Output BFD.  */
01241   bfd *output_bfd;
01242   /* General link information.  */
01243   struct bfd_link_info *info;
01244   /* Version tree.  */
01245   struct bfd_elf_version_tree *verdefs;
01246   /* Whether we had a failure.  */
01247   bfd_boolean failed;
01248 };
01249 
01250 /* This structure is used to pass information to
01251    _bfd_elf_link_find_version_dependencies.  */
01252 
01253 struct elf_find_verdep_info
01254 {
01255   /* Output BFD.  */
01256   bfd *output_bfd;
01257   /* General link information.  */
01258   struct bfd_link_info *info;
01259   /* The number of dependencies.  */
01260   unsigned int vers;
01261   /* Whether we had a failure.  */
01262   bfd_boolean failed;
01263 };
01264 
01265 /* Some private data is stashed away for future use using the tdata pointer
01266    in the bfd structure.  */
01267 
01268 struct elf_obj_tdata
01269 {
01270   Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
01271   Elf_Internal_Shdr **elf_sect_ptr;
01272   Elf_Internal_Phdr *phdr;
01273   struct elf_segment_map *segment_map;
01274   struct elf_strtab_hash *strtab_ptr;
01275   int num_locals;
01276   int num_globals;
01277   unsigned int num_elf_sections;   /* elf_sect_ptr size */
01278   int num_section_syms;
01279   asymbol **section_syms;          /* STT_SECTION symbols for each section */
01280   Elf_Internal_Shdr symtab_hdr;
01281   Elf_Internal_Shdr shstrtab_hdr;
01282   Elf_Internal_Shdr strtab_hdr;
01283   Elf_Internal_Shdr dynsymtab_hdr;
01284   Elf_Internal_Shdr dynstrtab_hdr;
01285   Elf_Internal_Shdr dynversym_hdr;
01286   Elf_Internal_Shdr dynverref_hdr;
01287   Elf_Internal_Shdr dynverdef_hdr;
01288   Elf_Internal_Shdr symtab_shndx_hdr;
01289   unsigned int symtab_section, shstrtab_section;
01290   unsigned int strtab_section, dynsymtab_section;
01291   unsigned int symtab_shndx_section;
01292   unsigned int dynversym_section, dynverdef_section, dynverref_section;
01293   file_ptr next_file_pos;
01294   bfd_vma gp;                      /* The gp value */
01295   unsigned int gp_size;                   /* The gp size */
01296 
01297   /* Information grabbed from an elf core file.  */
01298   int core_signal;
01299   int core_pid;
01300   int core_lwpid;
01301   char* core_program;
01302   char* core_command;
01303 
01304   /* A mapping from external symbols to entries in the linker hash
01305      table, used when linking.  This is indexed by the symbol index
01306      minus the sh_info field of the symbol table header.  */
01307   struct elf_link_hash_entry **sym_hashes;
01308 
01309   /* Track usage and final offsets of GOT entries for local symbols.
01310      This array is indexed by symbol index.  Elements are used
01311      identically to "got" in struct elf_link_hash_entry.  */
01312   union
01313     {
01314       bfd_signed_vma *refcounts;
01315       bfd_vma *offsets;
01316       struct got_entry **ents;
01317     } local_got;
01318 
01319   /* The linker ELF emulation code needs to let the backend ELF linker
01320      know what filename should be used for a dynamic object if the
01321      dynamic object is found using a search.  The emulation code then
01322      sometimes needs to know what name was actually used.  Until the
01323      file has been added to the linker symbol table, this field holds
01324      the name the linker wants.  After it has been added, it holds the
01325      name actually used, which will be the DT_SONAME entry if there is
01326      one.  */
01327   const char *dt_name;
01328 
01329   /* Records the result of `get_program_header_size'.  */
01330   bfd_size_type program_header_size;
01331 
01332   /* Used by find_nearest_line entry point.  */
01333   void *line_info;
01334 
01335   /* Used by MIPS ELF find_nearest_line entry point.  The structure
01336      could be included directly in this one, but there's no point to
01337      wasting the memory just for the infrequently called
01338      find_nearest_line.  */
01339   struct mips_elf_find_line *find_line_info;
01340 
01341   /* A place to stash dwarf1 info for this bfd.  */
01342   struct dwarf1_debug *dwarf1_find_line_info;
01343 
01344   /* A place to stash dwarf2 info for this bfd.  */
01345   void *dwarf2_find_line_info;
01346 
01347   /* An array of stub sections indexed by symbol number, used by the
01348      MIPS ELF linker.  FIXME: We should figure out some way to only
01349      include this field for a MIPS ELF target.  */
01350   asection **local_stubs;
01351   asection **local_call_stubs;
01352 
01353   /* Used to determine if PT_GNU_EH_FRAME segment header should be
01354      created.  */
01355   asection *eh_frame_hdr;
01356 
01357   Elf_Internal_Shdr **group_sect_ptr;
01358   int num_group;
01359 
01360   /* Number of symbol version definitions we are about to emit.  */
01361   unsigned int cverdefs;
01362 
01363   /* Number of symbol version references we are about to emit.  */
01364   unsigned int cverrefs;
01365 
01366   /* Segment flags for the PT_GNU_STACK segment.  */
01367   unsigned int stack_flags;
01368 
01369   /* Should the PT_GNU_RELRO segment be emitted?  */
01370   bfd_boolean relro;
01371 
01372   /* Symbol version definitions in external objects.  */
01373   Elf_Internal_Verdef *verdef;
01374 
01375   /* Symbol version references to external objects.  */
01376   Elf_Internal_Verneed *verref;
01377 
01378   /* The Irix 5 support uses two virtual sections, which represent
01379      text/data symbols defined in dynamic objects.  */
01380   asymbol *elf_data_symbol;
01381   asymbol *elf_text_symbol;
01382   asection *elf_data_section;
01383   asection *elf_text_section;
01384 
01385   /* Whether a dyanmic object was specified normally on the linker
01386      command line, or was specified when --as-needed was in effect,
01387      or was found via a DT_NEEDED entry.  */
01388   enum dynamic_lib_link_class dyn_lib_class;
01389 
01390   /* This is set to TRUE if the object was created by the backend
01391      linker.  */
01392   bfd_boolean linker;
01393 
01394   /* Irix 5 often screws up the symbol table, sorting local symbols
01395      after global symbols.  This flag is set if the symbol table in
01396      this BFD appears to be screwed up.  If it is, we ignore the
01397      sh_info field in the symbol table header, and always read all the
01398      symbols.  */
01399   bfd_boolean bad_symtab;
01400 
01401   /* Used to determine if the e_flags field has been initialized */
01402   bfd_boolean flags_init;
01403 
01404   /* Symbol buffer.  */
01405   void *symbuf;
01406 };
01407 
01408 #define elf_tdata(bfd)             ((bfd) -> tdata.elf_obj_data)
01409 #define elf_elfheader(bfd)  (elf_tdata(bfd) -> elf_header)
01410 #define elf_elfsections(bfd)       (elf_tdata(bfd) -> elf_sect_ptr)
01411 #define elf_numsections(bfd)       (elf_tdata(bfd) -> num_elf_sections)
01412 #define elf_shstrtab(bfd)   (elf_tdata(bfd) -> strtab_ptr)
01413 #define elf_onesymtab(bfd)  (elf_tdata(bfd) -> symtab_section)
01414 #define elf_symtab_shndx(bfd)      (elf_tdata(bfd) -> symtab_shndx_section)
01415 #define elf_dynsymtab(bfd)  (elf_tdata(bfd) -> dynsymtab_section)
01416 #define elf_dynversym(bfd)  (elf_tdata(bfd) -> dynversym_section)
01417 #define elf_dynverdef(bfd)  (elf_tdata(bfd) -> dynverdef_section)
01418 #define elf_dynverref(bfd)  (elf_tdata(bfd) -> dynverref_section)
01419 #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
01420 #define elf_num_globals(bfd)       (elf_tdata(bfd) -> num_globals)
01421 #define elf_section_syms(bfd)      (elf_tdata(bfd) -> section_syms)
01422 #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
01423 #define core_prpsinfo(bfd)  (elf_tdata(bfd) -> prpsinfo)
01424 #define core_prstatus(bfd)  (elf_tdata(bfd) -> prstatus)
01425 #define elf_gp(bfd)         (elf_tdata(bfd) -> gp)
01426 #define elf_gp_size(bfd)    (elf_tdata(bfd) -> gp_size)
01427 #define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
01428 #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
01429 #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
01430 #define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
01431 #define elf_dt_name(bfd)    (elf_tdata(bfd) -> dt_name)
01432 #define elf_dyn_lib_class(bfd)     (elf_tdata(bfd) -> dyn_lib_class)
01433 #define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
01434 #define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
01435 
01436 extern void _bfd_elf_swap_verdef_in
01437   (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *);
01438 extern void _bfd_elf_swap_verdef_out
01439   (bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *);
01440 extern void _bfd_elf_swap_verdaux_in
01441   (bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *);
01442 extern void _bfd_elf_swap_verdaux_out
01443   (bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *);
01444 extern void _bfd_elf_swap_verneed_in
01445   (bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *);
01446 extern void _bfd_elf_swap_verneed_out
01447   (bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *);
01448 extern void _bfd_elf_swap_vernaux_in
01449   (bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *);
01450 extern void _bfd_elf_swap_vernaux_out
01451   (bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *);
01452 extern void _bfd_elf_swap_versym_in
01453   (bfd *, const Elf_External_Versym *, Elf_Internal_Versym *);
01454 extern void _bfd_elf_swap_versym_out
01455   (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *);
01456 
01457 extern int _bfd_elf_section_from_bfd_section
01458   (bfd *, asection *);
01459 extern char *bfd_elf_string_from_elf_section
01460   (bfd *, unsigned, unsigned);
01461 extern char *bfd_elf_get_str_section
01462   (bfd *, unsigned);
01463 extern Elf_Internal_Sym *bfd_elf_get_elf_syms
01464   (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
01465    Elf_External_Sym_Shndx *);
01466 extern const char *bfd_elf_sym_name
01467   (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *);
01468 
01469 extern bfd_boolean _bfd_elf_copy_private_bfd_data
01470   (bfd *, bfd *);
01471 extern bfd_boolean _bfd_elf_print_private_bfd_data
01472   (bfd *, void *);
01473 extern void bfd_elf_print_symbol
01474   (bfd *, void *, asymbol *, bfd_print_symbol_type);
01475 
01476 extern void _bfd_elf_sprintf_vma
01477   (bfd *, char *, bfd_vma);
01478 extern void _bfd_elf_fprintf_vma
01479   (bfd *, void *, bfd_vma);
01480 
01481 extern unsigned int _bfd_elf_eh_frame_address_size
01482   (bfd *, asection *);
01483 extern bfd_byte _bfd_elf_encode_eh_address
01484   (bfd *abfd, struct bfd_link_info *info, asection *osec, bfd_vma offset,
01485    asection *loc_sec, bfd_vma loc_offset, bfd_vma *encoded);
01486 extern bfd_boolean _bfd_elf_can_make_relative
01487   (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
01488 
01489 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
01490   (const Elf_Internal_Rela *);
01491 extern bfd_vma _bfd_elf_rela_local_sym
01492   (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
01493 extern bfd_vma _bfd_elf_rel_local_sym
01494   (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
01495 extern bfd_vma _bfd_elf_section_offset
01496   (bfd *, struct bfd_link_info *, asection *, bfd_vma);
01497 
01498 extern unsigned long bfd_elf_hash
01499   (const char *);
01500 extern unsigned long bfd_elf_gnu_hash
01501   (const char *);
01502 
01503 extern bfd_reloc_status_type bfd_elf_generic_reloc
01504   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
01505 extern bfd_boolean bfd_elf_mkobject
01506   (bfd *);
01507 extern bfd_boolean bfd_elf_mkcorefile
01508   (bfd *);
01509 extern Elf_Internal_Shdr *bfd_elf_find_section
01510   (bfd *, char *);
01511 extern bfd_boolean _bfd_elf_make_section_from_shdr
01512   (bfd *, Elf_Internal_Shdr *, const char *, int);
01513 extern bfd_boolean _bfd_elf_make_section_from_phdr
01514   (bfd *, Elf_Internal_Phdr *, int, const char *);
01515 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
01516   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
01517 extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
01518   (bfd *);
01519 extern void _bfd_elf_link_hash_copy_indirect
01520   (struct bfd_link_info *, struct elf_link_hash_entry *,
01521    struct elf_link_hash_entry *);
01522 extern void _bfd_elf_link_hash_hide_symbol
01523   (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
01524 extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
01525   (struct bfd_link_info *, struct elf_link_hash_entry *);
01526 extern bfd_boolean _bfd_elf_link_hash_table_init
01527   (struct elf_link_hash_table *, bfd *,
01528    struct bfd_hash_entry *(*)
01529      (struct bfd_hash_entry *, struct bfd_hash_table *, const char *),
01530    unsigned int);
01531 extern bfd_boolean _bfd_elf_slurp_version_tables
01532   (bfd *, bfd_boolean);
01533 extern bfd_boolean _bfd_elf_merge_sections
01534   (bfd *, struct bfd_link_info *);
01535 extern bfd_boolean _bfd_elf_match_sections_by_type
01536   (bfd *, const asection *, bfd *, const asection *);
01537 extern bfd_boolean bfd_elf_is_group_section
01538   (bfd *, const struct bfd_section *);
01539 extern void _bfd_elf_section_already_linked
01540   (bfd *, struct bfd_section *, struct bfd_link_info *);
01541 extern void bfd_elf_set_group_contents
01542   (bfd *, asection *, void *);
01543 extern asection *_bfd_elf_check_kept_section
01544   (asection *, struct bfd_link_info *);
01545 extern void _bfd_elf_link_just_syms
01546   (asection *, struct bfd_link_info *);
01547 extern bfd_boolean _bfd_elf_copy_private_header_data
01548   (bfd *, bfd *);
01549 extern bfd_boolean _bfd_elf_copy_private_symbol_data
01550   (bfd *, asymbol *, bfd *, asymbol *);
01551 #define _bfd_generic_init_private_section_data \
01552   _bfd_elf_init_private_section_data
01553 extern bfd_boolean _bfd_elf_init_private_section_data
01554   (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
01555 extern bfd_boolean _bfd_elf_copy_private_section_data
01556   (bfd *, asection *, bfd *, asection *);
01557 extern bfd_boolean _bfd_elf_write_object_contents
01558   (bfd *);
01559 extern bfd_boolean _bfd_elf_write_corefile_contents
01560   (bfd *);
01561 extern bfd_boolean _bfd_elf_set_section_contents
01562   (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
01563 extern long _bfd_elf_get_symtab_upper_bound
01564   (bfd *);
01565 extern long _bfd_elf_canonicalize_symtab
01566   (bfd *, asymbol **);
01567 extern long _bfd_elf_get_dynamic_symtab_upper_bound
01568   (bfd *);
01569 extern long _bfd_elf_canonicalize_dynamic_symtab
01570   (bfd *, asymbol **);
01571 extern long _bfd_elf_get_synthetic_symtab
01572   (bfd *, long, asymbol **, long, asymbol **, asymbol **);
01573 extern long _bfd_elf_get_reloc_upper_bound
01574   (bfd *, sec_ptr);
01575 extern long _bfd_elf_canonicalize_reloc
01576   (bfd *, sec_ptr, arelent **, asymbol **);
01577 extern long _bfd_elf_get_dynamic_reloc_upper_bound
01578   (bfd *);
01579 extern long _bfd_elf_canonicalize_dynamic_reloc
01580   (bfd *, arelent **, asymbol **);
01581 extern asymbol *_bfd_elf_make_empty_symbol
01582   (bfd *);
01583 extern void _bfd_elf_get_symbol_info
01584   (bfd *, asymbol *, symbol_info *);
01585 extern bfd_boolean _bfd_elf_is_local_label_name
01586   (bfd *, const char *);
01587 extern alent *_bfd_elf_get_lineno
01588   (bfd *, asymbol *);
01589 extern bfd_boolean _bfd_elf_set_arch_mach
01590   (bfd *, enum bfd_architecture, unsigned long);
01591 extern bfd_boolean _bfd_elf_find_nearest_line
01592   (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **,
01593    unsigned int *);
01594 extern bfd_boolean _bfd_elf_find_line
01595   (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
01596 #define _bfd_generic_find_line _bfd_elf_find_line
01597 extern bfd_boolean _bfd_elf_find_inliner_info
01598   (bfd *, const char **, const char **, unsigned int *);
01599 #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
01600 #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
01601 extern int _bfd_elf_sizeof_headers
01602   (bfd *, struct bfd_link_info *);
01603 extern bfd_boolean _bfd_elf_new_section_hook
01604   (bfd *, asection *);
01605 extern bfd_boolean _bfd_elf_init_reloc_shdr
01606   (bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean);
01607 extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
01608   (const char *, const struct bfd_elf_special_section *, unsigned int);
01609 extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
01610   (bfd *, asection *);
01611 
01612 /* If the target doesn't have reloc handling written yet:  */
01613 extern void _bfd_elf_no_info_to_howto
01614   (bfd *, arelent *, Elf_Internal_Rela *);
01615 
01616 extern bfd_boolean bfd_section_from_shdr
01617   (bfd *, unsigned int shindex);
01618 extern bfd_boolean bfd_section_from_phdr
01619   (bfd *, Elf_Internal_Phdr *, int);
01620 
01621 extern int _bfd_elf_symbol_from_bfd_symbol
01622   (bfd *, asymbol **);
01623 
01624 extern asection *bfd_section_from_r_symndx
01625   (bfd *, struct sym_sec_cache *, asection *, unsigned long);
01626 extern asection *bfd_section_from_elf_index
01627   (bfd *, unsigned int);
01628 extern struct bfd_strtab_hash *_bfd_elf_stringtab_init
01629   (void);
01630 
01631 extern struct elf_strtab_hash * _bfd_elf_strtab_init
01632   (void);
01633 extern void _bfd_elf_strtab_free
01634   (struct elf_strtab_hash *);
01635 extern bfd_size_type _bfd_elf_strtab_add
01636   (struct elf_strtab_hash *, const char *, bfd_boolean);
01637 extern void _bfd_elf_strtab_addref
01638   (struct elf_strtab_hash *, bfd_size_type);
01639 extern void _bfd_elf_strtab_delref
01640   (struct elf_strtab_hash *, bfd_size_type);
01641 extern void _bfd_elf_strtab_clear_all_refs
01642   (struct elf_strtab_hash *);
01643 extern bfd_size_type _bfd_elf_strtab_size
01644   (struct elf_strtab_hash *);
01645 extern bfd_size_type _bfd_elf_strtab_offset
01646   (struct elf_strtab_hash *, bfd_size_type);
01647 extern bfd_boolean _bfd_elf_strtab_emit
01648   (bfd *, struct elf_strtab_hash *);
01649 extern void _bfd_elf_strtab_finalize
01650   (struct elf_strtab_hash *);
01651 
01652 extern bfd_boolean _bfd_elf_discard_section_eh_frame
01653   (bfd *, struct bfd_link_info *, asection *,
01654    bfd_boolean (*) (bfd_vma, void *), struct elf_reloc_cookie *);
01655 extern bfd_boolean _bfd_elf_discard_section_eh_frame_hdr
01656   (bfd *, struct bfd_link_info *);
01657 extern bfd_vma _bfd_elf_eh_frame_section_offset
01658   (bfd *, struct bfd_link_info *, asection *, bfd_vma);
01659 extern bfd_boolean _bfd_elf_write_section_eh_frame
01660   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
01661 extern bfd_boolean _bfd_elf_write_section_eh_frame_hdr
01662   (bfd *, struct bfd_link_info *);
01663 extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
01664   (struct bfd_link_info *);
01665 
01666 extern bfd_boolean _bfd_elf_merge_symbol
01667   (bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
01668    asection **, bfd_vma *, unsigned int *,
01669    struct elf_link_hash_entry **, bfd_boolean *,
01670    bfd_boolean *, bfd_boolean *, bfd_boolean *);
01671 
01672 extern bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
01673 
01674 extern bfd_boolean _bfd_elf_add_default_symbol
01675   (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
01676    const char *, Elf_Internal_Sym *, asection **, bfd_vma *,
01677    bfd_boolean *, bfd_boolean);
01678 
01679 extern bfd_boolean _bfd_elf_export_symbol
01680   (struct elf_link_hash_entry *, void *);
01681 
01682 extern bfd_boolean _bfd_elf_link_find_version_dependencies
01683   (struct elf_link_hash_entry *, void *);
01684 
01685 extern bfd_boolean _bfd_elf_link_assign_sym_version
01686   (struct elf_link_hash_entry *, void *);
01687 
01688 extern long _bfd_elf_link_lookup_local_dynindx
01689   (struct bfd_link_info *, bfd *, long);
01690 extern bfd_boolean _bfd_elf_compute_section_file_positions
01691   (bfd *, struct bfd_link_info *);
01692 extern void _bfd_elf_assign_file_positions_for_relocs
01693   (bfd *);
01694 extern file_ptr _bfd_elf_assign_file_position_for_section
01695   (Elf_Internal_Shdr *, file_ptr, bfd_boolean);
01696 
01697 extern bfd_boolean _bfd_elf_validate_reloc
01698   (bfd *, arelent *);
01699 
01700 extern bfd_boolean _bfd_elf_link_create_dynamic_sections
01701   (bfd *, struct bfd_link_info *);
01702 extern bfd_boolean _bfd_elf_link_omit_section_dynsym
01703   (bfd *, struct bfd_link_info *, asection *);
01704 extern bfd_boolean _bfd_elf_create_dynamic_sections
01705   (bfd *, struct bfd_link_info *);
01706 extern bfd_boolean _bfd_elf_create_got_section
01707   (bfd *, struct bfd_link_info *);
01708 extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
01709   (bfd *, struct bfd_link_info *, asection *, const char *);
01710 extern void _bfd_elf_init_1_index_section
01711   (bfd *, struct bfd_link_info *);
01712 extern void _bfd_elf_init_2_index_sections
01713   (bfd *, struct bfd_link_info *);
01714 
01715 extern bfd_boolean _bfd_elfcore_make_pseudosection
01716   (bfd *, char *, size_t, ufile_ptr);
01717 extern char *_bfd_elfcore_strndup
01718   (bfd *, char *, size_t);
01719 
01720 extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
01721   (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean);
01722 
01723 extern bfd_boolean _bfd_elf_link_size_reloc_section
01724   (bfd *, Elf_Internal_Shdr *, asection *);
01725 
01726 extern bfd_boolean _bfd_elf_link_output_relocs
01727   (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
01728    struct elf_link_hash_entry **);
01729 
01730 extern bfd_boolean _bfd_elf_fix_symbol_flags
01731   (struct elf_link_hash_entry *, struct elf_info_failed *);
01732 
01733 extern bfd_boolean _bfd_elf_adjust_dynamic_symbol
01734   (struct elf_link_hash_entry *, void *);
01735 
01736 extern bfd_boolean _bfd_elf_link_sec_merge_syms
01737   (struct elf_link_hash_entry *, void *);
01738 
01739 extern bfd_boolean _bfd_elf_dynamic_symbol_p
01740   (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
01741 
01742 extern bfd_boolean _bfd_elf_symbol_refs_local_p
01743   (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
01744 
01745 extern bfd_boolean bfd_elf_match_symbols_in_sections
01746   (asection *, asection *, struct bfd_link_info *);
01747 
01748 extern void bfd_elf_perform_complex_relocation
01749   (bfd *                   output_bfd ATTRIBUTE_UNUSED,
01750    struct bfd_link_info *  info,
01751    bfd *                   input_bfd,
01752    asection *              input_section,
01753    bfd_byte *              contents,
01754    Elf_Internal_Rela *     rel,
01755    Elf_Internal_Sym *      local_syms,
01756    asection **             local_sections);
01757 
01758 extern bfd_boolean _bfd_elf_setup_sections
01759   (bfd *);
01760 
01761 extern void _bfd_elf_set_osabi (bfd * , struct bfd_link_info *);
01762 
01763 extern const bfd_target *bfd_elf32_object_p
01764   (bfd *);
01765 extern const bfd_target *bfd_elf32_core_file_p
01766   (bfd *);
01767 extern char *bfd_elf32_core_file_failing_command
01768   (bfd *);
01769 extern int bfd_elf32_core_file_failing_signal
01770   (bfd *);
01771 extern bfd_boolean bfd_elf32_core_file_matches_executable_p
01772   (bfd *, bfd *);
01773 
01774 extern bfd_boolean bfd_elf32_swap_symbol_in
01775   (bfd *, const void *, const void *, Elf_Internal_Sym *);
01776 extern void bfd_elf32_swap_symbol_out
01777   (bfd *, const Elf_Internal_Sym *, void *, void *);
01778 extern void bfd_elf32_swap_reloc_in
01779   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
01780 extern void bfd_elf32_swap_reloc_out
01781   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
01782 extern void bfd_elf32_swap_reloca_in
01783   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
01784 extern void bfd_elf32_swap_reloca_out
01785   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
01786 extern void bfd_elf32_swap_phdr_in
01787   (bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *);
01788 extern void bfd_elf32_swap_phdr_out
01789   (bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *);
01790 extern void bfd_elf32_swap_dyn_in
01791   (bfd *, const void *, Elf_Internal_Dyn *);
01792 extern void bfd_elf32_swap_dyn_out
01793   (bfd *, const Elf_Internal_Dyn *, void *);
01794 extern long bfd_elf32_slurp_symbol_table
01795   (bfd *, asymbol **, bfd_boolean);
01796 extern bfd_boolean bfd_elf32_write_shdrs_and_ehdr
01797   (bfd *);
01798 extern int bfd_elf32_write_out_phdrs
01799   (bfd *, const Elf_Internal_Phdr *, unsigned int);
01800 extern void bfd_elf32_write_relocs
01801   (bfd *, asection *, void *);
01802 extern bfd_boolean bfd_elf32_slurp_reloc_table
01803   (bfd *, asection *, asymbol **, bfd_boolean);
01804 
01805 extern const bfd_target *bfd_elf64_object_p
01806   (bfd *);
01807 extern const bfd_target *bfd_elf64_core_file_p
01808   (bfd *);
01809 extern char *bfd_elf64_core_file_failing_command
01810   (bfd *);
01811 extern int bfd_elf64_core_file_failing_signal
01812   (bfd *);
01813 extern bfd_boolean bfd_elf64_core_file_matches_executable_p
01814   (bfd *, bfd *);
01815 
01816 extern bfd_boolean bfd_elf64_swap_symbol_in
01817   (bfd *, const void *, const void *, Elf_Internal_Sym *);
01818 extern void bfd_elf64_swap_symbol_out
01819   (bfd *, const Elf_Internal_Sym *, void *, void *);
01820 extern void bfd_elf64_swap_reloc_in
01821   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
01822 extern void bfd_elf64_swap_reloc_out
01823   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
01824 extern void bfd_elf64_swap_reloca_in
01825   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
01826 extern void bfd_elf64_swap_reloca_out
01827   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
01828 extern void bfd_elf64_swap_phdr_in
01829   (bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *);
01830 extern void bfd_elf64_swap_phdr_out
01831   (bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *);
01832 extern void bfd_elf64_swap_dyn_in
01833   (bfd *, const void *, Elf_Internal_Dyn *);
01834 extern void bfd_elf64_swap_dyn_out
01835   (bfd *, const Elf_Internal_Dyn *, void *);
01836 extern long bfd_elf64_slurp_symbol_table
01837   (bfd *, asymbol **, bfd_boolean);
01838 extern bfd_boolean bfd_elf64_write_shdrs_and_ehdr
01839   (bfd *);
01840 extern int bfd_elf64_write_out_phdrs
01841   (bfd *, const Elf_Internal_Phdr *, unsigned int);
01842 extern void bfd_elf64_write_relocs
01843   (bfd *, asection *, void *);
01844 extern bfd_boolean bfd_elf64_slurp_reloc_table
01845   (bfd *, asection *, asymbol **, bfd_boolean);
01846 
01847 extern struct elf_link_hash_entry *_bfd_elf_archive_symbol_lookup
01848   (bfd *, struct bfd_link_info *, const char *);
01849 extern bfd_boolean bfd_elf_link_add_symbols
01850   (bfd *, struct bfd_link_info *);
01851 extern bfd_boolean _bfd_elf_add_dynamic_entry
01852   (struct bfd_link_info *, bfd_vma, bfd_vma);
01853 
01854 extern bfd_boolean bfd_elf_link_record_dynamic_symbol
01855   (struct bfd_link_info *, struct elf_link_hash_entry *);
01856 
01857 extern int bfd_elf_link_record_local_dynamic_symbol
01858   (struct bfd_link_info *, bfd *, long);
01859 
01860 extern void bfd_elf_link_mark_dynamic_symbol
01861   (struct bfd_link_info *, struct elf_link_hash_entry *,
01862    Elf_Internal_Sym *);
01863 
01864 extern bfd_boolean _bfd_elf_close_and_cleanup
01865   (bfd *);
01866 
01867 extern bfd_boolean _bfd_elf_common_definition
01868   (Elf_Internal_Sym *);
01869 
01870 extern unsigned int _bfd_elf_common_section_index
01871   (asection *);
01872 
01873 extern asection *_bfd_elf_common_section
01874   (asection *);
01875 
01876 extern void _bfd_dwarf2_cleanup_debug_info
01877   (bfd *);
01878 
01879 extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
01880   (bfd *, arelent *, struct bfd_symbol *, void *,
01881    asection *, bfd *, char **);
01882 
01883 extern bfd_boolean bfd_elf_final_link
01884   (bfd *, struct bfd_link_info *);
01885 
01886 extern bfd_boolean bfd_elf_gc_mark_dynamic_ref_symbol
01887   (struct elf_link_hash_entry *h, void *inf);
01888 
01889 extern bfd_boolean bfd_elf_gc_sections
01890   (bfd *, struct bfd_link_info *);
01891 
01892 extern bfd_boolean bfd_elf_gc_record_vtinherit
01893   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
01894 
01895 extern bfd_boolean bfd_elf_gc_record_vtentry
01896   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
01897 
01898 extern asection *_bfd_elf_gc_mark_hook
01899   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
01900    struct elf_link_hash_entry *, Elf_Internal_Sym *);
01901 
01902 extern bfd_boolean _bfd_elf_gc_mark
01903   (struct bfd_link_info *, asection *,
01904    asection * (*) (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
01905                  struct elf_link_hash_entry *, Elf_Internal_Sym *));
01906 
01907 extern bfd_boolean bfd_elf_gc_common_finalize_got_offsets
01908   (bfd *, struct bfd_link_info *);
01909 
01910 extern bfd_boolean bfd_elf_gc_common_final_link
01911   (bfd *, struct bfd_link_info *);
01912 
01913 extern bfd_boolean bfd_elf_reloc_symbol_deleted_p
01914   (bfd_vma, void *);
01915 
01916 extern struct elf_segment_map * _bfd_elf_make_dynamic_segment
01917   (bfd *, asection *);
01918 
01919 extern bfd_boolean _bfd_elf_map_sections_to_segments
01920   (bfd *, struct bfd_link_info *);
01921 
01922 /* Exported interface for writing elf corefile notes. */
01923 extern char *elfcore_write_note
01924   (bfd *, char *, int *, const char *, int, const void *, int);
01925 extern char *elfcore_write_prpsinfo
01926   (bfd *, char *, int *, const char *, const char *);
01927 extern char *elfcore_write_prstatus
01928   (bfd *, char *, int *, long, int, const void *);
01929 extern char * elfcore_write_pstatus
01930   (bfd *, char *, int *, long, int, const void *);
01931 extern char *elfcore_write_prfpreg
01932   (bfd *, char *, int *, const void *, int);
01933 extern char *elfcore_write_prxfpreg
01934   (bfd *, char *, int *, const void *, int);
01935 extern char *elfcore_write_lwpstatus
01936   (bfd *, char *, int *, long, int, const void *);
01937 
01938 extern bfd *_bfd_elf32_bfd_from_remote_memory
01939   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
01940    int (*target_read_memory) (bfd_vma, bfd_byte *, int));
01941 extern bfd *_bfd_elf64_bfd_from_remote_memory
01942   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
01943    int (*target_read_memory) (bfd_vma, bfd_byte *, int));
01944 
01945 /* Large common section.  */
01946 extern asection _bfd_elf_large_com_section;
01947 
01948 /* SH ELF specific routine.  */
01949 
01950 extern bfd_boolean _sh_elf_set_mach_from_flags
01951   (bfd *);
01952 
01953 /* This is the condition under which finish_dynamic_symbol will be called.
01954    If our finish_dynamic_symbol isn't called, we'll need to do something
01955    about initializing any .plt and .got entries in relocate_section.  */
01956 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
01957   ((DYN)                                                       \
01958    && ((SHARED) || !(H)->forced_local)                                \
01959    && ((H)->dynindx != -1 || (H)->forced_local))
01960 
01961 /* This macro is to avoid lots of duplicated code in the body
01962    of xxx_relocate_section() in the various elfxx-xxxx.c files.  */
01963 #define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel,  \
01964                             r_symndx, symtab_hdr, sym_hashes,  \
01965                             h, sec, relocation,                \
01966                             unresolved_reloc, warned)          \
01967   do                                                           \
01968     {                                                          \
01969       /* It seems this can happen with erroneous or unsupported              \
01970         input (mixing a.out and elf in an archive, for example.)  */  \
01971       if (sym_hashes == NULL)                                         \
01972        return FALSE;                                           \
01973                                                                \
01974       h = sym_hashes[r_symndx - symtab_hdr->sh_info];                 \
01975                                                                \
01976       while (h->root.type == bfd_link_hash_indirect                   \
01977             || h->root.type == bfd_link_hash_warning)                 \
01978        h = (struct elf_link_hash_entry *) h->root.u.i.link;           \
01979                                                                \
01980       warned = FALSE;                                                 \
01981       unresolved_reloc = FALSE;                                       \
01982       relocation = 0;                                                 \
01983       if (h->root.type == bfd_link_hash_defined                       \
01984          || h->root.type == bfd_link_hash_defweak)                    \
01985        {                                                       \
01986          sec = h->root.u.def.section;                                 \
01987          if (sec == NULL                                       \
01988              || sec->output_section == NULL)                          \
01989            /* Set a flag that will be cleared later if we find a      \
01990               relocation value for this symbol.  output_section       \
01991               is typically NULL for symbols satisfied by a shared     \
01992               library.  */                                     \
01993            unresolved_reloc = TRUE;                                   \
01994          else                                                  \
01995            relocation = (h->root.u.def.value                          \
01996                        + sec->output_section->vma                     \
01997                        + sec->output_offset);                  \
01998        }                                                       \
01999       else if (h->root.type == bfd_link_hash_undefweak)               \
02000        ;                                                       \
02001       else if (info->unresolved_syms_in_objects == RM_IGNORE          \
02002               && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)         \
02003        ;                                                       \
02004       else if (!info->relocatable)                             \
02005        {                                                       \
02006          bfd_boolean err;                                      \
02007          err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR \
02008                || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT);       \
02009          if (!info->callbacks->undefined_symbol (info,                \
02010                                             h->root.root.string,      \
02011                                             input_bfd,         \
02012                                             input_section,     \
02013                                             rel->r_offset, err))      \
02014            return FALSE;                                       \
02015          warned = TRUE;                                        \
02016        }                                                       \
02017     }                                                          \
02018   while (0)
02019 
02020 /* Will a symbol be bound to the the definition within the shared
02021    library, if any.  */
02022 #define SYMBOLIC_BIND(INFO, H) \
02023     ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))
02024 
02025 #endif /* _LIBELF_H_ */