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