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