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