Home | History | Annotate | Download | only in include
      1 /* bfdlink.h -- header file for BFD link routines
      2    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
      3    2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
      4    Free Software Foundation, Inc.
      5    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support.
      6 
      7    This file is part of BFD, the Binary File Descriptor library.
      8 
      9    This program is free software; you can redistribute it and/or modify
     10    it under the terms of the GNU General Public License as published by
     11    the Free Software Foundation; either version 3 of the License, or
     12    (at your option) any later version.
     13 
     14    This program is distributed in the hope that it will be useful,
     15    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17    GNU General Public License for more details.
     18 
     19    You should have received a copy of the GNU General Public License
     20    along with this program; if not, write to the Free Software
     21    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     22    MA 02110-1301, USA.  */
     23 
     24 #ifndef BFDLINK_H
     25 #define BFDLINK_H
     26 
     27 /* Which symbols to strip during a link.  */
     28 enum bfd_link_strip
     29 {
     30   strip_none,		/* Don't strip any symbols.  */
     31   strip_debugger,	/* Strip debugging symbols.  */
     32   strip_some,		/* keep_hash is the list of symbols to keep.  */
     33   strip_all		/* Strip all symbols.  */
     34 };
     35 
     36 /* Which local symbols to discard during a link.  This is irrelevant
     37    if strip_all is used.  */
     38 enum bfd_link_discard
     39 {
     40   discard_sec_merge,	/* Discard local temporary symbols in SEC_MERGE
     41 			   sections.  */
     42   discard_none,		/* Don't discard any locals.  */
     43   discard_l,		/* Discard local temporary symbols.  */
     44   discard_all		/* Discard all locals.  */
     45 };
     46 
     47 /* Describes the type of hash table entry structure being used.
     48    Different hash table structure have different fields and so
     49    support different linking features.  */
     50 enum bfd_link_hash_table_type
     51   {
     52     bfd_link_generic_hash_table,
     53     bfd_link_elf_hash_table
     54   };
     55 
     56 /* These are the possible types of an entry in the BFD link hash
     58    table.  */
     59 
     60 enum bfd_link_hash_type
     61 {
     62   bfd_link_hash_new,		/* Symbol is new.  */
     63   bfd_link_hash_undefined,	/* Symbol seen before, but undefined.  */
     64   bfd_link_hash_undefweak,	/* Symbol is weak and undefined.  */
     65   bfd_link_hash_defined,	/* Symbol is defined.  */
     66   bfd_link_hash_defweak,	/* Symbol is weak and defined.  */
     67   bfd_link_hash_common,		/* Symbol is common.  */
     68   bfd_link_hash_indirect,	/* Symbol is an indirect link.  */
     69   bfd_link_hash_warning		/* Like indirect, but warn if referenced.  */
     70 };
     71 
     72 enum bfd_link_common_skip_ar_symbols
     73 {
     74   bfd_link_common_skip_none,
     75   bfd_link_common_skip_text,
     76   bfd_link_common_skip_data,
     77   bfd_link_common_skip_all
     78 };
     79 
     80 struct bfd_link_hash_common_entry
     81   {
     82     unsigned int alignment_power;	/* Alignment.  */
     83     asection *section;		/* Symbol section.  */
     84   };
     85 
     86 /* The linking routines use a hash table which uses this structure for
     87    its elements.  */
     88 
     89 struct bfd_link_hash_entry
     90 {
     91   /* Base hash table entry structure.  */
     92   struct bfd_hash_entry root;
     93 
     94   /* Type of this entry.  */
     95   ENUM_BITFIELD (bfd_link_hash_type) type : 8;
     96 
     97   unsigned int non_ir_ref : 1;
     98 
     99   /* A union of information depending upon the type.  */
    100   union
    101     {
    102       /* Nothing is kept for bfd_hash_new.  */
    103       /* bfd_link_hash_undefined, bfd_link_hash_undefweak.  */
    104       struct
    105 	{
    106 	  /* Undefined and common symbols are kept in a linked list through
    107 	     this field.  This field is present in all of the union element
    108 	     so that we don't need to remove entries from the list when we
    109 	     change their type.  Removing entries would either require the
    110 	     list to be doubly linked, which would waste more memory, or
    111 	     require a traversal.  When an undefined or common symbol is
    112 	     created, it should be added to this list, the head of which is in
    113 	     the link hash table itself.  As symbols are defined, they need
    114 	     not be removed from the list; anything which reads the list must
    115 	     doublecheck the symbol type.
    116 
    117 	     Weak symbols are not kept on this list.
    118 
    119 	     Defined and defweak symbols use this field as a reference marker.
    120 	     If the field is not NULL, or this structure is the tail of the
    121 	     undefined symbol list, the symbol has been referenced.  If the
    122 	     symbol is undefined and becomes defined, this field will
    123 	     automatically be non-NULL since the symbol will have been on the
    124 	     undefined symbol list.  */
    125 	  struct bfd_link_hash_entry *next;
    126 	  bfd *abfd;		/* BFD symbol was found in.  */
    127 	} undef;
    128       /* bfd_link_hash_defined, bfd_link_hash_defweak.  */
    129       struct
    130 	{
    131 	  struct bfd_link_hash_entry *next;
    132 	  asection *section;	/* Symbol section.  */
    133 	  bfd_vma value;	/* Symbol value.  */
    134 	} def;
    135       /* bfd_link_hash_indirect, bfd_link_hash_warning.  */
    136       struct
    137 	{
    138 	  struct bfd_link_hash_entry *next;
    139 	  struct bfd_link_hash_entry *link;	/* Real symbol.  */
    140 	  const char *warning;	/* Warning (bfd_link_hash_warning only).  */
    141 	} i;
    142       /* bfd_link_hash_common.  */
    143       struct
    144 	{
    145 	  struct bfd_link_hash_entry *next;
    146 	  /* The linker needs to know three things about common
    147 	     symbols: the size, the alignment, and the section in
    148 	     which the symbol should be placed.  We store the size
    149 	     here, and we allocate a small structure to hold the
    150 	     section and the alignment.  The alignment is stored as a
    151 	     power of two.  We don't store all the information
    152 	     directly because we don't want to increase the size of
    153 	     the union; this structure is a major space user in the
    154 	     linker.  */
    155 	  struct bfd_link_hash_common_entry *p;
    156 	  bfd_size_type size;	/* Common symbol size.  */
    157 	} c;
    158     } u;
    159 };
    160 
    161 /* This is the link hash table.  It is a derived class of
    162    bfd_hash_table.  */
    163 
    164 struct bfd_link_hash_table
    165 {
    166   /* The hash table itself.  */
    167   struct bfd_hash_table table;
    168   /* A linked list of undefined and common symbols, linked through the
    169      next field in the bfd_link_hash_entry structure.  */
    170   struct bfd_link_hash_entry *undefs;
    171   /* Entries are added to the tail of the undefs list.  */
    172   struct bfd_link_hash_entry *undefs_tail;
    173   /* The type of the link hash table.  */
    174   enum bfd_link_hash_table_type type;
    175 };
    176 
    177 /* Look up an entry in a link hash table.  If FOLLOW is TRUE, this
    178    follows bfd_link_hash_indirect and bfd_link_hash_warning links to
    179    the real symbol.  */
    180 extern struct bfd_link_hash_entry *bfd_link_hash_lookup
    181   (struct bfd_link_hash_table *, const char *, bfd_boolean create,
    182    bfd_boolean copy, bfd_boolean follow);
    183 
    184 /* Look up an entry in the main linker hash table if the symbol might
    185    be wrapped.  This should only be used for references to an
    186    undefined symbol, not for definitions of a symbol.  */
    187 
    188 extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup
    189   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
    190    bfd_boolean, bfd_boolean);
    191 
    192 /* Traverse a link hash table.  */
    193 extern void bfd_link_hash_traverse
    194   (struct bfd_link_hash_table *,
    195     bfd_boolean (*) (struct bfd_link_hash_entry *, void *),
    196     void *);
    197 
    198 /* Add an entry to the undefs list.  */
    199 extern void bfd_link_add_undef
    200   (struct bfd_link_hash_table *, struct bfd_link_hash_entry *);
    201 
    202 /* Remove symbols from the undefs list that don't belong there.  */
    203 extern void bfd_link_repair_undef_list
    204   (struct bfd_link_hash_table *table);
    205 
    206 /* Read symbols and cache symbol pointer array in outsymbols.  */
    207 extern bfd_boolean bfd_generic_link_read_symbols (bfd *);
    208 
    209 struct bfd_sym_chain
    210 {
    211   struct bfd_sym_chain *next;
    212   const char *name;
    213 };
    214 
    215 /* How to handle unresolved symbols.
    217    There are four possibilities which are enumerated below:  */
    218 enum report_method
    219 {
    220   /* This is the initial value when then link_info structure is created.
    221      It allows the various stages of the linker to determine whether they
    222      allowed to set the value.  */
    223   RM_NOT_YET_SET = 0,
    224   RM_IGNORE,
    225   RM_GENERATE_WARNING,
    226   RM_GENERATE_ERROR
    227 };
    228 
    229 typedef enum {with_flags, without_flags} flag_type;
    230 
    231 /* A section flag list.  */
    232 struct flag_info_list
    233 {
    234   flag_type with;
    235   const char *name;
    236   bfd_boolean valid;
    237   struct flag_info_list *next;
    238 };
    239 
    240 /* Section flag info.  */
    241 struct flag_info
    242 {
    243   flagword only_with_flags;
    244   flagword not_with_flags;
    245   struct flag_info_list *flag_list;
    246   bfd_boolean flags_initialized;
    247 };
    248 
    249 struct bfd_elf_dynamic_list;
    250 struct bfd_elf_version_tree;
    251 
    252 /* This structure holds all the information needed to communicate
    253    between BFD and the linker when doing a link.  */
    254 
    255 struct bfd_link_info
    256 {
    257   /* TRUE if BFD should generate a shared object (or a pie).  */
    258   unsigned int shared: 1;
    259 
    260   /* TRUE if generating an executable, position independent or not.  */
    261   unsigned int executable : 1;
    262 
    263   /* TRUE if generating a position independent executable.  */
    264   unsigned int pie: 1;
    265 
    266   /* TRUE if BFD should generate a relocatable object file.  */
    267   unsigned int relocatable: 1;
    268 
    269   /* TRUE if BFD should pre-bind symbols in a shared object.  */
    270   unsigned int symbolic: 1;
    271 
    272   /* TRUE if executable should not contain copy relocs.
    273      Setting this true may result in a non-sharable text segment.  */
    274   unsigned int nocopyreloc: 1;
    275 
    276   /* TRUE if BFD should export all symbols in the dynamic symbol table
    277      of an executable, rather than only those used.  */
    278   unsigned int export_dynamic: 1;
    279 
    280   /* TRUE if a default symbol version should be created and used for
    281      exported symbols.  */
    282   unsigned int create_default_symver: 1;
    283 
    284   /* TRUE if unreferenced sections should be removed.  */
    285   unsigned int gc_sections: 1;
    286 
    287   /* TRUE if every symbol should be reported back via the notice
    288      callback.  */
    289   unsigned int notice_all: 1;
    290 
    291   /* TRUE if we are loading LTO outputs.  */
    292   unsigned int loading_lto_outputs: 1;
    293 
    294   /* TRUE if global symbols in discarded sections should be stripped.  */
    295   unsigned int strip_discarded: 1;
    296 
    297   /* TRUE if all data symbols should be dynamic.  */
    298   unsigned int dynamic_data: 1;
    299 
    300   /* Which symbols to strip.  */
    301   ENUM_BITFIELD (bfd_link_strip) strip : 2;
    302 
    303   /* Which local symbols to discard.  */
    304   ENUM_BITFIELD (bfd_link_discard) discard : 2;
    305 
    306   /* Criteria for skipping symbols when determining
    307      whether to include an object from an archive. */
    308   ENUM_BITFIELD (bfd_link_common_skip_ar_symbols) common_skip_ar_symbols : 2;
    309 
    310   /* What to do with unresolved symbols in an object file.
    311      When producing executables the default is GENERATE_ERROR.
    312      When producing shared libraries the default is IGNORE.  The
    313      assumption with shared libraries is that the reference will be
    314      resolved at load/execution time.  */
    315   ENUM_BITFIELD (report_method) unresolved_syms_in_objects : 2;
    316 
    317   /* What to do with unresolved symbols in a shared library.
    318      The same defaults apply.  */
    319   ENUM_BITFIELD (report_method) unresolved_syms_in_shared_libs : 2;
    320 
    321   /* TRUE if shared objects should be linked directly, not shared.  */
    322   unsigned int static_link: 1;
    323 
    324   /* TRUE if symbols should be retained in memory, FALSE if they
    325      should be freed and reread.  */
    326   unsigned int keep_memory: 1;
    327 
    328   /* TRUE if BFD should generate relocation information in the final
    329      executable.  */
    330   unsigned int emitrelocations: 1;
    331 
    332   /* TRUE if PT_GNU_RELRO segment should be created.  */
    333   unsigned int relro: 1;
    334 
    335   /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment
    336      should be created.  */
    337   unsigned int eh_frame_hdr: 1;
    338 
    339   /* TRUE if we should warn when adding a DT_TEXTREL to a shared object.  */
    340   unsigned int warn_shared_textrel: 1;
    341 
    342   /* TRUE if we should error when adding a DT_TEXTREL.  */
    343   unsigned int error_textrel: 1;
    344 
    345   /* TRUE if .hash section should be created.  */
    346   unsigned int emit_hash: 1;
    347 
    348   /* TRUE if .gnu.hash section should be created.  */
    349   unsigned int emit_gnu_hash: 1;
    350 
    351   /* If TRUE reduce memory overheads, at the expense of speed. This will
    352      cause map file generation to use an O(N^2) algorithm and disable
    353      caching ELF symbol buffer.  */
    354   unsigned int reduce_memory_overheads: 1;
    355 
    356   /* TRUE if the output file should be in a traditional format.  This
    357      is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag
    358      on the output file, but may be checked when reading the input
    359      files.  */
    360   unsigned int traditional_format: 1;
    361 
    362   /* TRUE if non-PLT relocs should be merged into one reloc section
    363      and sorted so that relocs against the same symbol come together.  */
    364   unsigned int combreloc: 1;
    365 
    366   /* TRUE if a default symbol version should be created and used for
    367      imported symbols.  */
    368   unsigned int default_imported_symver: 1;
    369 
    370   /* TRUE if the new ELF dynamic tags are enabled. */
    371   unsigned int new_dtags: 1;
    372 
    373   /* FALSE if .eh_frame unwind info should be generated for PLT and other
    374      linker created sections, TRUE if it should be omitted.  */
    375   unsigned int no_ld_generated_unwind_info: 1;
    376 
    377   /* TRUE if BFD should generate a "task linked" object file,
    378      similar to relocatable but also with globals converted to
    379      statics.  */
    380   unsigned int task_link: 1;
    381 
    382   /* TRUE if ok to have multiple definition.  */
    383   unsigned int allow_multiple_definition: 1;
    384 
    385   /* TRUE if ok to have version with no definition.  */
    386   unsigned int allow_undefined_version: 1;
    387 
    388   /* TRUE if some symbols have to be dynamic, controlled by
    389      --dynamic-list command line options.  */
    390   unsigned int dynamic: 1;
    391 
    392   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X
    393      flags.  */
    394   unsigned int execstack: 1;
    395 
    396   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W
    397      flags.  */
    398   unsigned int noexecstack: 1;
    399 
    400   /* TRUE if we want to produced optimized output files.  This might
    401      need much more time and therefore must be explicitly selected.  */
    402   unsigned int optimize: 1;
    403 
    404   /* TRUE if user should be informed of removed unreferenced sections.  */
    405   unsigned int print_gc_sections: 1;
    406 
    407   /* TRUE if we should warn alternate ELF machine code.  */
    408   unsigned int warn_alternate_em: 1;
    409 
    410   /* TRUE if the linker script contained an explicit PHDRS command.  */
    411   unsigned int user_phdrs: 1;
    412 
    413   /* Char that may appear as the first char of a symbol, but should be
    414      skipped (like symbol_leading_char) when looking up symbols in
    415      wrap_hash.  Used by PowerPC Linux for 'dot' symbols.  */
    416   char wrap_char;
    417 
    418   /* Separator between archive and filename in linker script filespecs.  */
    419   char path_separator;
    420 
    421   /* Function callbacks.  */
    422   const struct bfd_link_callbacks *callbacks;
    423 
    424   /* Hash table handled by BFD.  */
    425   struct bfd_link_hash_table *hash;
    426 
    427   /* Hash table of symbols to keep.  This is NULL unless strip is
    428      strip_some.  */
    429   struct bfd_hash_table *keep_hash;
    430 
    431   /* Hash table of symbols to report back via the notice callback.  If
    432      this is NULL, and notice_all is FALSE, then no symbols are
    433      reported back.  */
    434   struct bfd_hash_table *notice_hash;
    435 
    436   /* Hash table of symbols which are being wrapped (the --wrap linker
    437      option).  If this is NULL, no symbols are being wrapped.  */
    438   struct bfd_hash_table *wrap_hash;
    439 
    440   /* The output BFD.  */
    441   bfd *output_bfd;
    442 
    443   /* The list of input BFD's involved in the link.  These are chained
    444      together via the link_next field.  */
    445   bfd *input_bfds;
    446   bfd **input_bfds_tail;
    447 
    448   /* Non-NULL if .note.gnu.build-id section should be created.  */
    449   char *emit_note_gnu_build_id;
    450 
    451   /* If a symbol should be created for each input BFD, this is section
    452      where those symbols should be placed.  It must be a section in
    453      the output BFD.  It may be NULL, in which case no such symbols
    454      will be created.  This is to support CREATE_OBJECT_SYMBOLS in the
    455      linker command language.  */
    456   asection *create_object_symbols_section;
    457 
    458   /* List of global symbol names that are starting points for marking
    459      sections against garbage collection.  */
    460   struct bfd_sym_chain *gc_sym_list;
    461 
    462   /* If a base output file is wanted, then this points to it */
    463   void *base_file;
    464 
    465   /* The function to call when the executable or shared object is
    466      loaded.  */
    467   const char *init_function;
    468 
    469   /* The function to call when the executable or shared object is
    470      unloaded.  */
    471   const char *fini_function;
    472 
    473   /* Number of relaxation passes.  Usually only one relaxation pass
    474      is needed.  But a backend can have as many relaxation passes as
    475      necessary.  During bfd_relax_section call, it is set to the
    476      current pass, starting from 0.  */
    477   int relax_pass;
    478 
    479   /* Number of relaxation trips.  This number is incremented every
    480      time the relaxation pass is restarted due to a previous
    481      relaxation returning true in *AGAIN.  */
    482   int relax_trip;
    483 
    484   /* Non-zero if auto-import thunks for DATA items in pei386 DLLs
    485      should be generated/linked against.  Set to 1 if this feature
    486      is explicitly requested by the user, -1 if enabled by default.  */
    487   int pei386_auto_import;
    488 
    489   /* Non-zero if runtime relocs for DATA items with non-zero addends
    490      in pei386 DLLs should be generated.  Set to 1 if this feature
    491      is explicitly requested by the user, -1 if enabled by default.  */
    492   int pei386_runtime_pseudo_reloc;
    493 
    494   /* How many spare .dynamic DT_NULL entries should be added?  */
    495   unsigned int spare_dynamic_tags;
    496 
    497   /* May be used to set DT_FLAGS for ELF. */
    498   bfd_vma flags;
    499 
    500   /* May be used to set DT_FLAGS_1 for ELF. */
    501   bfd_vma flags_1;
    502 
    503   /* Start and end of RELRO region.  */
    504   bfd_vma relro_start, relro_end;
    505 
    506   /* List of symbols should be dynamic.  */
    507   struct bfd_elf_dynamic_list *dynamic_list;
    508 
    509   /* The version information.  */
    510   struct bfd_elf_version_tree *version_info;
    511 };
    512 
    513 /* This structures holds a set of callback functions.  These are called
    514    by the BFD linker routines.  Except for the info functions, the first
    515    argument to each callback function is the bfd_link_info structure
    516    being used and each function returns a boolean value.  If the
    517    function returns FALSE, then the BFD function which called it should
    518    return with a failure indication.  */
    519 
    520 struct bfd_link_callbacks
    521 {
    522   /* A function which is called when an object is added from an
    523      archive.  ABFD is the archive element being added.  NAME is the
    524      name of the symbol which caused the archive element to be pulled
    525      in.  This function may set *SUBSBFD to point to an alternative
    526      BFD from which symbols should in fact be added in place of the
    527      original BFD's symbols.  */
    528   bfd_boolean (*add_archive_element)
    529     (struct bfd_link_info *, bfd *abfd, const char *name, bfd **subsbfd);
    530   /* A function which is called when a symbol is found with multiple
    531      definitions.  H is the symbol which is defined multiple times.
    532      NBFD is the new BFD, NSEC is the new section, and NVAL is the new
    533      value.  NSEC may be bfd_com_section or bfd_ind_section.  */
    534   bfd_boolean (*multiple_definition)
    535     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
    536      bfd *nbfd, asection *nsec, bfd_vma nval);
    537   /* A function which is called when a common symbol is defined
    538      multiple times.  H is the symbol appearing multiple times.
    539      NBFD is the BFD of the new symbol.  NTYPE is the type of the new
    540      symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or
    541      bfd_link_hash_indirect.  If NTYPE is bfd_link_hash_common, NSIZE
    542      is the size of the new symbol.  */
    543   bfd_boolean (*multiple_common)
    544     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
    545      bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize);
    546   /* A function which is called to add a symbol to a set.  ENTRY is
    547      the link hash table entry for the set itself (e.g.,
    548      __CTOR_LIST__).  RELOC is the relocation to use for an entry in
    549      the set when generating a relocatable file, and is also used to
    550      get the size of the entry when generating an executable file.
    551      ABFD, SEC and VALUE identify the value to add to the set.  */
    552   bfd_boolean (*add_to_set)
    553     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
    554      bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value);
    555   /* A function which is called when the name of a g++ constructor or
    556      destructor is found.  This is only called by some object file
    557      formats.  CONSTRUCTOR is TRUE for a constructor, FALSE for a
    558      destructor.  This will use BFD_RELOC_CTOR when generating a
    559      relocatable file.  NAME is the name of the symbol found.  ABFD,
    560      SECTION and VALUE are the value of the symbol.  */
    561   bfd_boolean (*constructor)
    562     (struct bfd_link_info *, bfd_boolean constructor, const char *name,
    563      bfd *abfd, asection *sec, bfd_vma value);
    564   /* A function which is called to issue a linker warning.  For
    565      example, this is called when there is a reference to a warning
    566      symbol.  WARNING is the warning to be issued.  SYMBOL is the name
    567      of the symbol which triggered the warning; it may be NULL if
    568      there is none.  ABFD, SECTION and ADDRESS identify the location
    569      which trigerred the warning; either ABFD or SECTION or both may
    570      be NULL if the location is not known.  */
    571   bfd_boolean (*warning)
    572     (struct bfd_link_info *, const char *warning, const char *symbol,
    573      bfd *abfd, asection *section, bfd_vma address);
    574   /* A function which is called when a relocation is attempted against
    575      an undefined symbol.  NAME is the symbol which is undefined.
    576      ABFD, SECTION and ADDRESS identify the location from which the
    577      reference is made. IS_FATAL indicates whether an undefined symbol is
    578      a fatal error or not. In some cases SECTION may be NULL.  */
    579   bfd_boolean (*undefined_symbol)
    580     (struct bfd_link_info *, const char *name, bfd *abfd,
    581      asection *section, bfd_vma address, bfd_boolean is_fatal);
    582   /* A function which is called when a reloc overflow occurs. ENTRY is
    583      the link hash table entry for the symbol the reloc is against.
    584      NAME is the name of the local symbol or section the reloc is
    585      against, RELOC_NAME is the name of the relocation, and ADDEND is
    586      any addend that is used.  ABFD, SECTION and ADDRESS identify the
    587      location at which the overflow occurs; if this is the result of a
    588      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
    589      ABFD will be NULL.  */
    590   bfd_boolean (*reloc_overflow)
    591     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
    592      const char *name, const char *reloc_name, bfd_vma addend,
    593      bfd *abfd, asection *section, bfd_vma address);
    594   /* A function which is called when a dangerous reloc is performed.
    595      MESSAGE is an appropriate message.
    596      ABFD, SECTION and ADDRESS identify the location at which the
    597      problem occurred; if this is the result of a
    598      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
    599      ABFD will be NULL.  */
    600   bfd_boolean (*reloc_dangerous)
    601     (struct bfd_link_info *, const char *message,
    602      bfd *abfd, asection *section, bfd_vma address);
    603   /* A function which is called when a reloc is found to be attached
    604      to a symbol which is not being written out.  NAME is the name of
    605      the symbol.  ABFD, SECTION and ADDRESS identify the location of
    606      the reloc; if this is the result of a
    607      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
    608      ABFD will be NULL.  */
    609   bfd_boolean (*unattached_reloc)
    610     (struct bfd_link_info *, const char *name,
    611      bfd *abfd, asection *section, bfd_vma address);
    612   /* A function which is called when a symbol in notice_hash is
    613      defined or referenced.  H is the symbol.  ABFD, SECTION and
    614      ADDRESS are the (new) value of the symbol.  If SECTION is
    615      bfd_und_section, this is a reference.  FLAGS are the symbol
    616      BSF_* flags.  STRING is the name of the symbol to indirect to if
    617      the sym is indirect, or the warning string if a warning sym.  */
    618   bfd_boolean (*notice)
    619     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
    620      bfd *abfd, asection *section, bfd_vma address, flagword flags,
    621      const char *string);
    622   /* Error or warning link info message.  */
    623   void (*einfo)
    624     (const char *fmt, ...);
    625   /* General link info message.  */
    626   void (*info)
    627     (const char *fmt, ...);
    628   /* Message to be printed in linker map file.  */
    629   void (*minfo)
    630     (const char *fmt, ...);
    631   /* This callback provides a chance for users of the BFD library to
    632      override its decision about whether to place two adjacent sections
    633      into the same segment.  */
    634   bfd_boolean (*override_segment_assignment)
    635     (struct bfd_link_info *, bfd * abfd,
    636      asection * current_section, asection * previous_section,
    637      bfd_boolean new_segment);
    638 };
    639 
    640 /* The linker builds link_order structures which tell the code how to
    642    include input data in the output file.  */
    643 
    644 /* These are the types of link_order structures.  */
    645 
    646 enum bfd_link_order_type
    647 {
    648   bfd_undefined_link_order,	/* Undefined.  */
    649   bfd_indirect_link_order,	/* Built from a section.  */
    650   bfd_data_link_order,		/* Set to explicit data.  */
    651   bfd_section_reloc_link_order,	/* Relocate against a section.  */
    652   bfd_symbol_reloc_link_order	/* Relocate against a symbol.  */
    653 };
    654 
    655 /* This is the link_order structure itself.  These form a chain
    656    attached to the output section whose contents they are describing.  */
    657 
    658 struct bfd_link_order
    659 {
    660   /* Next link_order in chain.  */
    661   struct bfd_link_order *next;
    662   /* Type of link_order.  */
    663   enum bfd_link_order_type type;
    664   /* Offset within output section.  */
    665   bfd_vma offset;
    666   /* Size within output section.  */
    667   bfd_size_type size;
    668   /* Type specific information.  */
    669   union
    670     {
    671       struct
    672 	{
    673 	  /* Section to include.  If this is used, then
    674 	     section->output_section must be the section the
    675 	     link_order is attached to, section->output_offset must
    676 	     equal the link_order offset field, and section->size
    677 	     must equal the link_order size field.  Maybe these
    678 	     restrictions should be relaxed someday.  */
    679 	  asection *section;
    680 	} indirect;
    681       struct
    682 	{
    683 	  /* Size of contents, or zero when contents should be filled by
    684 	     the architecture-dependent fill function.
    685 	     A non-zero value allows filling of the output section
    686 	     with an arbitrary repeated pattern.  */
    687 	  unsigned int size;
    688 	  /* Data to put into file.  */
    689 	  bfd_byte *contents;
    690 	} data;
    691       struct
    692 	{
    693 	  /* Description of reloc to generate.  Used for
    694 	     bfd_section_reloc_link_order and
    695 	     bfd_symbol_reloc_link_order.  */
    696 	  struct bfd_link_order_reloc *p;
    697 	} reloc;
    698     } u;
    699 };
    700 
    701 /* A linker order of type bfd_section_reloc_link_order or
    702    bfd_symbol_reloc_link_order means to create a reloc against a
    703    section or symbol, respectively.  This is used to implement -Ur to
    704    generate relocs for the constructor tables.  The
    705    bfd_link_order_reloc structure describes the reloc that BFD should
    706    create.  It is similar to a arelent, but I didn't use arelent
    707    because the linker does not know anything about most symbols, and
    708    any asymbol structure it creates will be partially meaningless.
    709    This information could logically be in the bfd_link_order struct,
    710    but I didn't want to waste the space since these types of relocs
    711    are relatively rare.  */
    712 
    713 struct bfd_link_order_reloc
    714 {
    715   /* Reloc type.  */
    716   bfd_reloc_code_real_type reloc;
    717 
    718   union
    719     {
    720       /* For type bfd_section_reloc_link_order, this is the section
    721 	 the reloc should be against.  This must be a section in the
    722 	 output BFD, not any of the input BFDs.  */
    723       asection *section;
    724       /* For type bfd_symbol_reloc_link_order, this is the name of the
    725 	 symbol the reloc should be against.  */
    726       const char *name;
    727     } u;
    728 
    729   /* Addend to use.  The object file should contain zero.  The BFD
    730      backend is responsible for filling in the contents of the object
    731      file correctly.  For some object file formats (e.g., COFF) the
    732      addend must be stored into in the object file, and for some
    733      (e.g., SPARC a.out) it is kept in the reloc.  */
    734   bfd_vma addend;
    735 };
    736 
    737 /* Allocate a new link_order for a section.  */
    738 extern struct bfd_link_order *bfd_new_link_order (bfd *, asection *);
    739 
    740 /* These structures are used to describe version information for the
    741    ELF linker.  These structures could be manipulated entirely inside
    742    BFD, but it would be a pain.  Instead, the regular linker sets up
    743    these structures, and then passes them into BFD.  */
    744 
    745 /* Glob pattern for a version.  */
    746 
    747 struct bfd_elf_version_expr
    748 {
    749   /* Next glob pattern for this version.  */
    750   struct bfd_elf_version_expr *next;
    751   /* Glob pattern.  */
    752   const char *pattern;
    753   /* Set if pattern is not a glob.  */
    754   unsigned int literal : 1;
    755   /* Defined by ".symver".  */
    756   unsigned int symver : 1;
    757   /* Defined by version script.  */
    758   unsigned int script : 1;
    759   /* Pattern type.  */
    760 #define BFD_ELF_VERSION_C_TYPE		1
    761 #define BFD_ELF_VERSION_CXX_TYPE	2
    762 #define BFD_ELF_VERSION_JAVA_TYPE	4
    763   unsigned int mask : 3;
    764 };
    765 
    766 struct bfd_elf_version_expr_head
    767 {
    768   /* List of all patterns, both wildcards and non-wildcards.  */
    769   struct bfd_elf_version_expr *list;
    770   /* Hash table for non-wildcards.  */
    771   void *htab;
    772   /* Remaining patterns.  */
    773   struct bfd_elf_version_expr *remaining;
    774   /* What kind of pattern types are present in list (bitmask).  */
    775   unsigned int mask;
    776 };
    777 
    778 /* Version dependencies.  */
    779 
    780 struct bfd_elf_version_deps
    781 {
    782   /* Next dependency for this version.  */
    783   struct bfd_elf_version_deps *next;
    784   /* The version which this version depends upon.  */
    785   struct bfd_elf_version_tree *version_needed;
    786 };
    787 
    788 /* A node in the version tree.  */
    789 
    790 struct bfd_elf_version_tree
    791 {
    792   /* Next version.  */
    793   struct bfd_elf_version_tree *next;
    794   /* Name of this version.  */
    795   const char *name;
    796   /* Version number.  */
    797   unsigned int vernum;
    798   /* Regular expressions for global symbols in this version.  */
    799   struct bfd_elf_version_expr_head globals;
    800   /* Regular expressions for local symbols in this version.  */
    801   struct bfd_elf_version_expr_head locals;
    802   /* List of versions which this version depends upon.  */
    803   struct bfd_elf_version_deps *deps;
    804   /* Index of the version name.  This is used within BFD.  */
    805   unsigned int name_indx;
    806   /* Whether this version tree was used.  This is used within BFD.  */
    807   int used;
    808   /* Matching hook.  */
    809   struct bfd_elf_version_expr *(*match)
    810     (struct bfd_elf_version_expr_head *head,
    811      struct bfd_elf_version_expr *prev, const char *sym);
    812 };
    813 
    814 struct bfd_elf_dynamic_list
    815 {
    816   struct bfd_elf_version_expr_head head;
    817   struct bfd_elf_version_expr *(*match)
    818     (struct bfd_elf_version_expr_head *head,
    819      struct bfd_elf_version_expr *prev, const char *sym);
    820 };
    821 
    822 #endif
    823