xref: /dflybsd-src/contrib/gdb-7/include/bfdlink.h (revision c50c785cb49e9377ca78104c5540c7b33f768771)
15796c8dcSSimon Schubert /* bfdlink.h -- header file for BFD link routines
25796c8dcSSimon Schubert    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
35796c8dcSSimon Schubert    2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
45796c8dcSSimon Schubert    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    This file is part of BFD, the Binary File Descriptor library.
75796c8dcSSimon Schubert 
85796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
95796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
105796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
115796c8dcSSimon Schubert    (at your option) any later version.
125796c8dcSSimon Schubert 
135796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
145796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
155796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165796c8dcSSimon Schubert    GNU General Public License for more details.
175796c8dcSSimon Schubert 
185796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
195796c8dcSSimon Schubert    along with this program; if not, write to the Free Software
205796c8dcSSimon Schubert    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
215796c8dcSSimon Schubert    MA 02110-1301, USA.  */
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert #ifndef BFDLINK_H
245796c8dcSSimon Schubert #define BFDLINK_H
255796c8dcSSimon Schubert 
265796c8dcSSimon Schubert /* Which symbols to strip during a link.  */
275796c8dcSSimon Schubert enum bfd_link_strip
285796c8dcSSimon Schubert {
295796c8dcSSimon Schubert   strip_none,		/* Don't strip any symbols.  */
305796c8dcSSimon Schubert   strip_debugger,	/* Strip debugging symbols.  */
315796c8dcSSimon Schubert   strip_some,		/* keep_hash is the list of symbols to keep.  */
325796c8dcSSimon Schubert   strip_all		/* Strip all symbols.  */
335796c8dcSSimon Schubert };
345796c8dcSSimon Schubert 
355796c8dcSSimon Schubert /* Which local symbols to discard during a link.  This is irrelevant
365796c8dcSSimon Schubert    if strip_all is used.  */
375796c8dcSSimon Schubert enum bfd_link_discard
385796c8dcSSimon Schubert {
395796c8dcSSimon Schubert   discard_sec_merge,	/* Discard local temporary symbols in SEC_MERGE
405796c8dcSSimon Schubert 			   sections.  */
415796c8dcSSimon Schubert   discard_none,		/* Don't discard any locals.  */
425796c8dcSSimon Schubert   discard_l,		/* Discard local temporary symbols.  */
435796c8dcSSimon Schubert   discard_all		/* Discard all locals.  */
445796c8dcSSimon Schubert };
455796c8dcSSimon Schubert 
465796c8dcSSimon Schubert /* Describes the type of hash table entry structure being used.
475796c8dcSSimon Schubert    Different hash table structure have different fields and so
485796c8dcSSimon Schubert    support different linking features.  */
495796c8dcSSimon Schubert enum bfd_link_hash_table_type
505796c8dcSSimon Schubert   {
515796c8dcSSimon Schubert     bfd_link_generic_hash_table,
525796c8dcSSimon Schubert     bfd_link_elf_hash_table
535796c8dcSSimon Schubert   };
545796c8dcSSimon Schubert 
555796c8dcSSimon Schubert /* These are the possible types of an entry in the BFD link hash
565796c8dcSSimon Schubert    table.  */
575796c8dcSSimon Schubert 
585796c8dcSSimon Schubert enum bfd_link_hash_type
595796c8dcSSimon Schubert {
605796c8dcSSimon Schubert   bfd_link_hash_new,		/* Symbol is new.  */
615796c8dcSSimon Schubert   bfd_link_hash_undefined,	/* Symbol seen before, but undefined.  */
625796c8dcSSimon Schubert   bfd_link_hash_undefweak,	/* Symbol is weak and undefined.  */
635796c8dcSSimon Schubert   bfd_link_hash_defined,	/* Symbol is defined.  */
645796c8dcSSimon Schubert   bfd_link_hash_defweak,	/* Symbol is weak and defined.  */
655796c8dcSSimon Schubert   bfd_link_hash_common,		/* Symbol is common.  */
665796c8dcSSimon Schubert   bfd_link_hash_indirect,	/* Symbol is an indirect link.  */
675796c8dcSSimon Schubert   bfd_link_hash_warning		/* Like indirect, but warn if referenced.  */
685796c8dcSSimon Schubert };
695796c8dcSSimon Schubert 
70cf7f2e2dSJohn Marino enum bfd_link_common_skip_ar_symbols
715796c8dcSSimon Schubert {
725796c8dcSSimon Schubert   bfd_link_common_skip_none,
735796c8dcSSimon Schubert   bfd_link_common_skip_text,
745796c8dcSSimon Schubert   bfd_link_common_skip_data,
755796c8dcSSimon Schubert   bfd_link_common_skip_all
765796c8dcSSimon Schubert };
775796c8dcSSimon Schubert 
785796c8dcSSimon Schubert struct bfd_link_hash_common_entry
795796c8dcSSimon Schubert   {
805796c8dcSSimon Schubert     unsigned int alignment_power;	/* Alignment.  */
815796c8dcSSimon Schubert     asection *section;		/* Symbol section.  */
825796c8dcSSimon Schubert   };
835796c8dcSSimon Schubert 
845796c8dcSSimon Schubert /* The linking routines use a hash table which uses this structure for
855796c8dcSSimon Schubert    its elements.  */
865796c8dcSSimon Schubert 
875796c8dcSSimon Schubert struct bfd_link_hash_entry
885796c8dcSSimon Schubert {
895796c8dcSSimon Schubert   /* Base hash table entry structure.  */
905796c8dcSSimon Schubert   struct bfd_hash_entry root;
915796c8dcSSimon Schubert 
925796c8dcSSimon Schubert   /* Type of this entry.  */
935796c8dcSSimon Schubert   enum bfd_link_hash_type type;
945796c8dcSSimon Schubert 
955796c8dcSSimon Schubert   /* A union of information depending upon the type.  */
965796c8dcSSimon Schubert   union
975796c8dcSSimon Schubert     {
985796c8dcSSimon Schubert       /* Nothing is kept for bfd_hash_new.  */
995796c8dcSSimon Schubert       /* bfd_link_hash_undefined, bfd_link_hash_undefweak.  */
1005796c8dcSSimon Schubert       struct
1015796c8dcSSimon Schubert 	{
1025796c8dcSSimon Schubert 	  /* Undefined and common symbols are kept in a linked list through
1035796c8dcSSimon Schubert 	     this field.  This field is present in all of the union element
1045796c8dcSSimon Schubert 	     so that we don't need to remove entries from the list when we
1055796c8dcSSimon Schubert 	     change their type.  Removing entries would either require the
1065796c8dcSSimon Schubert 	     list to be doubly linked, which would waste more memory, or
1075796c8dcSSimon Schubert 	     require a traversal.  When an undefined or common symbol is
1085796c8dcSSimon Schubert 	     created, it should be added to this list, the head of which is in
1095796c8dcSSimon Schubert 	     the link hash table itself.  As symbols are defined, they need
1105796c8dcSSimon Schubert 	     not be removed from the list; anything which reads the list must
1115796c8dcSSimon Schubert 	     doublecheck the symbol type.
1125796c8dcSSimon Schubert 
1135796c8dcSSimon Schubert 	     Weak symbols are not kept on this list.
1145796c8dcSSimon Schubert 
1155796c8dcSSimon Schubert 	     Defined and defweak symbols use this field as a reference marker.
1165796c8dcSSimon Schubert 	     If the field is not NULL, or this structure is the tail of the
1175796c8dcSSimon Schubert 	     undefined symbol list, the symbol has been referenced.  If the
1185796c8dcSSimon Schubert 	     symbol is undefined and becomes defined, this field will
1195796c8dcSSimon Schubert 	     automatically be non-NULL since the symbol will have been on the
1205796c8dcSSimon Schubert 	     undefined symbol list.  */
1215796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
1225796c8dcSSimon Schubert 	  bfd *abfd;		/* BFD symbol was found in.  */
1235796c8dcSSimon Schubert 	  bfd *weak;		/* BFD weak symbol was found in.  */
1245796c8dcSSimon Schubert 	} undef;
1255796c8dcSSimon Schubert       /* bfd_link_hash_defined, bfd_link_hash_defweak.  */
1265796c8dcSSimon Schubert       struct
1275796c8dcSSimon Schubert 	{
1285796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
1295796c8dcSSimon Schubert 	  asection *section;	/* Symbol section.  */
1305796c8dcSSimon Schubert 	  bfd_vma value;	/* Symbol value.  */
1315796c8dcSSimon Schubert 	} def;
1325796c8dcSSimon Schubert       /* bfd_link_hash_indirect, bfd_link_hash_warning.  */
1335796c8dcSSimon Schubert       struct
1345796c8dcSSimon Schubert 	{
1355796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
1365796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *link;	/* Real symbol.  */
1375796c8dcSSimon Schubert 	  const char *warning;	/* Warning (bfd_link_hash_warning only).  */
1385796c8dcSSimon Schubert 	} i;
1395796c8dcSSimon Schubert       /* bfd_link_hash_common.  */
1405796c8dcSSimon Schubert       struct
1415796c8dcSSimon Schubert 	{
1425796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
1435796c8dcSSimon Schubert 	  /* The linker needs to know three things about common
1445796c8dcSSimon Schubert 	     symbols: the size, the alignment, and the section in
1455796c8dcSSimon Schubert 	     which the symbol should be placed.  We store the size
1465796c8dcSSimon Schubert 	     here, and we allocate a small structure to hold the
1475796c8dcSSimon Schubert 	     section and the alignment.  The alignment is stored as a
1485796c8dcSSimon Schubert 	     power of two.  We don't store all the information
1495796c8dcSSimon Schubert 	     directly because we don't want to increase the size of
1505796c8dcSSimon Schubert 	     the union; this structure is a major space user in the
1515796c8dcSSimon Schubert 	     linker.  */
1525796c8dcSSimon Schubert 	  struct bfd_link_hash_common_entry *p;
1535796c8dcSSimon Schubert 	  bfd_size_type size;	/* Common symbol size.  */
1545796c8dcSSimon Schubert 	} c;
1555796c8dcSSimon Schubert     } u;
1565796c8dcSSimon Schubert };
1575796c8dcSSimon Schubert 
1585796c8dcSSimon Schubert /* This is the link hash table.  It is a derived class of
1595796c8dcSSimon Schubert    bfd_hash_table.  */
1605796c8dcSSimon Schubert 
1615796c8dcSSimon Schubert struct bfd_link_hash_table
1625796c8dcSSimon Schubert {
1635796c8dcSSimon Schubert   /* The hash table itself.  */
1645796c8dcSSimon Schubert   struct bfd_hash_table table;
1655796c8dcSSimon Schubert   /* A linked list of undefined and common symbols, linked through the
1665796c8dcSSimon Schubert      next field in the bfd_link_hash_entry structure.  */
1675796c8dcSSimon Schubert   struct bfd_link_hash_entry *undefs;
1685796c8dcSSimon Schubert   /* Entries are added to the tail of the undefs list.  */
1695796c8dcSSimon Schubert   struct bfd_link_hash_entry *undefs_tail;
1705796c8dcSSimon Schubert   /* The type of the link hash table.  */
1715796c8dcSSimon Schubert   enum bfd_link_hash_table_type type;
1725796c8dcSSimon Schubert };
1735796c8dcSSimon Schubert 
1745796c8dcSSimon Schubert /* Look up an entry in a link hash table.  If FOLLOW is TRUE, this
1755796c8dcSSimon Schubert    follows bfd_link_hash_indirect and bfd_link_hash_warning links to
1765796c8dcSSimon Schubert    the real symbol.  */
1775796c8dcSSimon Schubert extern struct bfd_link_hash_entry *bfd_link_hash_lookup
1785796c8dcSSimon Schubert   (struct bfd_link_hash_table *, const char *, bfd_boolean create,
1795796c8dcSSimon Schubert    bfd_boolean copy, bfd_boolean follow);
1805796c8dcSSimon Schubert 
1815796c8dcSSimon Schubert /* Look up an entry in the main linker hash table if the symbol might
1825796c8dcSSimon Schubert    be wrapped.  This should only be used for references to an
1835796c8dcSSimon Schubert    undefined symbol, not for definitions of a symbol.  */
1845796c8dcSSimon Schubert 
1855796c8dcSSimon Schubert extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup
1865796c8dcSSimon Schubert   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
1875796c8dcSSimon Schubert    bfd_boolean, bfd_boolean);
1885796c8dcSSimon Schubert 
1895796c8dcSSimon Schubert /* Traverse a link hash table.  */
1905796c8dcSSimon Schubert extern void bfd_link_hash_traverse
1915796c8dcSSimon Schubert   (struct bfd_link_hash_table *,
1925796c8dcSSimon Schubert     bfd_boolean (*) (struct bfd_link_hash_entry *, void *),
1935796c8dcSSimon Schubert     void *);
1945796c8dcSSimon Schubert 
1955796c8dcSSimon Schubert /* Add an entry to the undefs list.  */
1965796c8dcSSimon Schubert extern void bfd_link_add_undef
1975796c8dcSSimon Schubert   (struct bfd_link_hash_table *, struct bfd_link_hash_entry *);
1985796c8dcSSimon Schubert 
1995796c8dcSSimon Schubert /* Remove symbols from the undefs list that don't belong there.  */
2005796c8dcSSimon Schubert extern void bfd_link_repair_undef_list
2015796c8dcSSimon Schubert   (struct bfd_link_hash_table *table);
2025796c8dcSSimon Schubert 
2035796c8dcSSimon Schubert /* Read symbols and cache symbol pointer array in outsymbols.  */
2045796c8dcSSimon Schubert extern bfd_boolean bfd_generic_link_read_symbols (bfd *);
2055796c8dcSSimon Schubert 
2065796c8dcSSimon Schubert struct bfd_sym_chain
2075796c8dcSSimon Schubert {
2085796c8dcSSimon Schubert   struct bfd_sym_chain *next;
2095796c8dcSSimon Schubert   const char *name;
2105796c8dcSSimon Schubert };
2115796c8dcSSimon Schubert 
2125796c8dcSSimon Schubert /* How to handle unresolved symbols.
2135796c8dcSSimon Schubert    There are four possibilities which are enumerated below:  */
2145796c8dcSSimon Schubert enum report_method
2155796c8dcSSimon Schubert {
2165796c8dcSSimon Schubert   /* This is the initial value when then link_info structure is created.
2175796c8dcSSimon Schubert      It allows the various stages of the linker to determine whether they
2185796c8dcSSimon Schubert      allowed to set the value.  */
2195796c8dcSSimon Schubert   RM_NOT_YET_SET = 0,
2205796c8dcSSimon Schubert   RM_IGNORE,
2215796c8dcSSimon Schubert   RM_GENERATE_WARNING,
2225796c8dcSSimon Schubert   RM_GENERATE_ERROR
2235796c8dcSSimon Schubert };
2245796c8dcSSimon Schubert 
2255796c8dcSSimon Schubert struct bfd_elf_dynamic_list;
2265796c8dcSSimon Schubert 
2275796c8dcSSimon Schubert /* This structure holds all the information needed to communicate
2285796c8dcSSimon Schubert    between BFD and the linker when doing a link.  */
2295796c8dcSSimon Schubert 
2305796c8dcSSimon Schubert struct bfd_link_info
2315796c8dcSSimon Schubert {
2325796c8dcSSimon Schubert   /* TRUE if BFD should generate a relocatable object file.  */
2335796c8dcSSimon Schubert   unsigned int relocatable: 1;
2345796c8dcSSimon Schubert 
2355796c8dcSSimon Schubert   /* TRUE if BFD should generate relocation information in the final
2365796c8dcSSimon Schubert      executable.  */
2375796c8dcSSimon Schubert   unsigned int emitrelocations: 1;
2385796c8dcSSimon Schubert 
2395796c8dcSSimon Schubert   /* TRUE if BFD should generate a "task linked" object file,
2405796c8dcSSimon Schubert      similar to relocatable but also with globals converted to
2415796c8dcSSimon Schubert      statics.  */
2425796c8dcSSimon Schubert   unsigned int task_link: 1;
2435796c8dcSSimon Schubert 
2445796c8dcSSimon Schubert   /* TRUE if BFD should generate a shared object.  */
2455796c8dcSSimon Schubert   unsigned int shared: 1;
2465796c8dcSSimon Schubert 
2475796c8dcSSimon Schubert   /* TRUE if BFD should pre-bind symbols in a shared object.  */
2485796c8dcSSimon Schubert   unsigned int symbolic: 1;
2495796c8dcSSimon Schubert 
2505796c8dcSSimon Schubert   /* TRUE if BFD should export all symbols in the dynamic symbol table
2515796c8dcSSimon Schubert      of an executable, rather than only those used.  */
2525796c8dcSSimon Schubert   unsigned int export_dynamic: 1;
2535796c8dcSSimon Schubert 
2545796c8dcSSimon Schubert   /* TRUE if shared objects should be linked directly, not shared.  */
2555796c8dcSSimon Schubert   unsigned int static_link: 1;
2565796c8dcSSimon Schubert 
2575796c8dcSSimon Schubert   /* TRUE if the output file should be in a traditional format.  This
2585796c8dcSSimon Schubert      is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag
2595796c8dcSSimon Schubert      on the output file, but may be checked when reading the input
2605796c8dcSSimon Schubert      files.  */
2615796c8dcSSimon Schubert   unsigned int traditional_format: 1;
2625796c8dcSSimon Schubert 
2635796c8dcSSimon Schubert   /* TRUE if we want to produced optimized output files.  This might
2645796c8dcSSimon Schubert      need much more time and therefore must be explicitly selected.  */
2655796c8dcSSimon Schubert   unsigned int optimize: 1;
2665796c8dcSSimon Schubert 
2675796c8dcSSimon Schubert   /* TRUE if ok to have multiple definition.  */
2685796c8dcSSimon Schubert   unsigned int allow_multiple_definition: 1;
2695796c8dcSSimon Schubert 
2705796c8dcSSimon Schubert   /* TRUE if ok to have version with no definition.  */
2715796c8dcSSimon Schubert   unsigned int allow_undefined_version: 1;
2725796c8dcSSimon Schubert 
2735796c8dcSSimon Schubert   /* TRUE if a default symbol version should be created and used for
2745796c8dcSSimon Schubert      exported symbols.  */
2755796c8dcSSimon Schubert   unsigned int create_default_symver: 1;
2765796c8dcSSimon Schubert 
2775796c8dcSSimon Schubert   /* TRUE if a default symbol version should be created and used for
2785796c8dcSSimon Schubert      imported symbols.  */
2795796c8dcSSimon Schubert   unsigned int default_imported_symver: 1;
2805796c8dcSSimon Schubert 
2815796c8dcSSimon Schubert   /* TRUE if symbols should be retained in memory, FALSE if they
2825796c8dcSSimon Schubert      should be freed and reread.  */
2835796c8dcSSimon Schubert   unsigned int keep_memory: 1;
2845796c8dcSSimon Schubert 
2855796c8dcSSimon Schubert   /* TRUE if every symbol should be reported back via the notice
2865796c8dcSSimon Schubert      callback.  */
2875796c8dcSSimon Schubert   unsigned int notice_all: 1;
2885796c8dcSSimon Schubert 
2895796c8dcSSimon Schubert   /* TRUE if executable should not contain copy relocs.
2905796c8dcSSimon Schubert      Setting this true may result in a non-sharable text segment.  */
2915796c8dcSSimon Schubert   unsigned int nocopyreloc: 1;
2925796c8dcSSimon Schubert 
2935796c8dcSSimon Schubert   /* TRUE if the new ELF dynamic tags are enabled. */
2945796c8dcSSimon Schubert   unsigned int new_dtags: 1;
2955796c8dcSSimon Schubert 
2965796c8dcSSimon Schubert   /* TRUE if non-PLT relocs should be merged into one reloc section
2975796c8dcSSimon Schubert      and sorted so that relocs against the same symbol come together.  */
2985796c8dcSSimon Schubert   unsigned int combreloc: 1;
2995796c8dcSSimon Schubert 
3005796c8dcSSimon Schubert   /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment
3015796c8dcSSimon Schubert      should be created.  */
3025796c8dcSSimon Schubert   unsigned int eh_frame_hdr: 1;
3035796c8dcSSimon Schubert 
3045796c8dcSSimon Schubert   /* TRUE if global symbols in discarded sections should be stripped.  */
3055796c8dcSSimon Schubert   unsigned int strip_discarded: 1;
3065796c8dcSSimon Schubert 
3075796c8dcSSimon Schubert   /* TRUE if generating a position independent executable.  */
3085796c8dcSSimon Schubert   unsigned int pie: 1;
3095796c8dcSSimon Schubert 
3105796c8dcSSimon Schubert   /* TRUE if generating an executable, position independent or not.  */
3115796c8dcSSimon Schubert   unsigned int executable : 1;
3125796c8dcSSimon Schubert 
3135796c8dcSSimon Schubert   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X
3145796c8dcSSimon Schubert      flags.  */
3155796c8dcSSimon Schubert   unsigned int execstack: 1;
3165796c8dcSSimon Schubert 
3175796c8dcSSimon Schubert   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W
3185796c8dcSSimon Schubert      flags.  */
3195796c8dcSSimon Schubert   unsigned int noexecstack: 1;
3205796c8dcSSimon Schubert 
3215796c8dcSSimon Schubert   /* TRUE if PT_GNU_RELRO segment should be created.  */
3225796c8dcSSimon Schubert   unsigned int relro: 1;
3235796c8dcSSimon Schubert 
3245796c8dcSSimon Schubert   /* TRUE if we should warn when adding a DT_TEXTREL to a shared object.  */
3255796c8dcSSimon Schubert   unsigned int warn_shared_textrel: 1;
3265796c8dcSSimon Schubert 
3275796c8dcSSimon Schubert   /* TRUE if we should warn alternate ELF machine code.  */
3285796c8dcSSimon Schubert   unsigned int warn_alternate_em: 1;
3295796c8dcSSimon Schubert 
3305796c8dcSSimon Schubert   /* TRUE if unreferenced sections should be removed.  */
3315796c8dcSSimon Schubert   unsigned int gc_sections: 1;
3325796c8dcSSimon Schubert 
3335796c8dcSSimon Schubert   /* TRUE if user shoudl be informed of removed unreferenced sections.  */
3345796c8dcSSimon Schubert   unsigned int print_gc_sections: 1;
3355796c8dcSSimon Schubert 
3365796c8dcSSimon Schubert   /* TRUE if .hash section should be created.  */
3375796c8dcSSimon Schubert   unsigned int emit_hash: 1;
3385796c8dcSSimon Schubert 
3395796c8dcSSimon Schubert   /* TRUE if .gnu.hash section should be created.  */
3405796c8dcSSimon Schubert   unsigned int emit_gnu_hash: 1;
3415796c8dcSSimon Schubert 
3425796c8dcSSimon Schubert   /* If TRUE reduce memory overheads, at the expense of speed. This will
3435796c8dcSSimon Schubert      cause map file generation to use an O(N^2) algorithm and disable
3445796c8dcSSimon Schubert      caching ELF symbol buffer.  */
3455796c8dcSSimon Schubert   unsigned int reduce_memory_overheads: 1;
3465796c8dcSSimon Schubert 
3475796c8dcSSimon Schubert   /* TRUE if all data symbols should be dynamic.  */
3485796c8dcSSimon Schubert    unsigned int dynamic_data: 1;
3495796c8dcSSimon Schubert 
3505796c8dcSSimon Schubert   /* TRUE if some symbols have to be dynamic, controlled by
3515796c8dcSSimon Schubert      --dynamic-list command line options.  */
3525796c8dcSSimon Schubert   unsigned int dynamic: 1;
3535796c8dcSSimon Schubert 
3545796c8dcSSimon Schubert   /* Non-NULL if .note.gnu.build-id section should be created.  */
3555796c8dcSSimon Schubert   char *emit_note_gnu_build_id;
3565796c8dcSSimon Schubert 
3575796c8dcSSimon Schubert   /* What to do with unresolved symbols in an object file.
3585796c8dcSSimon Schubert      When producing executables the default is GENERATE_ERROR.
3595796c8dcSSimon Schubert      When producing shared libraries the default is IGNORE.  The
3605796c8dcSSimon Schubert      assumption with shared libraries is that the reference will be
3615796c8dcSSimon Schubert      resolved at load/execution time.  */
3625796c8dcSSimon Schubert   enum report_method unresolved_syms_in_objects;
3635796c8dcSSimon Schubert 
3645796c8dcSSimon Schubert   /* What to do with unresolved symbols in a shared library.
3655796c8dcSSimon Schubert      The same defaults apply.  */
3665796c8dcSSimon Schubert   enum report_method unresolved_syms_in_shared_libs;
3675796c8dcSSimon Schubert 
3685796c8dcSSimon Schubert   /* Which symbols to strip.  */
3695796c8dcSSimon Schubert   enum bfd_link_strip strip;
3705796c8dcSSimon Schubert 
3715796c8dcSSimon Schubert   /* Which local symbols to discard.  */
3725796c8dcSSimon Schubert   enum bfd_link_discard discard;
3735796c8dcSSimon Schubert 
374cf7f2e2dSJohn Marino   /* Criteria for skipping symbols when determining
3755796c8dcSSimon Schubert      whether to include an object from an archive. */
376cf7f2e2dSJohn Marino   enum bfd_link_common_skip_ar_symbols common_skip_ar_symbols;
3775796c8dcSSimon Schubert 
3785796c8dcSSimon Schubert   /* Char that may appear as the first char of a symbol, but should be
3795796c8dcSSimon Schubert      skipped (like symbol_leading_char) when looking up symbols in
3805796c8dcSSimon Schubert      wrap_hash.  Used by PowerPC Linux for 'dot' symbols.  */
3815796c8dcSSimon Schubert   char wrap_char;
3825796c8dcSSimon Schubert 
3835796c8dcSSimon Schubert   /* Separator between archive and filename in linker script filespecs.  */
3845796c8dcSSimon Schubert   char path_separator;
3855796c8dcSSimon Schubert 
3865796c8dcSSimon Schubert   /* Function callbacks.  */
3875796c8dcSSimon Schubert   const struct bfd_link_callbacks *callbacks;
3885796c8dcSSimon Schubert 
3895796c8dcSSimon Schubert   /* Hash table handled by BFD.  */
3905796c8dcSSimon Schubert   struct bfd_link_hash_table *hash;
3915796c8dcSSimon Schubert 
3925796c8dcSSimon Schubert   /* Hash table of symbols to keep.  This is NULL unless strip is
3935796c8dcSSimon Schubert      strip_some.  */
3945796c8dcSSimon Schubert   struct bfd_hash_table *keep_hash;
3955796c8dcSSimon Schubert 
3965796c8dcSSimon Schubert   /* Hash table of symbols to report back via the notice callback.  If
3975796c8dcSSimon Schubert      this is NULL, and notice_all is FALSE, then no symbols are
3985796c8dcSSimon Schubert      reported back.  */
3995796c8dcSSimon Schubert   struct bfd_hash_table *notice_hash;
4005796c8dcSSimon Schubert 
4015796c8dcSSimon Schubert   /* Hash table of symbols which are being wrapped (the --wrap linker
4025796c8dcSSimon Schubert      option).  If this is NULL, no symbols are being wrapped.  */
4035796c8dcSSimon Schubert   struct bfd_hash_table *wrap_hash;
4045796c8dcSSimon Schubert 
4055796c8dcSSimon Schubert   /* The output BFD.  */
4065796c8dcSSimon Schubert   bfd *output_bfd;
4075796c8dcSSimon Schubert 
4085796c8dcSSimon Schubert   /* The list of input BFD's involved in the link.  These are chained
4095796c8dcSSimon Schubert      together via the link_next field.  */
4105796c8dcSSimon Schubert   bfd *input_bfds;
4115796c8dcSSimon Schubert   bfd **input_bfds_tail;
4125796c8dcSSimon Schubert 
4135796c8dcSSimon Schubert   /* If a symbol should be created for each input BFD, this is section
4145796c8dcSSimon Schubert      where those symbols should be placed.  It must be a section in
4155796c8dcSSimon Schubert      the output BFD.  It may be NULL, in which case no such symbols
4165796c8dcSSimon Schubert      will be created.  This is to support CREATE_OBJECT_SYMBOLS in the
4175796c8dcSSimon Schubert      linker command language.  */
4185796c8dcSSimon Schubert   asection *create_object_symbols_section;
4195796c8dcSSimon Schubert 
4205796c8dcSSimon Schubert   /* List of global symbol names that are starting points for marking
4215796c8dcSSimon Schubert      sections against garbage collection.  */
4225796c8dcSSimon Schubert   struct bfd_sym_chain *gc_sym_list;
4235796c8dcSSimon Schubert 
4245796c8dcSSimon Schubert   /* If a base output file is wanted, then this points to it */
4255796c8dcSSimon Schubert   void *base_file;
4265796c8dcSSimon Schubert 
4275796c8dcSSimon Schubert   /* The function to call when the executable or shared object is
4285796c8dcSSimon Schubert      loaded.  */
4295796c8dcSSimon Schubert   const char *init_function;
4305796c8dcSSimon Schubert 
4315796c8dcSSimon Schubert   /* The function to call when the executable or shared object is
4325796c8dcSSimon Schubert      unloaded.  */
4335796c8dcSSimon Schubert   const char *fini_function;
4345796c8dcSSimon Schubert 
4355796c8dcSSimon Schubert   /* Number of relaxation passes.  Usually only one relaxation pass
4365796c8dcSSimon Schubert      is needed.  But a backend can have as many relaxation passes as
4375796c8dcSSimon Schubert      necessary.  During bfd_relax_section call, it is set to the
4385796c8dcSSimon Schubert      current pass, starting from 0.  */
4395796c8dcSSimon Schubert   int relax_pass;
4405796c8dcSSimon Schubert 
4415796c8dcSSimon Schubert   /* Number of relaxation trips.  This number is incremented every
4425796c8dcSSimon Schubert      time the relaxation pass is restarted due to a previous
4435796c8dcSSimon Schubert      relaxation returning true in *AGAIN.  */
4445796c8dcSSimon Schubert   int relax_trip;
4455796c8dcSSimon Schubert 
4465796c8dcSSimon Schubert   /* Non-zero if auto-import thunks for DATA items in pei386 DLLs
4475796c8dcSSimon Schubert      should be generated/linked against.  Set to 1 if this feature
4485796c8dcSSimon Schubert      is explicitly requested by the user, -1 if enabled by default.  */
4495796c8dcSSimon Schubert   int pei386_auto_import;
4505796c8dcSSimon Schubert 
4515796c8dcSSimon Schubert   /* Non-zero if runtime relocs for DATA items with non-zero addends
4525796c8dcSSimon Schubert      in pei386 DLLs should be generated.  Set to 1 if this feature
4535796c8dcSSimon Schubert      is explicitly requested by the user, -1 if enabled by default.  */
4545796c8dcSSimon Schubert   int pei386_runtime_pseudo_reloc;
4555796c8dcSSimon Schubert 
4565796c8dcSSimon Schubert   /* How many spare .dynamic DT_NULL entries should be added?  */
4575796c8dcSSimon Schubert   unsigned int spare_dynamic_tags;
4585796c8dcSSimon Schubert 
4595796c8dcSSimon Schubert   /* May be used to set DT_FLAGS for ELF. */
4605796c8dcSSimon Schubert   bfd_vma flags;
4615796c8dcSSimon Schubert 
4625796c8dcSSimon Schubert   /* May be used to set DT_FLAGS_1 for ELF. */
4635796c8dcSSimon Schubert   bfd_vma flags_1;
4645796c8dcSSimon Schubert 
4655796c8dcSSimon Schubert   /* Start and end of RELRO region.  */
4665796c8dcSSimon Schubert   bfd_vma relro_start, relro_end;
4675796c8dcSSimon Schubert 
4685796c8dcSSimon Schubert   /* List of symbols should be dynamic.  */
4695796c8dcSSimon Schubert   struct bfd_elf_dynamic_list *dynamic_list;
4705796c8dcSSimon Schubert };
4715796c8dcSSimon Schubert 
4725796c8dcSSimon Schubert /* This structures holds a set of callback functions.  These are called
4735796c8dcSSimon Schubert    by the BFD linker routines.  Except for the info functions, the first
4745796c8dcSSimon Schubert    argument to each callback function is the bfd_link_info structure
4755796c8dcSSimon Schubert    being used and each function returns a boolean value.  If the
4765796c8dcSSimon Schubert    function returns FALSE, then the BFD function which called it should
4775796c8dcSSimon Schubert    return with a failure indication.  */
4785796c8dcSSimon Schubert 
4795796c8dcSSimon Schubert struct bfd_link_callbacks
4805796c8dcSSimon Schubert {
4815796c8dcSSimon Schubert   /* A function which is called when an object is added from an
4825796c8dcSSimon Schubert      archive.  ABFD is the archive element being added.  NAME is the
4835796c8dcSSimon Schubert      name of the symbol which caused the archive element to be pulled
484*c50c785cSJohn Marino      in.  This function may set *SUBSBFD to point to an alternative
485*c50c785cSJohn Marino      BFD from which symbols should in fact be added in place of the
486*c50c785cSJohn Marino      original BFD's symbols.  */
4875796c8dcSSimon Schubert   bfd_boolean (*add_archive_element)
488*c50c785cSJohn Marino     (struct bfd_link_info *, bfd *abfd, const char *name, bfd **subsbfd);
4895796c8dcSSimon Schubert   /* A function which is called when a symbol is found with multiple
4905796c8dcSSimon Schubert      definitions.  NAME is the symbol which is defined multiple times.
4915796c8dcSSimon Schubert      OBFD is the old BFD, OSEC is the old section, OVAL is the old
4925796c8dcSSimon Schubert      value, NBFD is the new BFD, NSEC is the new section, and NVAL is
4935796c8dcSSimon Schubert      the new value.  OBFD may be NULL.  OSEC and NSEC may be
4945796c8dcSSimon Schubert      bfd_com_section or bfd_ind_section.  */
4955796c8dcSSimon Schubert   bfd_boolean (*multiple_definition)
4965796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
4975796c8dcSSimon Schubert      bfd *obfd, asection *osec, bfd_vma oval,
4985796c8dcSSimon Schubert      bfd *nbfd, asection *nsec, bfd_vma nval);
4995796c8dcSSimon Schubert   /* A function which is called when a common symbol is defined
5005796c8dcSSimon Schubert      multiple times.  NAME is the symbol appearing multiple times.
5015796c8dcSSimon Schubert      OBFD is the BFD of the existing symbol; it may be NULL if this is
5025796c8dcSSimon Schubert      not known.  OTYPE is the type of the existing symbol, which may
5035796c8dcSSimon Schubert      be bfd_link_hash_defined, bfd_link_hash_defweak,
5045796c8dcSSimon Schubert      bfd_link_hash_common, or bfd_link_hash_indirect.  If OTYPE is
5055796c8dcSSimon Schubert      bfd_link_hash_common, OSIZE is the size of the existing symbol.
5065796c8dcSSimon Schubert      NBFD is the BFD of the new symbol.  NTYPE is the type of the new
5075796c8dcSSimon Schubert      symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or
5085796c8dcSSimon Schubert      bfd_link_hash_indirect.  If NTYPE is bfd_link_hash_common, NSIZE
5095796c8dcSSimon Schubert      is the size of the new symbol.  */
5105796c8dcSSimon Schubert   bfd_boolean (*multiple_common)
5115796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
5125796c8dcSSimon Schubert      bfd *obfd, enum bfd_link_hash_type otype, bfd_vma osize,
5135796c8dcSSimon Schubert      bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize);
5145796c8dcSSimon Schubert   /* A function which is called to add a symbol to a set.  ENTRY is
5155796c8dcSSimon Schubert      the link hash table entry for the set itself (e.g.,
5165796c8dcSSimon Schubert      __CTOR_LIST__).  RELOC is the relocation to use for an entry in
5175796c8dcSSimon Schubert      the set when generating a relocatable file, and is also used to
5185796c8dcSSimon Schubert      get the size of the entry when generating an executable file.
5195796c8dcSSimon Schubert      ABFD, SEC and VALUE identify the value to add to the set.  */
5205796c8dcSSimon Schubert   bfd_boolean (*add_to_set)
5215796c8dcSSimon Schubert     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
5225796c8dcSSimon Schubert      bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value);
5235796c8dcSSimon Schubert   /* A function which is called when the name of a g++ constructor or
5245796c8dcSSimon Schubert      destructor is found.  This is only called by some object file
5255796c8dcSSimon Schubert      formats.  CONSTRUCTOR is TRUE for a constructor, FALSE for a
5265796c8dcSSimon Schubert      destructor.  This will use BFD_RELOC_CTOR when generating a
5275796c8dcSSimon Schubert      relocatable file.  NAME is the name of the symbol found.  ABFD,
5285796c8dcSSimon Schubert      SECTION and VALUE are the value of the symbol.  */
5295796c8dcSSimon Schubert   bfd_boolean (*constructor)
5305796c8dcSSimon Schubert     (struct bfd_link_info *, bfd_boolean constructor, const char *name,
5315796c8dcSSimon Schubert      bfd *abfd, asection *sec, bfd_vma value);
5325796c8dcSSimon Schubert   /* A function which is called to issue a linker warning.  For
5335796c8dcSSimon Schubert      example, this is called when there is a reference to a warning
5345796c8dcSSimon Schubert      symbol.  WARNING is the warning to be issued.  SYMBOL is the name
5355796c8dcSSimon Schubert      of the symbol which triggered the warning; it may be NULL if
5365796c8dcSSimon Schubert      there is none.  ABFD, SECTION and ADDRESS identify the location
5375796c8dcSSimon Schubert      which trigerred the warning; either ABFD or SECTION or both may
5385796c8dcSSimon Schubert      be NULL if the location is not known.  */
5395796c8dcSSimon Schubert   bfd_boolean (*warning)
5405796c8dcSSimon Schubert     (struct bfd_link_info *, const char *warning, const char *symbol,
5415796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
5425796c8dcSSimon Schubert   /* A function which is called when a relocation is attempted against
5435796c8dcSSimon Schubert      an undefined symbol.  NAME is the symbol which is undefined.
5445796c8dcSSimon Schubert      ABFD, SECTION and ADDRESS identify the location from which the
545cf7f2e2dSJohn Marino      reference is made. IS_FATAL indicates whether an undefined symbol is
5465796c8dcSSimon Schubert      a fatal error or not. In some cases SECTION may be NULL.  */
5475796c8dcSSimon Schubert   bfd_boolean (*undefined_symbol)
5485796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name, bfd *abfd,
549cf7f2e2dSJohn Marino      asection *section, bfd_vma address, bfd_boolean is_fatal);
5505796c8dcSSimon Schubert   /* A function which is called when a reloc overflow occurs. ENTRY is
5515796c8dcSSimon Schubert      the link hash table entry for the symbol the reloc is against.
5525796c8dcSSimon Schubert      NAME is the name of the local symbol or section the reloc is
5535796c8dcSSimon Schubert      against, RELOC_NAME is the name of the relocation, and ADDEND is
5545796c8dcSSimon Schubert      any addend that is used.  ABFD, SECTION and ADDRESS identify the
5555796c8dcSSimon Schubert      location at which the overflow occurs; if this is the result of a
5565796c8dcSSimon Schubert      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
5575796c8dcSSimon Schubert      ABFD will be NULL.  */
5585796c8dcSSimon Schubert   bfd_boolean (*reloc_overflow)
5595796c8dcSSimon Schubert     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
5605796c8dcSSimon Schubert      const char *name, const char *reloc_name, bfd_vma addend,
5615796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
5625796c8dcSSimon Schubert   /* A function which is called when a dangerous reloc is performed.
5635796c8dcSSimon Schubert      MESSAGE is an appropriate message.
5645796c8dcSSimon Schubert      ABFD, SECTION and ADDRESS identify the location at which the
5655796c8dcSSimon Schubert      problem occurred; if this is the result of a
5665796c8dcSSimon Schubert      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
5675796c8dcSSimon Schubert      ABFD will be NULL.  */
5685796c8dcSSimon Schubert   bfd_boolean (*reloc_dangerous)
5695796c8dcSSimon Schubert     (struct bfd_link_info *, const char *message,
5705796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
5715796c8dcSSimon Schubert   /* A function which is called when a reloc is found to be attached
5725796c8dcSSimon Schubert      to a symbol which is not being written out.  NAME is the name of
5735796c8dcSSimon Schubert      the symbol.  ABFD, SECTION and ADDRESS identify the location of
5745796c8dcSSimon Schubert      the reloc; if this is the result of a
5755796c8dcSSimon Schubert      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
5765796c8dcSSimon Schubert      ABFD will be NULL.  */
5775796c8dcSSimon Schubert   bfd_boolean (*unattached_reloc)
5785796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
5795796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
5805796c8dcSSimon Schubert   /* A function which is called when a symbol in notice_hash is
5815796c8dcSSimon Schubert      defined or referenced.  NAME is the symbol.  ABFD, SECTION and
5825796c8dcSSimon Schubert      ADDRESS are the value of the symbol.  If SECTION is
5835796c8dcSSimon Schubert      bfd_und_section, this is a reference.  */
5845796c8dcSSimon Schubert   bfd_boolean (*notice)
5855796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
5865796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
5875796c8dcSSimon Schubert   /* Error or warning link info message.  */
5885796c8dcSSimon Schubert   void (*einfo)
5895796c8dcSSimon Schubert     (const char *fmt, ...);
5905796c8dcSSimon Schubert   /* General link info message.  */
5915796c8dcSSimon Schubert   void (*info)
5925796c8dcSSimon Schubert     (const char *fmt, ...);
5935796c8dcSSimon Schubert   /* Message to be printed in linker map file.  */
5945796c8dcSSimon Schubert   void (*minfo)
5955796c8dcSSimon Schubert     (const char *fmt, ...);
5965796c8dcSSimon Schubert   /* This callback provides a chance for users of the BFD library to
5975796c8dcSSimon Schubert      override its decision about whether to place two adjacent sections
5985796c8dcSSimon Schubert      into the same segment.  */
5995796c8dcSSimon Schubert   bfd_boolean (*override_segment_assignment)
6005796c8dcSSimon Schubert     (struct bfd_link_info *, bfd * abfd,
6015796c8dcSSimon Schubert      asection * current_section, asection * previous_section,
6025796c8dcSSimon Schubert      bfd_boolean new_segment);
6035796c8dcSSimon Schubert };
6045796c8dcSSimon Schubert 
6055796c8dcSSimon Schubert /* The linker builds link_order structures which tell the code how to
6065796c8dcSSimon Schubert    include input data in the output file.  */
6075796c8dcSSimon Schubert 
6085796c8dcSSimon Schubert /* These are the types of link_order structures.  */
6095796c8dcSSimon Schubert 
6105796c8dcSSimon Schubert enum bfd_link_order_type
6115796c8dcSSimon Schubert {
6125796c8dcSSimon Schubert   bfd_undefined_link_order,	/* Undefined.  */
6135796c8dcSSimon Schubert   bfd_indirect_link_order,	/* Built from a section.  */
6145796c8dcSSimon Schubert   bfd_data_link_order,		/* Set to explicit data.  */
6155796c8dcSSimon Schubert   bfd_section_reloc_link_order,	/* Relocate against a section.  */
6165796c8dcSSimon Schubert   bfd_symbol_reloc_link_order	/* Relocate against a symbol.  */
6175796c8dcSSimon Schubert };
6185796c8dcSSimon Schubert 
6195796c8dcSSimon Schubert /* This is the link_order structure itself.  These form a chain
6205796c8dcSSimon Schubert    attached to the output section whose contents they are describing.  */
6215796c8dcSSimon Schubert 
6225796c8dcSSimon Schubert struct bfd_link_order
6235796c8dcSSimon Schubert {
6245796c8dcSSimon Schubert   /* Next link_order in chain.  */
6255796c8dcSSimon Schubert   struct bfd_link_order *next;
6265796c8dcSSimon Schubert   /* Type of link_order.  */
6275796c8dcSSimon Schubert   enum bfd_link_order_type type;
6285796c8dcSSimon Schubert   /* Offset within output section.  */
6295796c8dcSSimon Schubert   bfd_vma offset;
6305796c8dcSSimon Schubert   /* Size within output section.  */
6315796c8dcSSimon Schubert   bfd_size_type size;
6325796c8dcSSimon Schubert   /* Type specific information.  */
6335796c8dcSSimon Schubert   union
6345796c8dcSSimon Schubert     {
6355796c8dcSSimon Schubert       struct
6365796c8dcSSimon Schubert 	{
6375796c8dcSSimon Schubert 	  /* Section to include.  If this is used, then
6385796c8dcSSimon Schubert 	     section->output_section must be the section the
6395796c8dcSSimon Schubert 	     link_order is attached to, section->output_offset must
6405796c8dcSSimon Schubert 	     equal the link_order offset field, and section->size
6415796c8dcSSimon Schubert 	     must equal the link_order size field.  Maybe these
6425796c8dcSSimon Schubert 	     restrictions should be relaxed someday.  */
6435796c8dcSSimon Schubert 	  asection *section;
6445796c8dcSSimon Schubert 	} indirect;
6455796c8dcSSimon Schubert       struct
6465796c8dcSSimon Schubert 	{
6475796c8dcSSimon Schubert 	  /* Size of contents, or zero when contents size == size
6485796c8dcSSimon Schubert 	     within output section.
6495796c8dcSSimon Schubert 	     A non-zero value allows filling of the output section
6505796c8dcSSimon Schubert 	     with an arbitrary repeated pattern.  */
6515796c8dcSSimon Schubert 	  unsigned int size;
6525796c8dcSSimon Schubert 	  /* Data to put into file.  */
6535796c8dcSSimon Schubert 	  bfd_byte *contents;
6545796c8dcSSimon Schubert 	} data;
6555796c8dcSSimon Schubert       struct
6565796c8dcSSimon Schubert 	{
6575796c8dcSSimon Schubert 	  /* Description of reloc to generate.  Used for
6585796c8dcSSimon Schubert 	     bfd_section_reloc_link_order and
6595796c8dcSSimon Schubert 	     bfd_symbol_reloc_link_order.  */
6605796c8dcSSimon Schubert 	  struct bfd_link_order_reloc *p;
6615796c8dcSSimon Schubert 	} reloc;
6625796c8dcSSimon Schubert     } u;
6635796c8dcSSimon Schubert };
6645796c8dcSSimon Schubert 
6655796c8dcSSimon Schubert /* A linker order of type bfd_section_reloc_link_order or
6665796c8dcSSimon Schubert    bfd_symbol_reloc_link_order means to create a reloc against a
6675796c8dcSSimon Schubert    section or symbol, respectively.  This is used to implement -Ur to
6685796c8dcSSimon Schubert    generate relocs for the constructor tables.  The
6695796c8dcSSimon Schubert    bfd_link_order_reloc structure describes the reloc that BFD should
6705796c8dcSSimon Schubert    create.  It is similar to a arelent, but I didn't use arelent
6715796c8dcSSimon Schubert    because the linker does not know anything about most symbols, and
6725796c8dcSSimon Schubert    any asymbol structure it creates will be partially meaningless.
6735796c8dcSSimon Schubert    This information could logically be in the bfd_link_order struct,
6745796c8dcSSimon Schubert    but I didn't want to waste the space since these types of relocs
6755796c8dcSSimon Schubert    are relatively rare.  */
6765796c8dcSSimon Schubert 
6775796c8dcSSimon Schubert struct bfd_link_order_reloc
6785796c8dcSSimon Schubert {
6795796c8dcSSimon Schubert   /* Reloc type.  */
6805796c8dcSSimon Schubert   bfd_reloc_code_real_type reloc;
6815796c8dcSSimon Schubert 
6825796c8dcSSimon Schubert   union
6835796c8dcSSimon Schubert     {
6845796c8dcSSimon Schubert       /* For type bfd_section_reloc_link_order, this is the section
6855796c8dcSSimon Schubert 	 the reloc should be against.  This must be a section in the
6865796c8dcSSimon Schubert 	 output BFD, not any of the input BFDs.  */
6875796c8dcSSimon Schubert       asection *section;
6885796c8dcSSimon Schubert       /* For type bfd_symbol_reloc_link_order, this is the name of the
6895796c8dcSSimon Schubert 	 symbol the reloc should be against.  */
6905796c8dcSSimon Schubert       const char *name;
6915796c8dcSSimon Schubert     } u;
6925796c8dcSSimon Schubert 
6935796c8dcSSimon Schubert   /* Addend to use.  The object file should contain zero.  The BFD
6945796c8dcSSimon Schubert      backend is responsible for filling in the contents of the object
6955796c8dcSSimon Schubert      file correctly.  For some object file formats (e.g., COFF) the
6965796c8dcSSimon Schubert      addend must be stored into in the object file, and for some
6975796c8dcSSimon Schubert      (e.g., SPARC a.out) it is kept in the reloc.  */
6985796c8dcSSimon Schubert   bfd_vma addend;
6995796c8dcSSimon Schubert };
7005796c8dcSSimon Schubert 
7015796c8dcSSimon Schubert /* Allocate a new link_order for a section.  */
7025796c8dcSSimon Schubert extern struct bfd_link_order *bfd_new_link_order (bfd *, asection *);
7035796c8dcSSimon Schubert 
7045796c8dcSSimon Schubert /* These structures are used to describe version information for the
7055796c8dcSSimon Schubert    ELF linker.  These structures could be manipulated entirely inside
7065796c8dcSSimon Schubert    BFD, but it would be a pain.  Instead, the regular linker sets up
7075796c8dcSSimon Schubert    these structures, and then passes them into BFD.  */
7085796c8dcSSimon Schubert 
7095796c8dcSSimon Schubert /* Glob pattern for a version.  */
7105796c8dcSSimon Schubert 
7115796c8dcSSimon Schubert struct bfd_elf_version_expr
7125796c8dcSSimon Schubert {
7135796c8dcSSimon Schubert   /* Next glob pattern for this version.  */
7145796c8dcSSimon Schubert   struct bfd_elf_version_expr *next;
7155796c8dcSSimon Schubert   /* Glob pattern.  */
7165796c8dcSSimon Schubert   const char *pattern;
7175796c8dcSSimon Schubert   /* Set if pattern is not a glob.  */
7185796c8dcSSimon Schubert   unsigned int literal : 1;
7195796c8dcSSimon Schubert   /* Defined by ".symver".  */
7205796c8dcSSimon Schubert   unsigned int symver : 1;
7215796c8dcSSimon Schubert   /* Defined by version script.  */
7225796c8dcSSimon Schubert   unsigned int script : 1;
7235796c8dcSSimon Schubert   /* Pattern type.  */
7245796c8dcSSimon Schubert #define BFD_ELF_VERSION_C_TYPE		1
7255796c8dcSSimon Schubert #define BFD_ELF_VERSION_CXX_TYPE	2
7265796c8dcSSimon Schubert #define BFD_ELF_VERSION_JAVA_TYPE	4
7275796c8dcSSimon Schubert   unsigned int mask : 3;
7285796c8dcSSimon Schubert };
7295796c8dcSSimon Schubert 
7305796c8dcSSimon Schubert struct bfd_elf_version_expr_head
7315796c8dcSSimon Schubert {
7325796c8dcSSimon Schubert   /* List of all patterns, both wildcards and non-wildcards.  */
7335796c8dcSSimon Schubert   struct bfd_elf_version_expr *list;
7345796c8dcSSimon Schubert   /* Hash table for non-wildcards.  */
7355796c8dcSSimon Schubert   void *htab;
7365796c8dcSSimon Schubert   /* Remaining patterns.  */
7375796c8dcSSimon Schubert   struct bfd_elf_version_expr *remaining;
7385796c8dcSSimon Schubert   /* What kind of pattern types are present in list (bitmask).  */
7395796c8dcSSimon Schubert   unsigned int mask;
7405796c8dcSSimon Schubert };
7415796c8dcSSimon Schubert 
7425796c8dcSSimon Schubert /* Version dependencies.  */
7435796c8dcSSimon Schubert 
7445796c8dcSSimon Schubert struct bfd_elf_version_deps
7455796c8dcSSimon Schubert {
7465796c8dcSSimon Schubert   /* Next dependency for this version.  */
7475796c8dcSSimon Schubert   struct bfd_elf_version_deps *next;
7485796c8dcSSimon Schubert   /* The version which this version depends upon.  */
7495796c8dcSSimon Schubert   struct bfd_elf_version_tree *version_needed;
7505796c8dcSSimon Schubert };
7515796c8dcSSimon Schubert 
7525796c8dcSSimon Schubert /* A node in the version tree.  */
7535796c8dcSSimon Schubert 
7545796c8dcSSimon Schubert struct bfd_elf_version_tree
7555796c8dcSSimon Schubert {
7565796c8dcSSimon Schubert   /* Next version.  */
7575796c8dcSSimon Schubert   struct bfd_elf_version_tree *next;
7585796c8dcSSimon Schubert   /* Name of this version.  */
7595796c8dcSSimon Schubert   const char *name;
7605796c8dcSSimon Schubert   /* Version number.  */
7615796c8dcSSimon Schubert   unsigned int vernum;
7625796c8dcSSimon Schubert   /* Regular expressions for global symbols in this version.  */
7635796c8dcSSimon Schubert   struct bfd_elf_version_expr_head globals;
7645796c8dcSSimon Schubert   /* Regular expressions for local symbols in this version.  */
7655796c8dcSSimon Schubert   struct bfd_elf_version_expr_head locals;
7665796c8dcSSimon Schubert   /* List of versions which this version depends upon.  */
7675796c8dcSSimon Schubert   struct bfd_elf_version_deps *deps;
7685796c8dcSSimon Schubert   /* Index of the version name.  This is used within BFD.  */
7695796c8dcSSimon Schubert   unsigned int name_indx;
7705796c8dcSSimon Schubert   /* Whether this version tree was used.  This is used within BFD.  */
7715796c8dcSSimon Schubert   int used;
7725796c8dcSSimon Schubert   /* Matching hook.  */
7735796c8dcSSimon Schubert   struct bfd_elf_version_expr *(*match)
7745796c8dcSSimon Schubert     (struct bfd_elf_version_expr_head *head,
7755796c8dcSSimon Schubert      struct bfd_elf_version_expr *prev, const char *sym);
7765796c8dcSSimon Schubert };
7775796c8dcSSimon Schubert 
7785796c8dcSSimon Schubert struct bfd_elf_dynamic_list
7795796c8dcSSimon Schubert {
7805796c8dcSSimon Schubert   struct bfd_elf_version_expr_head head;
7815796c8dcSSimon Schubert   struct bfd_elf_version_expr *(*match)
7825796c8dcSSimon Schubert     (struct bfd_elf_version_expr_head *head,
7835796c8dcSSimon Schubert      struct bfd_elf_version_expr *prev, const char *sym);
7845796c8dcSSimon Schubert };
7855796c8dcSSimon Schubert 
7865796c8dcSSimon Schubert #endif
787