133965Sjdp/* bfdlink.h -- header file for BFD link routines 2218822Sdim Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 3218822Sdim 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 433965Sjdp Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support. 533965Sjdp 6104834Sobrien This file is part of BFD, the Binary File Descriptor library. 733965Sjdp 8104834Sobrien This program is free software; you can redistribute it and/or modify 9104834Sobrien it under the terms of the GNU General Public License as published by 10104834Sobrien the Free Software Foundation; either version 2 of the License, or 11104834Sobrien (at your option) any later version. 1233965Sjdp 13104834Sobrien This program is distributed in the hope that it will be useful, 14104834Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 15104834Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16104834Sobrien GNU General Public License for more details. 1733965Sjdp 18104834Sobrien You should have received a copy of the GNU General Public License 19104834Sobrien along with this program; if not, write to the Free Software 20218822Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 2133965Sjdp 2233965Sjdp#ifndef BFDLINK_H 2333965Sjdp#define BFDLINK_H 2433965Sjdp 2533965Sjdp/* Which symbols to strip during a link. */ 2633965Sjdpenum bfd_link_strip 2733965Sjdp{ 2833965Sjdp strip_none, /* Don't strip any symbols. */ 2933965Sjdp strip_debugger, /* Strip debugging symbols. */ 3033965Sjdp strip_some, /* keep_hash is the list of symbols to keep. */ 3133965Sjdp strip_all /* Strip all symbols. */ 3233965Sjdp}; 3333965Sjdp 3433965Sjdp/* Which local symbols to discard during a link. This is irrelevant 3533965Sjdp if strip_all is used. */ 3633965Sjdpenum bfd_link_discard 3733965Sjdp{ 3889857Sobrien discard_sec_merge, /* Discard local temporary symbols in SEC_MERGE 3989857Sobrien sections. */ 4033965Sjdp discard_none, /* Don't discard any locals. */ 4133965Sjdp discard_l, /* Discard local temporary symbols. */ 4233965Sjdp discard_all /* Discard all locals. */ 4333965Sjdp}; 4489857Sobrien 4589857Sobrien/* Describes the type of hash table entry structure being used. 4689857Sobrien Different hash table structure have different fields and so 4789857Sobrien support different linking features. */ 4889857Sobrienenum bfd_link_hash_table_type 4989857Sobrien { 5089857Sobrien bfd_link_generic_hash_table, 5189857Sobrien bfd_link_elf_hash_table 5289857Sobrien }; 5333965Sjdp 5433965Sjdp/* These are the possible types of an entry in the BFD link hash 5533965Sjdp table. */ 5633965Sjdp 5733965Sjdpenum bfd_link_hash_type 5833965Sjdp{ 5933965Sjdp bfd_link_hash_new, /* Symbol is new. */ 6033965Sjdp bfd_link_hash_undefined, /* Symbol seen before, but undefined. */ 6133965Sjdp bfd_link_hash_undefweak, /* Symbol is weak and undefined. */ 6233965Sjdp bfd_link_hash_defined, /* Symbol is defined. */ 6333965Sjdp bfd_link_hash_defweak, /* Symbol is weak and defined. */ 6433965Sjdp bfd_link_hash_common, /* Symbol is common. */ 6533965Sjdp bfd_link_hash_indirect, /* Symbol is an indirect link. */ 6633965Sjdp bfd_link_hash_warning /* Like indirect, but warn if referenced. */ 6733965Sjdp}; 6833965Sjdp 69130561Sobrienenum bfd_link_common_skip_ar_aymbols 70130561Sobrien{ 71130561Sobrien bfd_link_common_skip_none, 72130561Sobrien bfd_link_common_skip_text, 73130561Sobrien bfd_link_common_skip_data, 74130561Sobrien bfd_link_common_skip_all 75130561Sobrien}; 76130561Sobrien 7733965Sjdp/* The linking routines use a hash table which uses this structure for 7833965Sjdp its elements. */ 7933965Sjdp 8033965Sjdpstruct bfd_link_hash_entry 8133965Sjdp{ 8233965Sjdp /* Base hash table entry structure. */ 8333965Sjdp struct bfd_hash_entry root; 84130561Sobrien 8533965Sjdp /* Type of this entry. */ 8633965Sjdp enum bfd_link_hash_type type; 8733965Sjdp 8833965Sjdp /* A union of information depending upon the type. */ 8933965Sjdp union 9033965Sjdp { 9133965Sjdp /* Nothing is kept for bfd_hash_new. */ 9233965Sjdp /* bfd_link_hash_undefined, bfd_link_hash_undefweak. */ 9333965Sjdp struct 9433965Sjdp { 95218822Sdim /* Undefined and common symbols are kept in a linked list through 96218822Sdim this field. This field is present in all of the union element 97218822Sdim so that we don't need to remove entries from the list when we 98218822Sdim change their type. Removing entries would either require the 99218822Sdim list to be doubly linked, which would waste more memory, or 100218822Sdim require a traversal. When an undefined or common symbol is 101218822Sdim created, it should be added to this list, the head of which is in 102218822Sdim the link hash table itself. As symbols are defined, they need 103218822Sdim not be removed from the list; anything which reads the list must 104218822Sdim doublecheck the symbol type. 105218822Sdim 106218822Sdim Weak symbols are not kept on this list. 107218822Sdim 108218822Sdim Defined and defweak symbols use this field as a reference marker. 109218822Sdim If the field is not NULL, or this structure is the tail of the 110218822Sdim undefined symbol list, the symbol has been referenced. If the 111218822Sdim symbol is undefined and becomes defined, this field will 112218822Sdim automatically be non-NULL since the symbol will have been on the 113218822Sdim undefined symbol list. */ 114218822Sdim struct bfd_link_hash_entry *next; 11533965Sjdp bfd *abfd; /* BFD symbol was found in. */ 116218822Sdim bfd *weak; /* BFD weak symbol was found in. */ 11733965Sjdp } undef; 11833965Sjdp /* bfd_link_hash_defined, bfd_link_hash_defweak. */ 11933965Sjdp struct 12033965Sjdp { 121218822Sdim struct bfd_link_hash_entry *next; 122218822Sdim asection *section; /* Symbol section. */ 12333965Sjdp bfd_vma value; /* Symbol value. */ 12433965Sjdp } def; 12533965Sjdp /* bfd_link_hash_indirect, bfd_link_hash_warning. */ 12633965Sjdp struct 12733965Sjdp { 128218822Sdim struct bfd_link_hash_entry *next; 12933965Sjdp struct bfd_link_hash_entry *link; /* Real symbol. */ 13033965Sjdp const char *warning; /* Warning (bfd_link_hash_warning only). */ 13133965Sjdp } i; 13233965Sjdp /* bfd_link_hash_common. */ 13333965Sjdp struct 13433965Sjdp { 135218822Sdim struct bfd_link_hash_entry *next; 13633965Sjdp /* The linker needs to know three things about common 137130561Sobrien symbols: the size, the alignment, and the section in 138130561Sobrien which the symbol should be placed. We store the size 139130561Sobrien here, and we allocate a small structure to hold the 140130561Sobrien section and the alignment. The alignment is stored as a 141130561Sobrien power of two. We don't store all the information 142130561Sobrien directly because we don't want to increase the size of 143130561Sobrien the union; this structure is a major space user in the 144130561Sobrien linker. */ 14533965Sjdp struct bfd_link_hash_common_entry 14633965Sjdp { 14733965Sjdp unsigned int alignment_power; /* Alignment. */ 14833965Sjdp asection *section; /* Symbol section. */ 14933965Sjdp } *p; 150218822Sdim bfd_size_type size; /* Common symbol size. */ 15133965Sjdp } c; 15233965Sjdp } u; 15333965Sjdp}; 15433965Sjdp 15533965Sjdp/* This is the link hash table. It is a derived class of 15633965Sjdp bfd_hash_table. */ 15733965Sjdp 15833965Sjdpstruct bfd_link_hash_table 15933965Sjdp{ 16033965Sjdp /* The hash table itself. */ 16133965Sjdp struct bfd_hash_table table; 16233965Sjdp /* The back end which created this hash table. This indicates the 16333965Sjdp type of the entries in the hash table, which is sometimes 16433965Sjdp important information when linking object files of different 16533965Sjdp types together. */ 16633965Sjdp const bfd_target *creator; 16733965Sjdp /* A linked list of undefined and common symbols, linked through the 16833965Sjdp next field in the bfd_link_hash_entry structure. */ 16933965Sjdp struct bfd_link_hash_entry *undefs; 17033965Sjdp /* Entries are added to the tail of the undefs list. */ 17133965Sjdp struct bfd_link_hash_entry *undefs_tail; 172130561Sobrien /* The type of the link hash table. */ 17389857Sobrien enum bfd_link_hash_table_type type; 17433965Sjdp}; 17533965Sjdp 176130561Sobrien/* Look up an entry in a link hash table. If FOLLOW is TRUE, this 17733965Sjdp follows bfd_link_hash_indirect and bfd_link_hash_warning links to 17833965Sjdp the real symbol. */ 17933965Sjdpextern struct bfd_link_hash_entry *bfd_link_hash_lookup 180130561Sobrien (struct bfd_link_hash_table *, const char *, bfd_boolean create, 181130561Sobrien bfd_boolean copy, bfd_boolean follow); 18233965Sjdp 18333965Sjdp/* Look up an entry in the main linker hash table if the symbol might 18433965Sjdp be wrapped. This should only be used for references to an 18533965Sjdp undefined symbol, not for definitions of a symbol. */ 18633965Sjdp 18733965Sjdpextern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup 188130561Sobrien (bfd *, struct bfd_link_info *, const char *, bfd_boolean, 189130561Sobrien bfd_boolean, bfd_boolean); 19033965Sjdp 19133965Sjdp/* Traverse a link hash table. */ 19233965Sjdpextern void bfd_link_hash_traverse 193130561Sobrien (struct bfd_link_hash_table *, 194130561Sobrien bfd_boolean (*) (struct bfd_link_hash_entry *, void *), 195130561Sobrien void *); 19633965Sjdp 19733965Sjdp/* Add an entry to the undefs list. */ 19833965Sjdpextern void bfd_link_add_undef 199130561Sobrien (struct bfd_link_hash_table *, struct bfd_link_hash_entry *); 200104834Sobrien 201218822Sdim/* Remove symbols from the undefs list that don't belong there. */ 202218822Sdimextern void bfd_link_repair_undef_list 203218822Sdim (struct bfd_link_hash_table *table); 204218822Sdim 205104834Sobrienstruct bfd_sym_chain 206104834Sobrien{ 207104834Sobrien struct bfd_sym_chain *next; 208104834Sobrien const char *name; 209104834Sobrien}; 21033965Sjdp 211130561Sobrien/* How to handle unresolved symbols. 212130561Sobrien There are four possibilities which are enumerated below: */ 213130561Sobrienenum report_method 214130561Sobrien{ 215130561Sobrien /* This is the initial value when then link_info structure is created. 216130561Sobrien It allows the various stages of the linker to determine whether they 217130561Sobrien allowed to set the value. */ 218130561Sobrien RM_NOT_YET_SET = 0, 219130561Sobrien RM_IGNORE, 220130561Sobrien RM_GENERATE_WARNING, 221130561Sobrien RM_GENERATE_ERROR 222130561Sobrien}; 223130561Sobrien 224218822Sdimstruct bfd_elf_dynamic_list; 225218822Sdim 22633965Sjdp/* This structure holds all the information needed to communicate 22733965Sjdp between BFD and the linker when doing a link. */ 22833965Sjdp 22933965Sjdpstruct bfd_link_info 23033965Sjdp{ 231130561Sobrien /* TRUE if BFD should generate a relocatable object file. */ 232130561Sobrien unsigned int relocatable: 1; 233104834Sobrien 234130561Sobrien /* TRUE if BFD should generate relocation information in the final 235104834Sobrien executable. */ 236130561Sobrien unsigned int emitrelocations: 1; 237104834Sobrien 238130561Sobrien /* TRUE if BFD should generate a "task linked" object file, 239104834Sobrien similar to relocatable but also with globals converted to 240104834Sobrien statics. */ 241130561Sobrien unsigned int task_link: 1; 242104834Sobrien 243130561Sobrien /* TRUE if BFD should generate a shared object. */ 244130561Sobrien unsigned int shared: 1; 245104834Sobrien 246130561Sobrien /* TRUE if BFD should pre-bind symbols in a shared object. */ 247130561Sobrien unsigned int symbolic: 1; 248104834Sobrien 249130561Sobrien /* TRUE if BFD should export all symbols in the dynamic symbol table 25089857Sobrien of an executable, rather than only those used. */ 251130561Sobrien unsigned int export_dynamic: 1; 252104834Sobrien 253130561Sobrien /* TRUE if shared objects should be linked directly, not shared. */ 254130561Sobrien unsigned int static_link: 1; 255104834Sobrien 256130561Sobrien /* TRUE if the output file should be in a traditional format. This 25733965Sjdp is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag 25833965Sjdp on the output file, but may be checked when reading the input 25933965Sjdp files. */ 260130561Sobrien unsigned int traditional_format: 1; 261104834Sobrien 262130561Sobrien /* TRUE if we want to produced optimized output files. This might 26360484Sobrien need much more time and therefore must be explicitly selected. */ 264130561Sobrien unsigned int optimize: 1; 265104834Sobrien 266130561Sobrien /* TRUE if ok to have multiple definition. */ 267130561Sobrien unsigned int allow_multiple_definition: 1; 268104834Sobrien 269130561Sobrien /* TRUE if ok to have version with no definition. */ 270130561Sobrien unsigned int allow_undefined_version: 1; 271104834Sobrien 272218822Sdim /* TRUE if a default symbol version should be created and used for 273218822Sdim exported symbols. */ 274218822Sdim unsigned int create_default_symver: 1; 275218822Sdim 276218822Sdim /* TRUE if a default symbol version should be created and used for 277218822Sdim imported symbols. */ 278218822Sdim unsigned int default_imported_symver: 1; 279218822Sdim 280130561Sobrien /* TRUE if symbols should be retained in memory, FALSE if they 281130561Sobrien should be freed and reread. */ 282130561Sobrien unsigned int keep_memory: 1; 283104834Sobrien 284130561Sobrien /* TRUE if every symbol should be reported back via the notice 285130561Sobrien callback. */ 286130561Sobrien unsigned int notice_all: 1; 287104834Sobrien 288130561Sobrien /* TRUE if executable should not contain copy relocs. 289130561Sobrien Setting this true may result in a non-sharable text segment. */ 290130561Sobrien unsigned int nocopyreloc: 1; 291130561Sobrien 292130561Sobrien /* TRUE if the new ELF dynamic tags are enabled. */ 293130561Sobrien unsigned int new_dtags: 1; 294130561Sobrien 295130561Sobrien /* TRUE if non-PLT relocs should be merged into one reloc section 296130561Sobrien and sorted so that relocs against the same symbol come together. */ 297130561Sobrien unsigned int combreloc: 1; 298130561Sobrien 299130561Sobrien /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment 300130561Sobrien should be created. */ 301130561Sobrien unsigned int eh_frame_hdr: 1; 302130561Sobrien 303130561Sobrien /* TRUE if global symbols in discarded sections should be stripped. */ 304130561Sobrien unsigned int strip_discarded: 1; 305130561Sobrien 306130561Sobrien /* TRUE if generating a position independent executable. */ 307130561Sobrien unsigned int pie: 1; 308130561Sobrien 309130561Sobrien /* TRUE if generating an executable, position independent or not. */ 310130561Sobrien unsigned int executable : 1; 311130561Sobrien 312130561Sobrien /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X 313130561Sobrien flags. */ 314130561Sobrien unsigned int execstack: 1; 315130561Sobrien 316130561Sobrien /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W 317130561Sobrien flags. */ 318130561Sobrien unsigned int noexecstack: 1; 319130561Sobrien 320218822Sdim /* TRUE if PT_GNU_RELRO segment should be created. */ 321218822Sdim unsigned int relro: 1; 322218822Sdim 323218822Sdim /* TRUE if we should warn when adding a DT_TEXTREL to a shared object. */ 324218822Sdim unsigned int warn_shared_textrel: 1; 325218822Sdim 326218822Sdim /* TRUE if unreferenced sections should be removed. */ 327218822Sdim unsigned int gc_sections: 1; 328218822Sdim 329218822Sdim /* TRUE if user shoudl be informed of removed unreferenced sections. */ 330218822Sdim unsigned int print_gc_sections: 1; 331218822Sdim 332218822Sdim /* TRUE if .hash section should be created. */ 333218822Sdim unsigned int emit_hash: 1; 334218822Sdim 335218822Sdim /* TRUE if .gnu.hash section should be created. */ 336218822Sdim unsigned int emit_gnu_hash: 1; 337218822Sdim 338218822Sdim /* If TRUE reduce memory overheads, at the expense of speed. This will 339218822Sdim cause map file generation to use an O(N^2) algorithm and disable 340218822Sdim caching ELF symbol buffer. */ 341218822Sdim unsigned int reduce_memory_overheads: 1; 342218822Sdim 343218822Sdim /* TRUE if all data symbols should be dynamic. */ 344218822Sdim unsigned int dynamic_data: 1; 345218822Sdim 346218822Sdim /* TRUE if some symbols have to be dynamic, controlled by 347218822Sdim --dynamic-list command line options. */ 348218822Sdim unsigned int dynamic: 1; 349218822Sdim 350130561Sobrien /* What to do with unresolved symbols in an object file. 351130561Sobrien When producing executables the default is GENERATE_ERROR. 352130561Sobrien When producing shared libraries the default is IGNORE. The 353130561Sobrien assumption with shared libraries is that the reference will be 354130561Sobrien resolved at load/execution time. */ 355130561Sobrien enum report_method unresolved_syms_in_objects; 356130561Sobrien 357130561Sobrien /* What to do with unresolved symbols in a shared library. 358130561Sobrien The same defaults apply. */ 359130561Sobrien enum report_method unresolved_syms_in_shared_libs; 360130561Sobrien 36133965Sjdp /* Which symbols to strip. */ 36233965Sjdp enum bfd_link_strip strip; 363104834Sobrien 36433965Sjdp /* Which local symbols to discard. */ 36533965Sjdp enum bfd_link_discard discard; 366104834Sobrien 367130561Sobrien /* Criteria for skipping symbols when detemining 368130561Sobrien whether to include an object from an archive. */ 369130561Sobrien enum bfd_link_common_skip_ar_aymbols common_skip_ar_aymbols; 370104834Sobrien 371130561Sobrien /* Char that may appear as the first char of a symbol, but should be 372130561Sobrien skipped (like symbol_leading_char) when looking up symbols in 373130561Sobrien wrap_hash. Used by PowerPC Linux for 'dot' symbols. */ 374130561Sobrien char wrap_char; 375104834Sobrien 376130561Sobrien /* Function callbacks. */ 377130561Sobrien const struct bfd_link_callbacks *callbacks; 378104834Sobrien 37933965Sjdp /* Hash table handled by BFD. */ 38033965Sjdp struct bfd_link_hash_table *hash; 381104834Sobrien 38233965Sjdp /* Hash table of symbols to keep. This is NULL unless strip is 38333965Sjdp strip_some. */ 38433965Sjdp struct bfd_hash_table *keep_hash; 385104834Sobrien 38633965Sjdp /* Hash table of symbols to report back via the notice callback. If 387130561Sobrien this is NULL, and notice_all is FALSE, then no symbols are 38833965Sjdp reported back. */ 38933965Sjdp struct bfd_hash_table *notice_hash; 390104834Sobrien 39133965Sjdp /* Hash table of symbols which are being wrapped (the --wrap linker 39233965Sjdp option). If this is NULL, no symbols are being wrapped. */ 39333965Sjdp struct bfd_hash_table *wrap_hash; 394104834Sobrien 395130561Sobrien /* The list of input BFD's involved in the link. These are chained 396130561Sobrien together via the link_next field. */ 397130561Sobrien bfd *input_bfds; 398218822Sdim bfd **input_bfds_tail; 399130561Sobrien 400130561Sobrien /* If a symbol should be created for each input BFD, this is section 401130561Sobrien where those symbols should be placed. It must be a section in 402130561Sobrien the output BFD. It may be NULL, in which case no such symbols 403130561Sobrien will be created. This is to support CREATE_OBJECT_SYMBOLS in the 404130561Sobrien linker command language. */ 405130561Sobrien asection *create_object_symbols_section; 406130561Sobrien 407130561Sobrien /* List of global symbol names that are starting points for marking 408130561Sobrien sections against garbage collection. */ 409130561Sobrien struct bfd_sym_chain *gc_sym_list; 410130561Sobrien 41133965Sjdp /* If a base output file is wanted, then this points to it */ 412130561Sobrien void *base_file; 41360484Sobrien 41460484Sobrien /* The function to call when the executable or shared object is 41560484Sobrien loaded. */ 41660484Sobrien const char *init_function; 417104834Sobrien 41860484Sobrien /* The function to call when the executable or shared object is 41960484Sobrien unloaded. */ 42060484Sobrien const char *fini_function; 42177298Sobrien 422218822Sdim /* Number of relaxation passes. Usually only one relaxation pass 423218822Sdim is needed. But a backend can have as many relaxation passes as 424218822Sdim necessary. During bfd_relax_section call, it is set to the 425218822Sdim current pass, starting from 0. */ 426218822Sdim int relax_pass; 427218822Sdim 428218822Sdim /* Number of relaxation trips. This number is incremented every 429218822Sdim time the relaxation pass is restarted due to a previous 430218822Sdim relaxation returning true in *AGAIN. */ 431218822Sdim int relax_trip; 432218822Sdim 433130561Sobrien /* Non-zero if auto-import thunks for DATA items in pei386 DLLs 434104834Sobrien should be generated/linked against. Set to 1 if this feature 435104834Sobrien is explicitly requested by the user, -1 if enabled by default. */ 436104834Sobrien int pei386_auto_import; 43789857Sobrien 438130561Sobrien /* Non-zero if runtime relocs for DATA items with non-zero addends 439130561Sobrien in pei386 DLLs should be generated. Set to 1 if this feature 440130561Sobrien is explicitly requested by the user, -1 if enabled by default. */ 441130561Sobrien int pei386_runtime_pseudo_reloc; 44289857Sobrien 443130561Sobrien /* How many spare .dynamic DT_NULL entries should be added? */ 444130561Sobrien unsigned int spare_dynamic_tags; 44589857Sobrien 446130561Sobrien /* May be used to set DT_FLAGS for ELF. */ 447130561Sobrien bfd_vma flags; 44889857Sobrien 449130561Sobrien /* May be used to set DT_FLAGS_1 for ELF. */ 450130561Sobrien bfd_vma flags_1; 451218822Sdim 452218822Sdim /* Start and end of RELRO region. */ 453218822Sdim bfd_vma relro_start, relro_end; 454218822Sdim 455218822Sdim /* List of symbols should be dynamic. */ 456218822Sdim struct bfd_elf_dynamic_list *dynamic_list; 45733965Sjdp}; 45833965Sjdp 459218822Sdim/* This structures holds a set of callback functions. These are called 460218822Sdim by the BFD linker routines. Except for the info functions, the first 461218822Sdim argument to each callback function is the bfd_link_info structure 462218822Sdim being used and each function returns a boolean value. If the 463218822Sdim function returns FALSE, then the BFD function which called it should 464218822Sdim return with a failure indication. */ 46533965Sjdp 46633965Sjdpstruct bfd_link_callbacks 46733965Sjdp{ 46833965Sjdp /* A function which is called when an object is added from an 46933965Sjdp archive. ABFD is the archive element being added. NAME is the 47033965Sjdp name of the symbol which caused the archive element to be pulled 47133965Sjdp in. */ 472130561Sobrien bfd_boolean (*add_archive_element) 473130561Sobrien (struct bfd_link_info *, bfd *abfd, const char *name); 47433965Sjdp /* A function which is called when a symbol is found with multiple 47533965Sjdp definitions. NAME is the symbol which is defined multiple times. 47633965Sjdp OBFD is the old BFD, OSEC is the old section, OVAL is the old 47733965Sjdp value, NBFD is the new BFD, NSEC is the new section, and NVAL is 47833965Sjdp the new value. OBFD may be NULL. OSEC and NSEC may be 47933965Sjdp bfd_com_section or bfd_ind_section. */ 480130561Sobrien bfd_boolean (*multiple_definition) 481130561Sobrien (struct bfd_link_info *, const char *name, 482130561Sobrien bfd *obfd, asection *osec, bfd_vma oval, 483130561Sobrien bfd *nbfd, asection *nsec, bfd_vma nval); 48433965Sjdp /* A function which is called when a common symbol is defined 48533965Sjdp multiple times. NAME is the symbol appearing multiple times. 48633965Sjdp OBFD is the BFD of the existing symbol; it may be NULL if this is 48733965Sjdp not known. OTYPE is the type of the existing symbol, which may 48833965Sjdp be bfd_link_hash_defined, bfd_link_hash_defweak, 48933965Sjdp bfd_link_hash_common, or bfd_link_hash_indirect. If OTYPE is 49033965Sjdp bfd_link_hash_common, OSIZE is the size of the existing symbol. 49133965Sjdp NBFD is the BFD of the new symbol. NTYPE is the type of the new 49233965Sjdp symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or 49333965Sjdp bfd_link_hash_indirect. If NTYPE is bfd_link_hash_common, NSIZE 49433965Sjdp is the size of the new symbol. */ 495130561Sobrien bfd_boolean (*multiple_common) 496130561Sobrien (struct bfd_link_info *, const char *name, 497130561Sobrien bfd *obfd, enum bfd_link_hash_type otype, bfd_vma osize, 498130561Sobrien bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize); 49933965Sjdp /* A function which is called to add a symbol to a set. ENTRY is 50033965Sjdp the link hash table entry for the set itself (e.g., 50133965Sjdp __CTOR_LIST__). RELOC is the relocation to use for an entry in 502130561Sobrien the set when generating a relocatable file, and is also used to 50333965Sjdp get the size of the entry when generating an executable file. 50433965Sjdp ABFD, SEC and VALUE identify the value to add to the set. */ 505130561Sobrien bfd_boolean (*add_to_set) 506130561Sobrien (struct bfd_link_info *, struct bfd_link_hash_entry *entry, 507130561Sobrien bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value); 50833965Sjdp /* A function which is called when the name of a g++ constructor or 50933965Sjdp destructor is found. This is only called by some object file 510130561Sobrien formats. CONSTRUCTOR is TRUE for a constructor, FALSE for a 51133965Sjdp destructor. This will use BFD_RELOC_CTOR when generating a 512130561Sobrien relocatable file. NAME is the name of the symbol found. ABFD, 51333965Sjdp SECTION and VALUE are the value of the symbol. */ 514130561Sobrien bfd_boolean (*constructor) 515130561Sobrien (struct bfd_link_info *, bfd_boolean constructor, const char *name, 516130561Sobrien bfd *abfd, asection *sec, bfd_vma value); 51733965Sjdp /* A function which is called to issue a linker warning. For 51833965Sjdp example, this is called when there is a reference to a warning 51933965Sjdp symbol. WARNING is the warning to be issued. SYMBOL is the name 52033965Sjdp of the symbol which triggered the warning; it may be NULL if 52133965Sjdp there is none. ABFD, SECTION and ADDRESS identify the location 52233965Sjdp which trigerred the warning; either ABFD or SECTION or both may 52333965Sjdp be NULL if the location is not known. */ 524130561Sobrien bfd_boolean (*warning) 525130561Sobrien (struct bfd_link_info *, const char *warning, const char *symbol, 526130561Sobrien bfd *abfd, asection *section, bfd_vma address); 52733965Sjdp /* A function which is called when a relocation is attempted against 52833965Sjdp an undefined symbol. NAME is the symbol which is undefined. 52933965Sjdp ABFD, SECTION and ADDRESS identify the location from which the 53060484Sobrien reference is made. FATAL indicates whether an undefined symbol is 53160484Sobrien a fatal error or not. In some cases SECTION may be NULL. */ 532130561Sobrien bfd_boolean (*undefined_symbol) 533130561Sobrien (struct bfd_link_info *, const char *name, bfd *abfd, 534130561Sobrien asection *section, bfd_vma address, bfd_boolean fatal); 535218822Sdim /* A function which is called when a reloc overflow occurs. ENTRY is 536218822Sdim the link hash table entry for the symbol the reloc is against. 537218822Sdim NAME is the name of the local symbol or section the reloc is 538218822Sdim against, RELOC_NAME is the name of the relocation, and ADDEND is 539218822Sdim any addend that is used. ABFD, SECTION and ADDRESS identify the 54033965Sjdp location at which the overflow occurs; if this is the result of a 54133965Sjdp bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 54233965Sjdp ABFD will be NULL. */ 543130561Sobrien bfd_boolean (*reloc_overflow) 544218822Sdim (struct bfd_link_info *, struct bfd_link_hash_entry *entry, 545218822Sdim const char *name, const char *reloc_name, bfd_vma addend, 546218822Sdim bfd *abfd, asection *section, bfd_vma address); 54733965Sjdp /* A function which is called when a dangerous reloc is performed. 548218822Sdim MESSAGE is an appropriate message. 54933965Sjdp ABFD, SECTION and ADDRESS identify the location at which the 55033965Sjdp problem occurred; if this is the result of a 55133965Sjdp bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 55233965Sjdp ABFD will be NULL. */ 553130561Sobrien bfd_boolean (*reloc_dangerous) 554130561Sobrien (struct bfd_link_info *, const char *message, 555130561Sobrien bfd *abfd, asection *section, bfd_vma address); 55633965Sjdp /* A function which is called when a reloc is found to be attached 55733965Sjdp to a symbol which is not being written out. NAME is the name of 55833965Sjdp the symbol. ABFD, SECTION and ADDRESS identify the location of 55933965Sjdp the reloc; if this is the result of a 56033965Sjdp bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 56133965Sjdp ABFD will be NULL. */ 562130561Sobrien bfd_boolean (*unattached_reloc) 563130561Sobrien (struct bfd_link_info *, const char *name, 564130561Sobrien bfd *abfd, asection *section, bfd_vma address); 56533965Sjdp /* A function which is called when a symbol in notice_hash is 56633965Sjdp defined or referenced. NAME is the symbol. ABFD, SECTION and 56733965Sjdp ADDRESS are the value of the symbol. If SECTION is 56833965Sjdp bfd_und_section, this is a reference. */ 569130561Sobrien bfd_boolean (*notice) 570130561Sobrien (struct bfd_link_info *, const char *name, 571130561Sobrien bfd *abfd, asection *section, bfd_vma address); 572218822Sdim /* Error or warning link info message. */ 573218822Sdim void (*einfo) 574218822Sdim (const char *fmt, ...); 575218822Sdim /* General link info message. */ 576218822Sdim void (*info) 577218822Sdim (const char *fmt, ...); 578218822Sdim /* Message to be printed in linker map file. */ 579218822Sdim void (*minfo) 580218822Sdim (const char *fmt, ...); 581218822Sdim /* This callback provides a chance for users of the BFD library to 582218822Sdim override its decision about whether to place two adjacent sections 583218822Sdim into the same segment. */ 584218822Sdim bfd_boolean (*override_segment_assignment) 585218822Sdim (struct bfd_link_info *, bfd * abfd, 586218822Sdim asection * current_section, asection * previous_section, 587218822Sdim bfd_boolean new_segment); 58833965Sjdp}; 58933965Sjdp 59033965Sjdp/* The linker builds link_order structures which tell the code how to 59133965Sjdp include input data in the output file. */ 59233965Sjdp 59333965Sjdp/* These are the types of link_order structures. */ 59433965Sjdp 59533965Sjdpenum bfd_link_order_type 59633965Sjdp{ 59733965Sjdp bfd_undefined_link_order, /* Undefined. */ 59833965Sjdp bfd_indirect_link_order, /* Built from a section. */ 59933965Sjdp bfd_data_link_order, /* Set to explicit data. */ 60033965Sjdp bfd_section_reloc_link_order, /* Relocate against a section. */ 60133965Sjdp bfd_symbol_reloc_link_order /* Relocate against a symbol. */ 60233965Sjdp}; 60333965Sjdp 60433965Sjdp/* This is the link_order structure itself. These form a chain 605218822Sdim attached to the output section whose contents they are describing. */ 60633965Sjdp 607130561Sobrienstruct bfd_link_order 60833965Sjdp{ 60933965Sjdp /* Next link_order in chain. */ 61033965Sjdp struct bfd_link_order *next; 61133965Sjdp /* Type of link_order. */ 61233965Sjdp enum bfd_link_order_type type; 61333965Sjdp /* Offset within output section. */ 614130561Sobrien bfd_vma offset; 61533965Sjdp /* Size within output section. */ 61633965Sjdp bfd_size_type size; 61733965Sjdp /* Type specific information. */ 618130561Sobrien union 61933965Sjdp { 620130561Sobrien struct 62133965Sjdp { 62233965Sjdp /* Section to include. If this is used, then 62333965Sjdp section->output_section must be the section the 62433965Sjdp link_order is attached to, section->output_offset must 625218822Sdim equal the link_order offset field, and section->size 62633965Sjdp must equal the link_order size field. Maybe these 62733965Sjdp restrictions should be relaxed someday. */ 62833965Sjdp asection *section; 62933965Sjdp } indirect; 63033965Sjdp struct 63133965Sjdp { 632104834Sobrien /* Size of contents, or zero when contents size == size 633104834Sobrien within output section. 634104834Sobrien A non-zero value allows filling of the output section 635104834Sobrien with an arbitrary repeated pattern. */ 636104834Sobrien unsigned int size; 637104834Sobrien /* Data to put into file. */ 63833965Sjdp bfd_byte *contents; 63933965Sjdp } data; 64033965Sjdp struct 64133965Sjdp { 64233965Sjdp /* Description of reloc to generate. Used for 64333965Sjdp bfd_section_reloc_link_order and 64433965Sjdp bfd_symbol_reloc_link_order. */ 64533965Sjdp struct bfd_link_order_reloc *p; 64633965Sjdp } reloc; 64733965Sjdp } u; 64833965Sjdp}; 64933965Sjdp 65033965Sjdp/* A linker order of type bfd_section_reloc_link_order or 65133965Sjdp bfd_symbol_reloc_link_order means to create a reloc against a 65233965Sjdp section or symbol, respectively. This is used to implement -Ur to 65333965Sjdp generate relocs for the constructor tables. The 65433965Sjdp bfd_link_order_reloc structure describes the reloc that BFD should 65533965Sjdp create. It is similar to a arelent, but I didn't use arelent 65633965Sjdp because the linker does not know anything about most symbols, and 65733965Sjdp any asymbol structure it creates will be partially meaningless. 65833965Sjdp This information could logically be in the bfd_link_order struct, 65933965Sjdp but I didn't want to waste the space since these types of relocs 66033965Sjdp are relatively rare. */ 66133965Sjdp 66233965Sjdpstruct bfd_link_order_reloc 66333965Sjdp{ 66433965Sjdp /* Reloc type. */ 66533965Sjdp bfd_reloc_code_real_type reloc; 66633965Sjdp 66733965Sjdp union 66833965Sjdp { 66933965Sjdp /* For type bfd_section_reloc_link_order, this is the section 67033965Sjdp the reloc should be against. This must be a section in the 67133965Sjdp output BFD, not any of the input BFDs. */ 67233965Sjdp asection *section; 67333965Sjdp /* For type bfd_symbol_reloc_link_order, this is the name of the 67433965Sjdp symbol the reloc should be against. */ 67533965Sjdp const char *name; 67633965Sjdp } u; 67733965Sjdp 67833965Sjdp /* Addend to use. The object file should contain zero. The BFD 67933965Sjdp backend is responsible for filling in the contents of the object 68033965Sjdp file correctly. For some object file formats (e.g., COFF) the 68133965Sjdp addend must be stored into in the object file, and for some 68233965Sjdp (e.g., SPARC a.out) it is kept in the reloc. */ 68333965Sjdp bfd_vma addend; 68433965Sjdp}; 68533965Sjdp 68633965Sjdp/* Allocate a new link_order for a section. */ 687130561Sobrienextern struct bfd_link_order *bfd_new_link_order (bfd *, asection *); 68833965Sjdp 68933965Sjdp/* These structures are used to describe version information for the 69033965Sjdp ELF linker. These structures could be manipulated entirely inside 69133965Sjdp BFD, but it would be a pain. Instead, the regular linker sets up 69233965Sjdp these structures, and then passes them into BFD. */ 69333965Sjdp 694130561Sobrien/* Glob pattern for a version. */ 69533965Sjdp 69633965Sjdpstruct bfd_elf_version_expr 69733965Sjdp{ 698130561Sobrien /* Next glob pattern for this version. */ 69933965Sjdp struct bfd_elf_version_expr *next; 700130561Sobrien /* Glob pattern. */ 70160484Sobrien const char *pattern; 702130561Sobrien /* NULL for a glob pattern, otherwise a straight symbol. */ 703130561Sobrien const char *symbol; 704104834Sobrien /* Defined by ".symver". */ 705130561Sobrien unsigned int symver : 1; 706104834Sobrien /* Defined by version script. */ 707104834Sobrien unsigned int script : 1; 708130561Sobrien /* Pattern type. */ 709130561Sobrien#define BFD_ELF_VERSION_C_TYPE 1 710130561Sobrien#define BFD_ELF_VERSION_CXX_TYPE 2 711130561Sobrien#define BFD_ELF_VERSION_JAVA_TYPE 4 712130561Sobrien unsigned int mask : 3; 71333965Sjdp}; 71433965Sjdp 715130561Sobrienstruct bfd_elf_version_expr_head 716130561Sobrien{ 717130561Sobrien /* List of all patterns, both wildcards and non-wildcards. */ 718130561Sobrien struct bfd_elf_version_expr *list; 719130561Sobrien /* Hash table for non-wildcards. */ 720130561Sobrien void *htab; 721130561Sobrien /* Remaining patterns. */ 722130561Sobrien struct bfd_elf_version_expr *remaining; 723130561Sobrien /* What kind of pattern types are present in list (bitmask). */ 724130561Sobrien unsigned int mask; 725130561Sobrien}; 726130561Sobrien 72733965Sjdp/* Version dependencies. */ 72833965Sjdp 72933965Sjdpstruct bfd_elf_version_deps 73033965Sjdp{ 73133965Sjdp /* Next dependency for this version. */ 73233965Sjdp struct bfd_elf_version_deps *next; 73333965Sjdp /* The version which this version depends upon. */ 73433965Sjdp struct bfd_elf_version_tree *version_needed; 73533965Sjdp}; 73633965Sjdp 73733965Sjdp/* A node in the version tree. */ 73833965Sjdp 73933965Sjdpstruct bfd_elf_version_tree 74033965Sjdp{ 74133965Sjdp /* Next version. */ 74233965Sjdp struct bfd_elf_version_tree *next; 74333965Sjdp /* Name of this version. */ 74433965Sjdp const char *name; 74533965Sjdp /* Version number. */ 74633965Sjdp unsigned int vernum; 74733965Sjdp /* Regular expressions for global symbols in this version. */ 748130561Sobrien struct bfd_elf_version_expr_head globals; 74933965Sjdp /* Regular expressions for local symbols in this version. */ 750130561Sobrien struct bfd_elf_version_expr_head locals; 75133965Sjdp /* List of versions which this version depends upon. */ 75233965Sjdp struct bfd_elf_version_deps *deps; 75333965Sjdp /* Index of the version name. This is used within BFD. */ 75433965Sjdp unsigned int name_indx; 75533965Sjdp /* Whether this version tree was used. This is used within BFD. */ 75633965Sjdp int used; 757130561Sobrien /* Matching hook. */ 758130561Sobrien struct bfd_elf_version_expr *(*match) 759130561Sobrien (struct bfd_elf_version_expr_head *head, 760130561Sobrien struct bfd_elf_version_expr *prev, const char *sym); 76133965Sjdp}; 76233965Sjdp 763218822Sdimstruct bfd_elf_dynamic_list 764218822Sdim{ 765218822Sdim struct bfd_elf_version_expr_head head; 766218822Sdim struct bfd_elf_version_expr *(*match) 767218822Sdim (struct bfd_elf_version_expr_head *head, 768218822Sdim struct bfd_elf_version_expr *prev, const char *sym); 769218822Sdim}; 770218822Sdim 77133965Sjdp#endif 772