15796c8dcSSimon Schubert /* bfdlink.h -- header file for BFD link routines 25796c8dcSSimon Schubert Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 3a45ae5f8SJohn Marino 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 4a45ae5f8SJohn Marino Free Software Foundation, Inc. 55796c8dcSSimon Schubert Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This file is part of BFD, the Binary File Descriptor library. 85796c8dcSSimon Schubert 95796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 105796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 115796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 125796c8dcSSimon Schubert (at your option) any later version. 135796c8dcSSimon Schubert 145796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 155796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 165796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175796c8dcSSimon Schubert GNU General Public License for more details. 185796c8dcSSimon Schubert 195796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 205796c8dcSSimon Schubert along with this program; if not, write to the Free Software 215796c8dcSSimon Schubert Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 225796c8dcSSimon Schubert MA 02110-1301, USA. */ 235796c8dcSSimon Schubert 245796c8dcSSimon Schubert #ifndef BFDLINK_H 255796c8dcSSimon Schubert #define BFDLINK_H 265796c8dcSSimon Schubert 275796c8dcSSimon Schubert /* Which symbols to strip during a link. */ 285796c8dcSSimon Schubert enum bfd_link_strip 295796c8dcSSimon Schubert { 305796c8dcSSimon Schubert strip_none, /* Don't strip any symbols. */ 315796c8dcSSimon Schubert strip_debugger, /* Strip debugging symbols. */ 325796c8dcSSimon Schubert strip_some, /* keep_hash is the list of symbols to keep. */ 335796c8dcSSimon Schubert strip_all /* Strip all symbols. */ 345796c8dcSSimon Schubert }; 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert /* Which local symbols to discard during a link. This is irrelevant 375796c8dcSSimon Schubert if strip_all is used. */ 385796c8dcSSimon Schubert enum bfd_link_discard 395796c8dcSSimon Schubert { 405796c8dcSSimon Schubert discard_sec_merge, /* Discard local temporary symbols in SEC_MERGE 415796c8dcSSimon Schubert sections. */ 425796c8dcSSimon Schubert discard_none, /* Don't discard any locals. */ 435796c8dcSSimon Schubert discard_l, /* Discard local temporary symbols. */ 445796c8dcSSimon Schubert discard_all /* Discard all locals. */ 455796c8dcSSimon Schubert }; 465796c8dcSSimon Schubert 475796c8dcSSimon Schubert /* Describes the type of hash table entry structure being used. 485796c8dcSSimon Schubert Different hash table structure have different fields and so 495796c8dcSSimon Schubert support different linking features. */ 505796c8dcSSimon Schubert enum bfd_link_hash_table_type 515796c8dcSSimon Schubert { 525796c8dcSSimon Schubert bfd_link_generic_hash_table, 535796c8dcSSimon Schubert bfd_link_elf_hash_table 545796c8dcSSimon Schubert }; 555796c8dcSSimon Schubert 565796c8dcSSimon Schubert /* These are the possible types of an entry in the BFD link hash 575796c8dcSSimon Schubert table. */ 585796c8dcSSimon Schubert 595796c8dcSSimon Schubert enum bfd_link_hash_type 605796c8dcSSimon Schubert { 615796c8dcSSimon Schubert bfd_link_hash_new, /* Symbol is new. */ 625796c8dcSSimon Schubert bfd_link_hash_undefined, /* Symbol seen before, but undefined. */ 635796c8dcSSimon Schubert bfd_link_hash_undefweak, /* Symbol is weak and undefined. */ 645796c8dcSSimon Schubert bfd_link_hash_defined, /* Symbol is defined. */ 655796c8dcSSimon Schubert bfd_link_hash_defweak, /* Symbol is weak and defined. */ 665796c8dcSSimon Schubert bfd_link_hash_common, /* Symbol is common. */ 675796c8dcSSimon Schubert bfd_link_hash_indirect, /* Symbol is an indirect link. */ 685796c8dcSSimon Schubert bfd_link_hash_warning /* Like indirect, but warn if referenced. */ 695796c8dcSSimon Schubert }; 705796c8dcSSimon Schubert 71cf7f2e2dSJohn Marino enum bfd_link_common_skip_ar_symbols 725796c8dcSSimon Schubert { 735796c8dcSSimon Schubert bfd_link_common_skip_none, 745796c8dcSSimon Schubert bfd_link_common_skip_text, 755796c8dcSSimon Schubert bfd_link_common_skip_data, 765796c8dcSSimon Schubert bfd_link_common_skip_all 775796c8dcSSimon Schubert }; 785796c8dcSSimon Schubert 795796c8dcSSimon Schubert struct bfd_link_hash_common_entry 805796c8dcSSimon Schubert { 815796c8dcSSimon Schubert unsigned int alignment_power; /* Alignment. */ 825796c8dcSSimon Schubert asection *section; /* Symbol section. */ 835796c8dcSSimon Schubert }; 845796c8dcSSimon Schubert 855796c8dcSSimon Schubert /* The linking routines use a hash table which uses this structure for 865796c8dcSSimon Schubert its elements. */ 875796c8dcSSimon Schubert 885796c8dcSSimon Schubert struct bfd_link_hash_entry 895796c8dcSSimon Schubert { 905796c8dcSSimon Schubert /* Base hash table entry structure. */ 915796c8dcSSimon Schubert struct bfd_hash_entry root; 925796c8dcSSimon Schubert 935796c8dcSSimon Schubert /* Type of this entry. */ 94a45ae5f8SJohn Marino ENUM_BITFIELD (bfd_link_hash_type) type : 8; 95a45ae5f8SJohn Marino 96a45ae5f8SJohn Marino unsigned int non_ir_ref : 1; 975796c8dcSSimon Schubert 985796c8dcSSimon Schubert /* A union of information depending upon the type. */ 995796c8dcSSimon Schubert union 1005796c8dcSSimon Schubert { 1015796c8dcSSimon Schubert /* Nothing is kept for bfd_hash_new. */ 1025796c8dcSSimon Schubert /* bfd_link_hash_undefined, bfd_link_hash_undefweak. */ 1035796c8dcSSimon Schubert struct 1045796c8dcSSimon Schubert { 1055796c8dcSSimon Schubert /* Undefined and common symbols are kept in a linked list through 1065796c8dcSSimon Schubert this field. This field is present in all of the union element 1075796c8dcSSimon Schubert so that we don't need to remove entries from the list when we 1085796c8dcSSimon Schubert change their type. Removing entries would either require the 1095796c8dcSSimon Schubert list to be doubly linked, which would waste more memory, or 1105796c8dcSSimon Schubert require a traversal. When an undefined or common symbol is 1115796c8dcSSimon Schubert created, it should be added to this list, the head of which is in 1125796c8dcSSimon Schubert the link hash table itself. As symbols are defined, they need 1135796c8dcSSimon Schubert not be removed from the list; anything which reads the list must 1145796c8dcSSimon Schubert doublecheck the symbol type. 1155796c8dcSSimon Schubert 1165796c8dcSSimon Schubert Weak symbols are not kept on this list. 1175796c8dcSSimon Schubert 1185796c8dcSSimon Schubert Defined and defweak symbols use this field as a reference marker. 1195796c8dcSSimon Schubert If the field is not NULL, or this structure is the tail of the 1205796c8dcSSimon Schubert undefined symbol list, the symbol has been referenced. If the 1215796c8dcSSimon Schubert symbol is undefined and becomes defined, this field will 1225796c8dcSSimon Schubert automatically be non-NULL since the symbol will have been on the 1235796c8dcSSimon Schubert undefined symbol list. */ 1245796c8dcSSimon Schubert struct bfd_link_hash_entry *next; 1255796c8dcSSimon Schubert bfd *abfd; /* BFD symbol was found in. */ 1265796c8dcSSimon Schubert } undef; 1275796c8dcSSimon Schubert /* bfd_link_hash_defined, bfd_link_hash_defweak. */ 1285796c8dcSSimon Schubert struct 1295796c8dcSSimon Schubert { 1305796c8dcSSimon Schubert struct bfd_link_hash_entry *next; 1315796c8dcSSimon Schubert asection *section; /* Symbol section. */ 1325796c8dcSSimon Schubert bfd_vma value; /* Symbol value. */ 1335796c8dcSSimon Schubert } def; 1345796c8dcSSimon Schubert /* bfd_link_hash_indirect, bfd_link_hash_warning. */ 1355796c8dcSSimon Schubert struct 1365796c8dcSSimon Schubert { 1375796c8dcSSimon Schubert struct bfd_link_hash_entry *next; 1385796c8dcSSimon Schubert struct bfd_link_hash_entry *link; /* Real symbol. */ 1395796c8dcSSimon Schubert const char *warning; /* Warning (bfd_link_hash_warning only). */ 1405796c8dcSSimon Schubert } i; 1415796c8dcSSimon Schubert /* bfd_link_hash_common. */ 1425796c8dcSSimon Schubert struct 1435796c8dcSSimon Schubert { 1445796c8dcSSimon Schubert struct bfd_link_hash_entry *next; 1455796c8dcSSimon Schubert /* The linker needs to know three things about common 1465796c8dcSSimon Schubert symbols: the size, the alignment, and the section in 1475796c8dcSSimon Schubert which the symbol should be placed. We store the size 1485796c8dcSSimon Schubert here, and we allocate a small structure to hold the 1495796c8dcSSimon Schubert section and the alignment. The alignment is stored as a 1505796c8dcSSimon Schubert power of two. We don't store all the information 1515796c8dcSSimon Schubert directly because we don't want to increase the size of 1525796c8dcSSimon Schubert the union; this structure is a major space user in the 1535796c8dcSSimon Schubert linker. */ 1545796c8dcSSimon Schubert struct bfd_link_hash_common_entry *p; 1555796c8dcSSimon Schubert bfd_size_type size; /* Common symbol size. */ 1565796c8dcSSimon Schubert } c; 1575796c8dcSSimon Schubert } u; 1585796c8dcSSimon Schubert }; 1595796c8dcSSimon Schubert 1605796c8dcSSimon Schubert /* This is the link hash table. It is a derived class of 1615796c8dcSSimon Schubert bfd_hash_table. */ 1625796c8dcSSimon Schubert 1635796c8dcSSimon Schubert struct bfd_link_hash_table 1645796c8dcSSimon Schubert { 1655796c8dcSSimon Schubert /* The hash table itself. */ 1665796c8dcSSimon Schubert struct bfd_hash_table table; 1675796c8dcSSimon Schubert /* A linked list of undefined and common symbols, linked through the 1685796c8dcSSimon Schubert next field in the bfd_link_hash_entry structure. */ 1695796c8dcSSimon Schubert struct bfd_link_hash_entry *undefs; 1705796c8dcSSimon Schubert /* Entries are added to the tail of the undefs list. */ 1715796c8dcSSimon Schubert struct bfd_link_hash_entry *undefs_tail; 1725796c8dcSSimon Schubert /* The type of the link hash table. */ 1735796c8dcSSimon Schubert enum bfd_link_hash_table_type type; 1745796c8dcSSimon Schubert }; 1755796c8dcSSimon Schubert 1765796c8dcSSimon Schubert /* Look up an entry in a link hash table. If FOLLOW is TRUE, this 1775796c8dcSSimon Schubert follows bfd_link_hash_indirect and bfd_link_hash_warning links to 1785796c8dcSSimon Schubert the real symbol. */ 1795796c8dcSSimon Schubert extern struct bfd_link_hash_entry *bfd_link_hash_lookup 1805796c8dcSSimon Schubert (struct bfd_link_hash_table *, const char *, bfd_boolean create, 1815796c8dcSSimon Schubert bfd_boolean copy, bfd_boolean follow); 1825796c8dcSSimon Schubert 1835796c8dcSSimon Schubert /* Look up an entry in the main linker hash table if the symbol might 1845796c8dcSSimon Schubert be wrapped. This should only be used for references to an 1855796c8dcSSimon Schubert undefined symbol, not for definitions of a symbol. */ 1865796c8dcSSimon Schubert 1875796c8dcSSimon Schubert extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup 1885796c8dcSSimon Schubert (bfd *, struct bfd_link_info *, const char *, bfd_boolean, 1895796c8dcSSimon Schubert bfd_boolean, bfd_boolean); 1905796c8dcSSimon Schubert 1915796c8dcSSimon Schubert /* Traverse a link hash table. */ 1925796c8dcSSimon Schubert extern void bfd_link_hash_traverse 1935796c8dcSSimon Schubert (struct bfd_link_hash_table *, 1945796c8dcSSimon Schubert bfd_boolean (*) (struct bfd_link_hash_entry *, void *), 1955796c8dcSSimon Schubert void *); 1965796c8dcSSimon Schubert 1975796c8dcSSimon Schubert /* Add an entry to the undefs list. */ 1985796c8dcSSimon Schubert extern void bfd_link_add_undef 1995796c8dcSSimon Schubert (struct bfd_link_hash_table *, struct bfd_link_hash_entry *); 2005796c8dcSSimon Schubert 2015796c8dcSSimon Schubert /* Remove symbols from the undefs list that don't belong there. */ 2025796c8dcSSimon Schubert extern void bfd_link_repair_undef_list 2035796c8dcSSimon Schubert (struct bfd_link_hash_table *table); 2045796c8dcSSimon Schubert 2055796c8dcSSimon Schubert /* Read symbols and cache symbol pointer array in outsymbols. */ 2065796c8dcSSimon Schubert extern bfd_boolean bfd_generic_link_read_symbols (bfd *); 2075796c8dcSSimon Schubert 2085796c8dcSSimon Schubert struct bfd_sym_chain 2095796c8dcSSimon Schubert { 2105796c8dcSSimon Schubert struct bfd_sym_chain *next; 2115796c8dcSSimon Schubert const char *name; 2125796c8dcSSimon Schubert }; 2135796c8dcSSimon Schubert 2145796c8dcSSimon Schubert /* How to handle unresolved symbols. 2155796c8dcSSimon Schubert There are four possibilities which are enumerated below: */ 2165796c8dcSSimon Schubert enum report_method 2175796c8dcSSimon Schubert { 2185796c8dcSSimon Schubert /* This is the initial value when then link_info structure is created. 2195796c8dcSSimon Schubert It allows the various stages of the linker to determine whether they 2205796c8dcSSimon Schubert allowed to set the value. */ 2215796c8dcSSimon Schubert RM_NOT_YET_SET = 0, 2225796c8dcSSimon Schubert RM_IGNORE, 2235796c8dcSSimon Schubert RM_GENERATE_WARNING, 2245796c8dcSSimon Schubert RM_GENERATE_ERROR 2255796c8dcSSimon Schubert }; 2265796c8dcSSimon Schubert 227a45ae5f8SJohn Marino typedef enum {with_flags, without_flags} flag_type; 228a45ae5f8SJohn Marino 229a45ae5f8SJohn Marino /* A section flag list. */ 230a45ae5f8SJohn Marino struct flag_info_list 231a45ae5f8SJohn Marino { 232a45ae5f8SJohn Marino flag_type with; 233a45ae5f8SJohn Marino const char *name; 234a45ae5f8SJohn Marino bfd_boolean valid; 235a45ae5f8SJohn Marino struct flag_info_list *next; 236a45ae5f8SJohn Marino }; 237a45ae5f8SJohn Marino 238a45ae5f8SJohn Marino /* Section flag info. */ 239a45ae5f8SJohn Marino struct flag_info 240a45ae5f8SJohn Marino { 241a45ae5f8SJohn Marino flagword only_with_flags; 242a45ae5f8SJohn Marino flagword not_with_flags; 243a45ae5f8SJohn Marino struct flag_info_list *flag_list; 244a45ae5f8SJohn Marino bfd_boolean flags_initialized; 245a45ae5f8SJohn Marino }; 246a45ae5f8SJohn Marino 2475796c8dcSSimon Schubert struct bfd_elf_dynamic_list; 248a45ae5f8SJohn Marino struct bfd_elf_version_tree; 2495796c8dcSSimon Schubert 2505796c8dcSSimon Schubert /* This structure holds all the information needed to communicate 2515796c8dcSSimon Schubert between BFD and the linker when doing a link. */ 2525796c8dcSSimon Schubert 2535796c8dcSSimon Schubert struct bfd_link_info 2545796c8dcSSimon Schubert { 255a45ae5f8SJohn Marino /* TRUE if BFD should generate a shared object (or a pie). */ 256a45ae5f8SJohn Marino unsigned int shared: 1; 257a45ae5f8SJohn Marino 258a45ae5f8SJohn Marino /* TRUE if generating an executable, position independent or not. */ 259a45ae5f8SJohn Marino unsigned int executable : 1; 260a45ae5f8SJohn Marino 261a45ae5f8SJohn Marino /* TRUE if generating a position independent executable. */ 262a45ae5f8SJohn Marino unsigned int pie: 1; 263a45ae5f8SJohn Marino 2645796c8dcSSimon Schubert /* TRUE if BFD should generate a relocatable object file. */ 2655796c8dcSSimon Schubert unsigned int relocatable: 1; 2665796c8dcSSimon Schubert 2675796c8dcSSimon Schubert /* TRUE if BFD should pre-bind symbols in a shared object. */ 2685796c8dcSSimon Schubert unsigned int symbolic: 1; 2695796c8dcSSimon Schubert 2705796c8dcSSimon Schubert /* TRUE if executable should not contain copy relocs. 2715796c8dcSSimon Schubert Setting this true may result in a non-sharable text segment. */ 2725796c8dcSSimon Schubert unsigned int nocopyreloc: 1; 2735796c8dcSSimon Schubert 274a45ae5f8SJohn Marino /* TRUE if BFD should export all symbols in the dynamic symbol table 275a45ae5f8SJohn Marino of an executable, rather than only those used. */ 276a45ae5f8SJohn Marino unsigned int export_dynamic: 1; 2775796c8dcSSimon Schubert 278a45ae5f8SJohn Marino /* TRUE if a default symbol version should be created and used for 279a45ae5f8SJohn Marino exported symbols. */ 280a45ae5f8SJohn Marino unsigned int create_default_symver: 1; 281a45ae5f8SJohn Marino 282a45ae5f8SJohn Marino /* TRUE if unreferenced sections should be removed. */ 283a45ae5f8SJohn Marino unsigned int gc_sections: 1; 284a45ae5f8SJohn Marino 285a45ae5f8SJohn Marino /* TRUE if every symbol should be reported back via the notice 286a45ae5f8SJohn Marino callback. */ 287a45ae5f8SJohn Marino unsigned int notice_all: 1; 288a45ae5f8SJohn Marino 289a45ae5f8SJohn Marino /* TRUE if we are loading LTO outputs. */ 290a45ae5f8SJohn Marino unsigned int loading_lto_outputs: 1; 291a45ae5f8SJohn Marino 292a45ae5f8SJohn Marino /* TRUE if global symbols in discarded sections should be stripped. */ 293a45ae5f8SJohn Marino unsigned int strip_discarded: 1; 294a45ae5f8SJohn Marino 295a45ae5f8SJohn Marino /* TRUE if all data symbols should be dynamic. */ 296a45ae5f8SJohn Marino unsigned int dynamic_data: 1; 297a45ae5f8SJohn Marino 298a45ae5f8SJohn Marino /* Which symbols to strip. */ 299a45ae5f8SJohn Marino ENUM_BITFIELD (bfd_link_strip) strip : 2; 300a45ae5f8SJohn Marino 301a45ae5f8SJohn Marino /* Which local symbols to discard. */ 302a45ae5f8SJohn Marino ENUM_BITFIELD (bfd_link_discard) discard : 2; 303a45ae5f8SJohn Marino 304a45ae5f8SJohn Marino /* Criteria for skipping symbols when determining 305a45ae5f8SJohn Marino whether to include an object from an archive. */ 306a45ae5f8SJohn Marino ENUM_BITFIELD (bfd_link_common_skip_ar_symbols) common_skip_ar_symbols : 2; 307a45ae5f8SJohn Marino 308a45ae5f8SJohn Marino /* What to do with unresolved symbols in an object file. 309a45ae5f8SJohn Marino When producing executables the default is GENERATE_ERROR. 310a45ae5f8SJohn Marino When producing shared libraries the default is IGNORE. The 311a45ae5f8SJohn Marino assumption with shared libraries is that the reference will be 312a45ae5f8SJohn Marino resolved at load/execution time. */ 313a45ae5f8SJohn Marino ENUM_BITFIELD (report_method) unresolved_syms_in_objects : 2; 314a45ae5f8SJohn Marino 315a45ae5f8SJohn Marino /* What to do with unresolved symbols in a shared library. 316a45ae5f8SJohn Marino The same defaults apply. */ 317a45ae5f8SJohn Marino ENUM_BITFIELD (report_method) unresolved_syms_in_shared_libs : 2; 318a45ae5f8SJohn Marino 319a45ae5f8SJohn Marino /* TRUE if shared objects should be linked directly, not shared. */ 320a45ae5f8SJohn Marino unsigned int static_link: 1; 321a45ae5f8SJohn Marino 322a45ae5f8SJohn Marino /* TRUE if symbols should be retained in memory, FALSE if they 323a45ae5f8SJohn Marino should be freed and reread. */ 324a45ae5f8SJohn Marino unsigned int keep_memory: 1; 325a45ae5f8SJohn Marino 326a45ae5f8SJohn Marino /* TRUE if BFD should generate relocation information in the final 327a45ae5f8SJohn Marino executable. */ 328a45ae5f8SJohn Marino unsigned int emitrelocations: 1; 329a45ae5f8SJohn Marino 330a45ae5f8SJohn Marino /* TRUE if PT_GNU_RELRO segment should be created. */ 331a45ae5f8SJohn Marino unsigned int relro: 1; 3325796c8dcSSimon Schubert 3335796c8dcSSimon Schubert /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment 3345796c8dcSSimon Schubert should be created. */ 3355796c8dcSSimon Schubert unsigned int eh_frame_hdr: 1; 3365796c8dcSSimon Schubert 3375796c8dcSSimon Schubert /* TRUE if we should warn when adding a DT_TEXTREL to a shared object. */ 3385796c8dcSSimon Schubert unsigned int warn_shared_textrel: 1; 3395796c8dcSSimon Schubert 340a45ae5f8SJohn Marino /* TRUE if we should error when adding a DT_TEXTREL. */ 341a45ae5f8SJohn Marino unsigned int error_textrel: 1; 3425796c8dcSSimon Schubert 3435796c8dcSSimon Schubert /* TRUE if .hash section should be created. */ 3445796c8dcSSimon Schubert unsigned int emit_hash: 1; 3455796c8dcSSimon Schubert 3465796c8dcSSimon Schubert /* TRUE if .gnu.hash section should be created. */ 3475796c8dcSSimon Schubert unsigned int emit_gnu_hash: 1; 3485796c8dcSSimon Schubert 3495796c8dcSSimon Schubert /* If TRUE reduce memory overheads, at the expense of speed. This will 3505796c8dcSSimon Schubert cause map file generation to use an O(N^2) algorithm and disable 3515796c8dcSSimon Schubert caching ELF symbol buffer. */ 3525796c8dcSSimon Schubert unsigned int reduce_memory_overheads: 1; 3535796c8dcSSimon Schubert 354a45ae5f8SJohn Marino /* TRUE if the output file should be in a traditional format. This 355a45ae5f8SJohn Marino is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag 356a45ae5f8SJohn Marino on the output file, but may be checked when reading the input 357a45ae5f8SJohn Marino files. */ 358a45ae5f8SJohn Marino unsigned int traditional_format: 1; 359a45ae5f8SJohn Marino 360a45ae5f8SJohn Marino /* TRUE if non-PLT relocs should be merged into one reloc section 361a45ae5f8SJohn Marino and sorted so that relocs against the same symbol come together. */ 362a45ae5f8SJohn Marino unsigned int combreloc: 1; 363a45ae5f8SJohn Marino 364a45ae5f8SJohn Marino /* TRUE if a default symbol version should be created and used for 365a45ae5f8SJohn Marino imported symbols. */ 366a45ae5f8SJohn Marino unsigned int default_imported_symver: 1; 367a45ae5f8SJohn Marino 368a45ae5f8SJohn Marino /* TRUE if the new ELF dynamic tags are enabled. */ 369a45ae5f8SJohn Marino unsigned int new_dtags: 1; 370a45ae5f8SJohn Marino 371a45ae5f8SJohn Marino /* FALSE if .eh_frame unwind info should be generated for PLT and other 372a45ae5f8SJohn Marino linker created sections, TRUE if it should be omitted. */ 373a45ae5f8SJohn Marino unsigned int no_ld_generated_unwind_info: 1; 374a45ae5f8SJohn Marino 375a45ae5f8SJohn Marino /* TRUE if BFD should generate a "task linked" object file, 376a45ae5f8SJohn Marino similar to relocatable but also with globals converted to 377a45ae5f8SJohn Marino statics. */ 378a45ae5f8SJohn Marino unsigned int task_link: 1; 379a45ae5f8SJohn Marino 380a45ae5f8SJohn Marino /* TRUE if ok to have multiple definition. */ 381a45ae5f8SJohn Marino unsigned int allow_multiple_definition: 1; 382a45ae5f8SJohn Marino 383a45ae5f8SJohn Marino /* TRUE if ok to have version with no definition. */ 384a45ae5f8SJohn Marino unsigned int allow_undefined_version: 1; 3855796c8dcSSimon Schubert 3865796c8dcSSimon Schubert /* TRUE if some symbols have to be dynamic, controlled by 3875796c8dcSSimon Schubert --dynamic-list command line options. */ 3885796c8dcSSimon Schubert unsigned int dynamic: 1; 3895796c8dcSSimon Schubert 390a45ae5f8SJohn Marino /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X 391a45ae5f8SJohn Marino flags. */ 392a45ae5f8SJohn Marino unsigned int execstack: 1; 3935796c8dcSSimon Schubert 394a45ae5f8SJohn Marino /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W 395a45ae5f8SJohn Marino flags. */ 396a45ae5f8SJohn Marino unsigned int noexecstack: 1; 3975796c8dcSSimon Schubert 398a45ae5f8SJohn Marino /* TRUE if we want to produced optimized output files. This might 399a45ae5f8SJohn Marino need much more time and therefore must be explicitly selected. */ 400a45ae5f8SJohn Marino unsigned int optimize: 1; 4015796c8dcSSimon Schubert 402a45ae5f8SJohn Marino /* TRUE if user should be informed of removed unreferenced sections. */ 403a45ae5f8SJohn Marino unsigned int print_gc_sections: 1; 4045796c8dcSSimon Schubert 405a45ae5f8SJohn Marino /* TRUE if we should warn alternate ELF machine code. */ 406a45ae5f8SJohn Marino unsigned int warn_alternate_em: 1; 4075796c8dcSSimon Schubert 408*ef5ccd6cSJohn Marino /* TRUE if the linker script contained an explicit PHDRS command. */ 409*ef5ccd6cSJohn Marino unsigned int user_phdrs: 1; 410*ef5ccd6cSJohn Marino 4115796c8dcSSimon Schubert /* Char that may appear as the first char of a symbol, but should be 4125796c8dcSSimon Schubert skipped (like symbol_leading_char) when looking up symbols in 4135796c8dcSSimon Schubert wrap_hash. Used by PowerPC Linux for 'dot' symbols. */ 4145796c8dcSSimon Schubert char wrap_char; 4155796c8dcSSimon Schubert 4165796c8dcSSimon Schubert /* Separator between archive and filename in linker script filespecs. */ 4175796c8dcSSimon Schubert char path_separator; 4185796c8dcSSimon Schubert 419*ef5ccd6cSJohn Marino /* Default stack size. Zero means default (often zero itself), -1 420*ef5ccd6cSJohn Marino means explicitly zero-sized. */ 421*ef5ccd6cSJohn Marino bfd_signed_vma stacksize; 422*ef5ccd6cSJohn Marino 423*ef5ccd6cSJohn Marino /* Enable or disable target specific optimizations. 424*ef5ccd6cSJohn Marino 425*ef5ccd6cSJohn Marino Not all targets have optimizations to enable. 426*ef5ccd6cSJohn Marino 427*ef5ccd6cSJohn Marino Normally these optimizations are disabled by default but some targets 428*ef5ccd6cSJohn Marino prefer to enable them by default. So this field is a tri-state variable. 429*ef5ccd6cSJohn Marino The values are: 430*ef5ccd6cSJohn Marino 431*ef5ccd6cSJohn Marino zero: Enable the optimizations (either from --relax being specified on 432*ef5ccd6cSJohn Marino the command line or the backend's before_allocation emulation function. 433*ef5ccd6cSJohn Marino 434*ef5ccd6cSJohn Marino positive: The user has requested that these optimizations be disabled. 435*ef5ccd6cSJohn Marino (Via the --no-relax command line option). 436*ef5ccd6cSJohn Marino 437*ef5ccd6cSJohn Marino negative: The optimizations are disabled. (Set when initializing the 438*ef5ccd6cSJohn Marino args_type structure in ldmain.c:main. */ 439*ef5ccd6cSJohn Marino signed int disable_target_specific_optimizations; 440*ef5ccd6cSJohn Marino 4415796c8dcSSimon Schubert /* Function callbacks. */ 4425796c8dcSSimon Schubert const struct bfd_link_callbacks *callbacks; 4435796c8dcSSimon Schubert 4445796c8dcSSimon Schubert /* Hash table handled by BFD. */ 4455796c8dcSSimon Schubert struct bfd_link_hash_table *hash; 4465796c8dcSSimon Schubert 4475796c8dcSSimon Schubert /* Hash table of symbols to keep. This is NULL unless strip is 4485796c8dcSSimon Schubert strip_some. */ 4495796c8dcSSimon Schubert struct bfd_hash_table *keep_hash; 4505796c8dcSSimon Schubert 4515796c8dcSSimon Schubert /* Hash table of symbols to report back via the notice callback. If 4525796c8dcSSimon Schubert this is NULL, and notice_all is FALSE, then no symbols are 4535796c8dcSSimon Schubert reported back. */ 4545796c8dcSSimon Schubert struct bfd_hash_table *notice_hash; 4555796c8dcSSimon Schubert 4565796c8dcSSimon Schubert /* Hash table of symbols which are being wrapped (the --wrap linker 4575796c8dcSSimon Schubert option). If this is NULL, no symbols are being wrapped. */ 4585796c8dcSSimon Schubert struct bfd_hash_table *wrap_hash; 4595796c8dcSSimon Schubert 460*ef5ccd6cSJohn Marino /* Hash table of symbols which may be left unresolved during 461*ef5ccd6cSJohn Marino a link. If this is NULL, no symbols can be left unresolved. */ 462*ef5ccd6cSJohn Marino struct bfd_hash_table *ignore_hash; 463*ef5ccd6cSJohn Marino 4645796c8dcSSimon Schubert /* The output BFD. */ 4655796c8dcSSimon Schubert bfd *output_bfd; 4665796c8dcSSimon Schubert 4675796c8dcSSimon Schubert /* The list of input BFD's involved in the link. These are chained 4685796c8dcSSimon Schubert together via the link_next field. */ 4695796c8dcSSimon Schubert bfd *input_bfds; 4705796c8dcSSimon Schubert bfd **input_bfds_tail; 4715796c8dcSSimon Schubert 4725796c8dcSSimon Schubert /* If a symbol should be created for each input BFD, this is section 4735796c8dcSSimon Schubert where those symbols should be placed. It must be a section in 4745796c8dcSSimon Schubert the output BFD. It may be NULL, in which case no such symbols 4755796c8dcSSimon Schubert will be created. This is to support CREATE_OBJECT_SYMBOLS in the 4765796c8dcSSimon Schubert linker command language. */ 4775796c8dcSSimon Schubert asection *create_object_symbols_section; 4785796c8dcSSimon Schubert 4795796c8dcSSimon Schubert /* List of global symbol names that are starting points for marking 4805796c8dcSSimon Schubert sections against garbage collection. */ 4815796c8dcSSimon Schubert struct bfd_sym_chain *gc_sym_list; 4825796c8dcSSimon Schubert 4835796c8dcSSimon Schubert /* If a base output file is wanted, then this points to it */ 4845796c8dcSSimon Schubert void *base_file; 4855796c8dcSSimon Schubert 4865796c8dcSSimon Schubert /* The function to call when the executable or shared object is 4875796c8dcSSimon Schubert loaded. */ 4885796c8dcSSimon Schubert const char *init_function; 4895796c8dcSSimon Schubert 4905796c8dcSSimon Schubert /* The function to call when the executable or shared object is 4915796c8dcSSimon Schubert unloaded. */ 4925796c8dcSSimon Schubert const char *fini_function; 4935796c8dcSSimon Schubert 4945796c8dcSSimon Schubert /* Number of relaxation passes. Usually only one relaxation pass 4955796c8dcSSimon Schubert is needed. But a backend can have as many relaxation passes as 4965796c8dcSSimon Schubert necessary. During bfd_relax_section call, it is set to the 4975796c8dcSSimon Schubert current pass, starting from 0. */ 4985796c8dcSSimon Schubert int relax_pass; 4995796c8dcSSimon Schubert 5005796c8dcSSimon Schubert /* Number of relaxation trips. This number is incremented every 5015796c8dcSSimon Schubert time the relaxation pass is restarted due to a previous 5025796c8dcSSimon Schubert relaxation returning true in *AGAIN. */ 5035796c8dcSSimon Schubert int relax_trip; 5045796c8dcSSimon Schubert 5055796c8dcSSimon Schubert /* Non-zero if auto-import thunks for DATA items in pei386 DLLs 5065796c8dcSSimon Schubert should be generated/linked against. Set to 1 if this feature 5075796c8dcSSimon Schubert is explicitly requested by the user, -1 if enabled by default. */ 5085796c8dcSSimon Schubert int pei386_auto_import; 5095796c8dcSSimon Schubert 5105796c8dcSSimon Schubert /* Non-zero if runtime relocs for DATA items with non-zero addends 5115796c8dcSSimon Schubert in pei386 DLLs should be generated. Set to 1 if this feature 5125796c8dcSSimon Schubert is explicitly requested by the user, -1 if enabled by default. */ 5135796c8dcSSimon Schubert int pei386_runtime_pseudo_reloc; 5145796c8dcSSimon Schubert 5155796c8dcSSimon Schubert /* How many spare .dynamic DT_NULL entries should be added? */ 5165796c8dcSSimon Schubert unsigned int spare_dynamic_tags; 5175796c8dcSSimon Schubert 5185796c8dcSSimon Schubert /* May be used to set DT_FLAGS for ELF. */ 5195796c8dcSSimon Schubert bfd_vma flags; 5205796c8dcSSimon Schubert 5215796c8dcSSimon Schubert /* May be used to set DT_FLAGS_1 for ELF. */ 5225796c8dcSSimon Schubert bfd_vma flags_1; 5235796c8dcSSimon Schubert 5245796c8dcSSimon Schubert /* Start and end of RELRO region. */ 5255796c8dcSSimon Schubert bfd_vma relro_start, relro_end; 5265796c8dcSSimon Schubert 5275796c8dcSSimon Schubert /* List of symbols should be dynamic. */ 5285796c8dcSSimon Schubert struct bfd_elf_dynamic_list *dynamic_list; 529a45ae5f8SJohn Marino 530a45ae5f8SJohn Marino /* The version information. */ 531a45ae5f8SJohn Marino struct bfd_elf_version_tree *version_info; 5325796c8dcSSimon Schubert }; 5335796c8dcSSimon Schubert 5345796c8dcSSimon Schubert /* This structures holds a set of callback functions. These are called 5355796c8dcSSimon Schubert by the BFD linker routines. Except for the info functions, the first 5365796c8dcSSimon Schubert argument to each callback function is the bfd_link_info structure 5375796c8dcSSimon Schubert being used and each function returns a boolean value. If the 5385796c8dcSSimon Schubert function returns FALSE, then the BFD function which called it should 5395796c8dcSSimon Schubert return with a failure indication. */ 5405796c8dcSSimon Schubert 5415796c8dcSSimon Schubert struct bfd_link_callbacks 5425796c8dcSSimon Schubert { 5435796c8dcSSimon Schubert /* A function which is called when an object is added from an 5445796c8dcSSimon Schubert archive. ABFD is the archive element being added. NAME is the 5455796c8dcSSimon Schubert name of the symbol which caused the archive element to be pulled 546c50c785cSJohn Marino in. This function may set *SUBSBFD to point to an alternative 547c50c785cSJohn Marino BFD from which symbols should in fact be added in place of the 548c50c785cSJohn Marino original BFD's symbols. */ 5495796c8dcSSimon Schubert bfd_boolean (*add_archive_element) 550c50c785cSJohn Marino (struct bfd_link_info *, bfd *abfd, const char *name, bfd **subsbfd); 5515796c8dcSSimon Schubert /* A function which is called when a symbol is found with multiple 552a45ae5f8SJohn Marino definitions. H is the symbol which is defined multiple times. 553a45ae5f8SJohn Marino NBFD is the new BFD, NSEC is the new section, and NVAL is the new 554a45ae5f8SJohn Marino value. NSEC may be bfd_com_section or bfd_ind_section. */ 5555796c8dcSSimon Schubert bfd_boolean (*multiple_definition) 556a45ae5f8SJohn Marino (struct bfd_link_info *, struct bfd_link_hash_entry *h, 5575796c8dcSSimon Schubert bfd *nbfd, asection *nsec, bfd_vma nval); 5585796c8dcSSimon Schubert /* A function which is called when a common symbol is defined 559a45ae5f8SJohn Marino multiple times. H is the symbol appearing multiple times. 5605796c8dcSSimon Schubert NBFD is the BFD of the new symbol. NTYPE is the type of the new 5615796c8dcSSimon Schubert symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or 5625796c8dcSSimon Schubert bfd_link_hash_indirect. If NTYPE is bfd_link_hash_common, NSIZE 5635796c8dcSSimon Schubert is the size of the new symbol. */ 5645796c8dcSSimon Schubert bfd_boolean (*multiple_common) 565a45ae5f8SJohn Marino (struct bfd_link_info *, struct bfd_link_hash_entry *h, 5665796c8dcSSimon Schubert bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize); 5675796c8dcSSimon Schubert /* A function which is called to add a symbol to a set. ENTRY is 5685796c8dcSSimon Schubert the link hash table entry for the set itself (e.g., 5695796c8dcSSimon Schubert __CTOR_LIST__). RELOC is the relocation to use for an entry in 5705796c8dcSSimon Schubert the set when generating a relocatable file, and is also used to 5715796c8dcSSimon Schubert get the size of the entry when generating an executable file. 5725796c8dcSSimon Schubert ABFD, SEC and VALUE identify the value to add to the set. */ 5735796c8dcSSimon Schubert bfd_boolean (*add_to_set) 5745796c8dcSSimon Schubert (struct bfd_link_info *, struct bfd_link_hash_entry *entry, 5755796c8dcSSimon Schubert bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value); 5765796c8dcSSimon Schubert /* A function which is called when the name of a g++ constructor or 5775796c8dcSSimon Schubert destructor is found. This is only called by some object file 5785796c8dcSSimon Schubert formats. CONSTRUCTOR is TRUE for a constructor, FALSE for a 5795796c8dcSSimon Schubert destructor. This will use BFD_RELOC_CTOR when generating a 5805796c8dcSSimon Schubert relocatable file. NAME is the name of the symbol found. ABFD, 5815796c8dcSSimon Schubert SECTION and VALUE are the value of the symbol. */ 5825796c8dcSSimon Schubert bfd_boolean (*constructor) 5835796c8dcSSimon Schubert (struct bfd_link_info *, bfd_boolean constructor, const char *name, 5845796c8dcSSimon Schubert bfd *abfd, asection *sec, bfd_vma value); 5855796c8dcSSimon Schubert /* A function which is called to issue a linker warning. For 5865796c8dcSSimon Schubert example, this is called when there is a reference to a warning 5875796c8dcSSimon Schubert symbol. WARNING is the warning to be issued. SYMBOL is the name 5885796c8dcSSimon Schubert of the symbol which triggered the warning; it may be NULL if 5895796c8dcSSimon Schubert there is none. ABFD, SECTION and ADDRESS identify the location 5905796c8dcSSimon Schubert which trigerred the warning; either ABFD or SECTION or both may 5915796c8dcSSimon Schubert be NULL if the location is not known. */ 5925796c8dcSSimon Schubert bfd_boolean (*warning) 5935796c8dcSSimon Schubert (struct bfd_link_info *, const char *warning, const char *symbol, 5945796c8dcSSimon Schubert bfd *abfd, asection *section, bfd_vma address); 5955796c8dcSSimon Schubert /* A function which is called when a relocation is attempted against 5965796c8dcSSimon Schubert an undefined symbol. NAME is the symbol which is undefined. 5975796c8dcSSimon Schubert ABFD, SECTION and ADDRESS identify the location from which the 598cf7f2e2dSJohn Marino reference is made. IS_FATAL indicates whether an undefined symbol is 5995796c8dcSSimon Schubert a fatal error or not. In some cases SECTION may be NULL. */ 6005796c8dcSSimon Schubert bfd_boolean (*undefined_symbol) 6015796c8dcSSimon Schubert (struct bfd_link_info *, const char *name, bfd *abfd, 602cf7f2e2dSJohn Marino asection *section, bfd_vma address, bfd_boolean is_fatal); 6035796c8dcSSimon Schubert /* A function which is called when a reloc overflow occurs. ENTRY is 6045796c8dcSSimon Schubert the link hash table entry for the symbol the reloc is against. 6055796c8dcSSimon Schubert NAME is the name of the local symbol or section the reloc is 6065796c8dcSSimon Schubert against, RELOC_NAME is the name of the relocation, and ADDEND is 6075796c8dcSSimon Schubert any addend that is used. ABFD, SECTION and ADDRESS identify the 6085796c8dcSSimon Schubert location at which the overflow occurs; if this is the result of a 6095796c8dcSSimon Schubert bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 6105796c8dcSSimon Schubert ABFD will be NULL. */ 6115796c8dcSSimon Schubert bfd_boolean (*reloc_overflow) 6125796c8dcSSimon Schubert (struct bfd_link_info *, struct bfd_link_hash_entry *entry, 6135796c8dcSSimon Schubert const char *name, const char *reloc_name, bfd_vma addend, 6145796c8dcSSimon Schubert bfd *abfd, asection *section, bfd_vma address); 6155796c8dcSSimon Schubert /* A function which is called when a dangerous reloc is performed. 6165796c8dcSSimon Schubert MESSAGE is an appropriate message. 6175796c8dcSSimon Schubert ABFD, SECTION and ADDRESS identify the location at which the 6185796c8dcSSimon Schubert problem occurred; if this is the result of a 6195796c8dcSSimon Schubert bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 6205796c8dcSSimon Schubert ABFD will be NULL. */ 6215796c8dcSSimon Schubert bfd_boolean (*reloc_dangerous) 6225796c8dcSSimon Schubert (struct bfd_link_info *, const char *message, 6235796c8dcSSimon Schubert bfd *abfd, asection *section, bfd_vma address); 6245796c8dcSSimon Schubert /* A function which is called when a reloc is found to be attached 6255796c8dcSSimon Schubert to a symbol which is not being written out. NAME is the name of 6265796c8dcSSimon Schubert the symbol. ABFD, SECTION and ADDRESS identify the location of 6275796c8dcSSimon Schubert the reloc; if this is the result of a 6285796c8dcSSimon Schubert bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 6295796c8dcSSimon Schubert ABFD will be NULL. */ 6305796c8dcSSimon Schubert bfd_boolean (*unattached_reloc) 6315796c8dcSSimon Schubert (struct bfd_link_info *, const char *name, 6325796c8dcSSimon Schubert bfd *abfd, asection *section, bfd_vma address); 6335796c8dcSSimon Schubert /* A function which is called when a symbol in notice_hash is 634a45ae5f8SJohn Marino defined or referenced. H is the symbol. ABFD, SECTION and 635a45ae5f8SJohn Marino ADDRESS are the (new) value of the symbol. If SECTION is 636a45ae5f8SJohn Marino bfd_und_section, this is a reference. FLAGS are the symbol 637a45ae5f8SJohn Marino BSF_* flags. STRING is the name of the symbol to indirect to if 638a45ae5f8SJohn Marino the sym is indirect, or the warning string if a warning sym. */ 6395796c8dcSSimon Schubert bfd_boolean (*notice) 640a45ae5f8SJohn Marino (struct bfd_link_info *, struct bfd_link_hash_entry *h, 641a45ae5f8SJohn Marino bfd *abfd, asection *section, bfd_vma address, flagword flags, 642a45ae5f8SJohn Marino const char *string); 6435796c8dcSSimon Schubert /* Error or warning link info message. */ 6445796c8dcSSimon Schubert void (*einfo) 6455796c8dcSSimon Schubert (const char *fmt, ...); 6465796c8dcSSimon Schubert /* General link info message. */ 6475796c8dcSSimon Schubert void (*info) 6485796c8dcSSimon Schubert (const char *fmt, ...); 6495796c8dcSSimon Schubert /* Message to be printed in linker map file. */ 6505796c8dcSSimon Schubert void (*minfo) 6515796c8dcSSimon Schubert (const char *fmt, ...); 6525796c8dcSSimon Schubert /* This callback provides a chance for users of the BFD library to 6535796c8dcSSimon Schubert override its decision about whether to place two adjacent sections 6545796c8dcSSimon Schubert into the same segment. */ 6555796c8dcSSimon Schubert bfd_boolean (*override_segment_assignment) 6565796c8dcSSimon Schubert (struct bfd_link_info *, bfd * abfd, 6575796c8dcSSimon Schubert asection * current_section, asection * previous_section, 6585796c8dcSSimon Schubert bfd_boolean new_segment); 6595796c8dcSSimon Schubert }; 6605796c8dcSSimon Schubert 6615796c8dcSSimon Schubert /* The linker builds link_order structures which tell the code how to 6625796c8dcSSimon Schubert include input data in the output file. */ 6635796c8dcSSimon Schubert 6645796c8dcSSimon Schubert /* These are the types of link_order structures. */ 6655796c8dcSSimon Schubert 6665796c8dcSSimon Schubert enum bfd_link_order_type 6675796c8dcSSimon Schubert { 6685796c8dcSSimon Schubert bfd_undefined_link_order, /* Undefined. */ 6695796c8dcSSimon Schubert bfd_indirect_link_order, /* Built from a section. */ 6705796c8dcSSimon Schubert bfd_data_link_order, /* Set to explicit data. */ 6715796c8dcSSimon Schubert bfd_section_reloc_link_order, /* Relocate against a section. */ 6725796c8dcSSimon Schubert bfd_symbol_reloc_link_order /* Relocate against a symbol. */ 6735796c8dcSSimon Schubert }; 6745796c8dcSSimon Schubert 6755796c8dcSSimon Schubert /* This is the link_order structure itself. These form a chain 6765796c8dcSSimon Schubert attached to the output section whose contents they are describing. */ 6775796c8dcSSimon Schubert 6785796c8dcSSimon Schubert struct bfd_link_order 6795796c8dcSSimon Schubert { 6805796c8dcSSimon Schubert /* Next link_order in chain. */ 6815796c8dcSSimon Schubert struct bfd_link_order *next; 6825796c8dcSSimon Schubert /* Type of link_order. */ 6835796c8dcSSimon Schubert enum bfd_link_order_type type; 6845796c8dcSSimon Schubert /* Offset within output section. */ 6855796c8dcSSimon Schubert bfd_vma offset; 6865796c8dcSSimon Schubert /* Size within output section. */ 6875796c8dcSSimon Schubert bfd_size_type size; 6885796c8dcSSimon Schubert /* Type specific information. */ 6895796c8dcSSimon Schubert union 6905796c8dcSSimon Schubert { 6915796c8dcSSimon Schubert struct 6925796c8dcSSimon Schubert { 6935796c8dcSSimon Schubert /* Section to include. If this is used, then 6945796c8dcSSimon Schubert section->output_section must be the section the 6955796c8dcSSimon Schubert link_order is attached to, section->output_offset must 6965796c8dcSSimon Schubert equal the link_order offset field, and section->size 6975796c8dcSSimon Schubert must equal the link_order size field. Maybe these 6985796c8dcSSimon Schubert restrictions should be relaxed someday. */ 6995796c8dcSSimon Schubert asection *section; 7005796c8dcSSimon Schubert } indirect; 7015796c8dcSSimon Schubert struct 7025796c8dcSSimon Schubert { 703*ef5ccd6cSJohn Marino /* Size of contents, or zero when contents should be filled by 704*ef5ccd6cSJohn Marino the architecture-dependent fill function. 7055796c8dcSSimon Schubert A non-zero value allows filling of the output section 7065796c8dcSSimon Schubert with an arbitrary repeated pattern. */ 7075796c8dcSSimon Schubert unsigned int size; 7085796c8dcSSimon Schubert /* Data to put into file. */ 7095796c8dcSSimon Schubert bfd_byte *contents; 7105796c8dcSSimon Schubert } data; 7115796c8dcSSimon Schubert struct 7125796c8dcSSimon Schubert { 7135796c8dcSSimon Schubert /* Description of reloc to generate. Used for 7145796c8dcSSimon Schubert bfd_section_reloc_link_order and 7155796c8dcSSimon Schubert bfd_symbol_reloc_link_order. */ 7165796c8dcSSimon Schubert struct bfd_link_order_reloc *p; 7175796c8dcSSimon Schubert } reloc; 7185796c8dcSSimon Schubert } u; 7195796c8dcSSimon Schubert }; 7205796c8dcSSimon Schubert 7215796c8dcSSimon Schubert /* A linker order of type bfd_section_reloc_link_order or 7225796c8dcSSimon Schubert bfd_symbol_reloc_link_order means to create a reloc against a 7235796c8dcSSimon Schubert section or symbol, respectively. This is used to implement -Ur to 7245796c8dcSSimon Schubert generate relocs for the constructor tables. The 7255796c8dcSSimon Schubert bfd_link_order_reloc structure describes the reloc that BFD should 7265796c8dcSSimon Schubert create. It is similar to a arelent, but I didn't use arelent 7275796c8dcSSimon Schubert because the linker does not know anything about most symbols, and 7285796c8dcSSimon Schubert any asymbol structure it creates will be partially meaningless. 7295796c8dcSSimon Schubert This information could logically be in the bfd_link_order struct, 7305796c8dcSSimon Schubert but I didn't want to waste the space since these types of relocs 7315796c8dcSSimon Schubert are relatively rare. */ 7325796c8dcSSimon Schubert 7335796c8dcSSimon Schubert struct bfd_link_order_reloc 7345796c8dcSSimon Schubert { 7355796c8dcSSimon Schubert /* Reloc type. */ 7365796c8dcSSimon Schubert bfd_reloc_code_real_type reloc; 7375796c8dcSSimon Schubert 7385796c8dcSSimon Schubert union 7395796c8dcSSimon Schubert { 7405796c8dcSSimon Schubert /* For type bfd_section_reloc_link_order, this is the section 7415796c8dcSSimon Schubert the reloc should be against. This must be a section in the 7425796c8dcSSimon Schubert output BFD, not any of the input BFDs. */ 7435796c8dcSSimon Schubert asection *section; 7445796c8dcSSimon Schubert /* For type bfd_symbol_reloc_link_order, this is the name of the 7455796c8dcSSimon Schubert symbol the reloc should be against. */ 7465796c8dcSSimon Schubert const char *name; 7475796c8dcSSimon Schubert } u; 7485796c8dcSSimon Schubert 7495796c8dcSSimon Schubert /* Addend to use. The object file should contain zero. The BFD 7505796c8dcSSimon Schubert backend is responsible for filling in the contents of the object 7515796c8dcSSimon Schubert file correctly. For some object file formats (e.g., COFF) the 7525796c8dcSSimon Schubert addend must be stored into in the object file, and for some 7535796c8dcSSimon Schubert (e.g., SPARC a.out) it is kept in the reloc. */ 7545796c8dcSSimon Schubert bfd_vma addend; 7555796c8dcSSimon Schubert }; 7565796c8dcSSimon Schubert 7575796c8dcSSimon Schubert /* Allocate a new link_order for a section. */ 7585796c8dcSSimon Schubert extern struct bfd_link_order *bfd_new_link_order (bfd *, asection *); 7595796c8dcSSimon Schubert 7605796c8dcSSimon Schubert /* These structures are used to describe version information for the 7615796c8dcSSimon Schubert ELF linker. These structures could be manipulated entirely inside 7625796c8dcSSimon Schubert BFD, but it would be a pain. Instead, the regular linker sets up 7635796c8dcSSimon Schubert these structures, and then passes them into BFD. */ 7645796c8dcSSimon Schubert 7655796c8dcSSimon Schubert /* Glob pattern for a version. */ 7665796c8dcSSimon Schubert 7675796c8dcSSimon Schubert struct bfd_elf_version_expr 7685796c8dcSSimon Schubert { 7695796c8dcSSimon Schubert /* Next glob pattern for this version. */ 7705796c8dcSSimon Schubert struct bfd_elf_version_expr *next; 7715796c8dcSSimon Schubert /* Glob pattern. */ 7725796c8dcSSimon Schubert const char *pattern; 7735796c8dcSSimon Schubert /* Set if pattern is not a glob. */ 7745796c8dcSSimon Schubert unsigned int literal : 1; 7755796c8dcSSimon Schubert /* Defined by ".symver". */ 7765796c8dcSSimon Schubert unsigned int symver : 1; 7775796c8dcSSimon Schubert /* Defined by version script. */ 7785796c8dcSSimon Schubert unsigned int script : 1; 7795796c8dcSSimon Schubert /* Pattern type. */ 7805796c8dcSSimon Schubert #define BFD_ELF_VERSION_C_TYPE 1 7815796c8dcSSimon Schubert #define BFD_ELF_VERSION_CXX_TYPE 2 7825796c8dcSSimon Schubert #define BFD_ELF_VERSION_JAVA_TYPE 4 7835796c8dcSSimon Schubert unsigned int mask : 3; 7845796c8dcSSimon Schubert }; 7855796c8dcSSimon Schubert 7865796c8dcSSimon Schubert struct bfd_elf_version_expr_head 7875796c8dcSSimon Schubert { 7885796c8dcSSimon Schubert /* List of all patterns, both wildcards and non-wildcards. */ 7895796c8dcSSimon Schubert struct bfd_elf_version_expr *list; 7905796c8dcSSimon Schubert /* Hash table for non-wildcards. */ 7915796c8dcSSimon Schubert void *htab; 7925796c8dcSSimon Schubert /* Remaining patterns. */ 7935796c8dcSSimon Schubert struct bfd_elf_version_expr *remaining; 7945796c8dcSSimon Schubert /* What kind of pattern types are present in list (bitmask). */ 7955796c8dcSSimon Schubert unsigned int mask; 7965796c8dcSSimon Schubert }; 7975796c8dcSSimon Schubert 7985796c8dcSSimon Schubert /* Version dependencies. */ 7995796c8dcSSimon Schubert 8005796c8dcSSimon Schubert struct bfd_elf_version_deps 8015796c8dcSSimon Schubert { 8025796c8dcSSimon Schubert /* Next dependency for this version. */ 8035796c8dcSSimon Schubert struct bfd_elf_version_deps *next; 8045796c8dcSSimon Schubert /* The version which this version depends upon. */ 8055796c8dcSSimon Schubert struct bfd_elf_version_tree *version_needed; 8065796c8dcSSimon Schubert }; 8075796c8dcSSimon Schubert 8085796c8dcSSimon Schubert /* A node in the version tree. */ 8095796c8dcSSimon Schubert 8105796c8dcSSimon Schubert struct bfd_elf_version_tree 8115796c8dcSSimon Schubert { 8125796c8dcSSimon Schubert /* Next version. */ 8135796c8dcSSimon Schubert struct bfd_elf_version_tree *next; 8145796c8dcSSimon Schubert /* Name of this version. */ 8155796c8dcSSimon Schubert const char *name; 8165796c8dcSSimon Schubert /* Version number. */ 8175796c8dcSSimon Schubert unsigned int vernum; 8185796c8dcSSimon Schubert /* Regular expressions for global symbols in this version. */ 8195796c8dcSSimon Schubert struct bfd_elf_version_expr_head globals; 8205796c8dcSSimon Schubert /* Regular expressions for local symbols in this version. */ 8215796c8dcSSimon Schubert struct bfd_elf_version_expr_head locals; 8225796c8dcSSimon Schubert /* List of versions which this version depends upon. */ 8235796c8dcSSimon Schubert struct bfd_elf_version_deps *deps; 8245796c8dcSSimon Schubert /* Index of the version name. This is used within BFD. */ 8255796c8dcSSimon Schubert unsigned int name_indx; 8265796c8dcSSimon Schubert /* Whether this version tree was used. This is used within BFD. */ 8275796c8dcSSimon Schubert int used; 8285796c8dcSSimon Schubert /* Matching hook. */ 8295796c8dcSSimon Schubert struct bfd_elf_version_expr *(*match) 8305796c8dcSSimon Schubert (struct bfd_elf_version_expr_head *head, 8315796c8dcSSimon Schubert struct bfd_elf_version_expr *prev, const char *sym); 8325796c8dcSSimon Schubert }; 8335796c8dcSSimon Schubert 8345796c8dcSSimon Schubert struct bfd_elf_dynamic_list 8355796c8dcSSimon Schubert { 8365796c8dcSSimon Schubert struct bfd_elf_version_expr_head head; 8375796c8dcSSimon Schubert struct bfd_elf_version_expr *(*match) 8385796c8dcSSimon Schubert (struct bfd_elf_version_expr_head *head, 8395796c8dcSSimon Schubert struct bfd_elf_version_expr *prev, const char *sym); 8405796c8dcSSimon Schubert }; 8415796c8dcSSimon Schubert 8425796c8dcSSimon Schubert #endif 843