1130812Smarcel/* bfdlink.h -- header file for BFD link routines 2130812Smarcel Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 3130812Smarcel Free Software Foundation, Inc. 4130812Smarcel Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support. 5130812Smarcel 6130812Smarcel This file is part of BFD, the Binary File Descriptor library. 7130812Smarcel 8130812Smarcel This program is free software; you can redistribute it and/or modify 9130812Smarcel it under the terms of the GNU General Public License as published by 10130812Smarcel the Free Software Foundation; either version 2 of the License, or 11130812Smarcel (at your option) any later version. 12130812Smarcel 13130812Smarcel This program is distributed in the hope that it will be useful, 14130812Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 15130812Smarcel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16130812Smarcel GNU General Public License for more details. 17130812Smarcel 18130812Smarcel You should have received a copy of the GNU General Public License 19130812Smarcel along with this program; if not, write to the Free Software 20130812Smarcel Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21130812Smarcel 22130812Smarcel#ifndef BFDLINK_H 23130812Smarcel#define BFDLINK_H 24130812Smarcel 25130812Smarcel/* Which symbols to strip during a link. */ 26130812Smarcelenum bfd_link_strip 27130812Smarcel{ 28130812Smarcel strip_none, /* Don't strip any symbols. */ 29130812Smarcel strip_debugger, /* Strip debugging symbols. */ 30130812Smarcel strip_some, /* keep_hash is the list of symbols to keep. */ 31130812Smarcel strip_all /* Strip all symbols. */ 32130812Smarcel}; 33130812Smarcel 34130812Smarcel/* Which local symbols to discard during a link. This is irrelevant 35130812Smarcel if strip_all is used. */ 36130812Smarcelenum bfd_link_discard 37130812Smarcel{ 38130812Smarcel discard_sec_merge, /* Discard local temporary symbols in SEC_MERGE 39130812Smarcel sections. */ 40130812Smarcel discard_none, /* Don't discard any locals. */ 41130812Smarcel discard_l, /* Discard local temporary symbols. */ 42130812Smarcel discard_all /* Discard all locals. */ 43130812Smarcel}; 44130812Smarcel 45130812Smarcel/* Describes the type of hash table entry structure being used. 46130812Smarcel Different hash table structure have different fields and so 47130812Smarcel support different linking features. */ 48130812Smarcelenum bfd_link_hash_table_type 49130812Smarcel { 50130812Smarcel bfd_link_generic_hash_table, 51130812Smarcel bfd_link_elf_hash_table 52130812Smarcel }; 53130812Smarcel 54130812Smarcel/* These are the possible types of an entry in the BFD link hash 55130812Smarcel table. */ 56130812Smarcel 57130812Smarcelenum bfd_link_hash_type 58130812Smarcel{ 59130812Smarcel bfd_link_hash_new, /* Symbol is new. */ 60130812Smarcel bfd_link_hash_undefined, /* Symbol seen before, but undefined. */ 61130812Smarcel bfd_link_hash_undefweak, /* Symbol is weak and undefined. */ 62130812Smarcel bfd_link_hash_defined, /* Symbol is defined. */ 63130812Smarcel bfd_link_hash_defweak, /* Symbol is weak and defined. */ 64130812Smarcel bfd_link_hash_common, /* Symbol is common. */ 65130812Smarcel bfd_link_hash_indirect, /* Symbol is an indirect link. */ 66130812Smarcel bfd_link_hash_warning /* Like indirect, but warn if referenced. */ 67130812Smarcel}; 68130812Smarcel 69130812Smarcelenum bfd_link_common_skip_ar_aymbols 70130812Smarcel{ 71130812Smarcel bfd_link_common_skip_none, 72130812Smarcel bfd_link_common_skip_text, 73130812Smarcel bfd_link_common_skip_data, 74130812Smarcel bfd_link_common_skip_all 75130812Smarcel}; 76130812Smarcel 77130812Smarcel/* The linking routines use a hash table which uses this structure for 78130812Smarcel its elements. */ 79130812Smarcel 80130812Smarcelstruct bfd_link_hash_entry 81130812Smarcel{ 82130812Smarcel /* Base hash table entry structure. */ 83130812Smarcel struct bfd_hash_entry root; 84130812Smarcel 85130812Smarcel /* Type of this entry. */ 86130812Smarcel enum bfd_link_hash_type type; 87130812Smarcel 88130812Smarcel /* Undefined and common symbols are kept in a linked list through 89130812Smarcel this field. This field is not in the union because that would 90130812Smarcel force us to remove entries from the list when we changed their 91130812Smarcel type, which would force the list to be doubly linked, which would 92130812Smarcel waste more memory. When an undefined or common symbol is 93130812Smarcel created, it should be added to this list, the head of which is in 94130812Smarcel the link hash table itself. As symbols are defined, they need 95130812Smarcel not be removed from the list; anything which reads the list must 96130812Smarcel doublecheck the symbol type. 97130812Smarcel 98130812Smarcel Weak symbols are not kept on this list. 99130812Smarcel 100130812Smarcel Defined and defweak symbols use this field as a reference marker. 101130812Smarcel If the field is not NULL, or this structure is the tail of the 102130812Smarcel undefined symbol list, the symbol has been referenced. If the 103130812Smarcel symbol is undefined and becomes defined, this field will 104130812Smarcel automatically be non-NULL since the symbol will have been on the 105130812Smarcel undefined symbol list. */ 106130812Smarcel struct bfd_link_hash_entry *und_next; 107130812Smarcel 108130812Smarcel /* A union of information depending upon the type. */ 109130812Smarcel union 110130812Smarcel { 111130812Smarcel /* Nothing is kept for bfd_hash_new. */ 112130812Smarcel /* bfd_link_hash_undefined, bfd_link_hash_undefweak. */ 113130812Smarcel struct 114130812Smarcel { 115130812Smarcel bfd *abfd; /* BFD symbol was found in. */ 116130812Smarcel } undef; 117130812Smarcel /* bfd_link_hash_defined, bfd_link_hash_defweak. */ 118130812Smarcel struct 119130812Smarcel { 120130812Smarcel bfd_vma value; /* Symbol value. */ 121130812Smarcel asection *section; /* Symbol section. */ 122130812Smarcel } def; 123130812Smarcel /* bfd_link_hash_indirect, bfd_link_hash_warning. */ 124130812Smarcel struct 125130812Smarcel { 126130812Smarcel struct bfd_link_hash_entry *link; /* Real symbol. */ 127130812Smarcel const char *warning; /* Warning (bfd_link_hash_warning only). */ 128130812Smarcel } i; 129130812Smarcel /* bfd_link_hash_common. */ 130130812Smarcel struct 131130812Smarcel { 132130812Smarcel /* The linker needs to know three things about common 133130812Smarcel symbols: the size, the alignment, and the section in 134130812Smarcel which the symbol should be placed. We store the size 135130812Smarcel here, and we allocate a small structure to hold the 136130812Smarcel section and the alignment. The alignment is stored as a 137130812Smarcel power of two. We don't store all the information 138130812Smarcel directly because we don't want to increase the size of 139130812Smarcel the union; this structure is a major space user in the 140130812Smarcel linker. */ 141130812Smarcel bfd_size_type size; /* Common symbol size. */ 142130812Smarcel struct bfd_link_hash_common_entry 143130812Smarcel { 144130812Smarcel unsigned int alignment_power; /* Alignment. */ 145130812Smarcel asection *section; /* Symbol section. */ 146130812Smarcel } *p; 147130812Smarcel } c; 148130812Smarcel } u; 149130812Smarcel}; 150130812Smarcel 151130812Smarcel/* This is the link hash table. It is a derived class of 152130812Smarcel bfd_hash_table. */ 153130812Smarcel 154130812Smarcelstruct bfd_link_hash_table 155130812Smarcel{ 156130812Smarcel /* The hash table itself. */ 157130812Smarcel struct bfd_hash_table table; 158130812Smarcel /* The back end which created this hash table. This indicates the 159130812Smarcel type of the entries in the hash table, which is sometimes 160130812Smarcel important information when linking object files of different 161130812Smarcel types together. */ 162130812Smarcel const bfd_target *creator; 163130812Smarcel /* A linked list of undefined and common symbols, linked through the 164130812Smarcel next field in the bfd_link_hash_entry structure. */ 165130812Smarcel struct bfd_link_hash_entry *undefs; 166130812Smarcel /* Entries are added to the tail of the undefs list. */ 167130812Smarcel struct bfd_link_hash_entry *undefs_tail; 168130812Smarcel /* The type of the link hash table. */ 169130812Smarcel enum bfd_link_hash_table_type type; 170130812Smarcel}; 171130812Smarcel 172130812Smarcel/* Look up an entry in a link hash table. If FOLLOW is TRUE, this 173130812Smarcel follows bfd_link_hash_indirect and bfd_link_hash_warning links to 174130812Smarcel the real symbol. */ 175130812Smarcelextern struct bfd_link_hash_entry *bfd_link_hash_lookup 176130812Smarcel (struct bfd_link_hash_table *, const char *, bfd_boolean create, 177130812Smarcel bfd_boolean copy, bfd_boolean follow); 178130812Smarcel 179130812Smarcel/* Look up an entry in the main linker hash table if the symbol might 180130812Smarcel be wrapped. This should only be used for references to an 181130812Smarcel undefined symbol, not for definitions of a symbol. */ 182130812Smarcel 183130812Smarcelextern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup 184130812Smarcel (bfd *, struct bfd_link_info *, const char *, bfd_boolean, 185130812Smarcel bfd_boolean, bfd_boolean); 186130812Smarcel 187130812Smarcel/* Traverse a link hash table. */ 188130812Smarcelextern void bfd_link_hash_traverse 189130812Smarcel (struct bfd_link_hash_table *, 190130812Smarcel bfd_boolean (*) (struct bfd_link_hash_entry *, void *), 191130812Smarcel void *); 192130812Smarcel 193130812Smarcel/* Add an entry to the undefs list. */ 194130812Smarcelextern void bfd_link_add_undef 195130812Smarcel (struct bfd_link_hash_table *, struct bfd_link_hash_entry *); 196130812Smarcel 197130812Smarcelstruct bfd_sym_chain 198130812Smarcel{ 199130812Smarcel struct bfd_sym_chain *next; 200130812Smarcel const char *name; 201130812Smarcel}; 202130812Smarcel 203130812Smarcel/* How to handle unresolved symbols. 204130812Smarcel There are four possibilities which are enumerated below: */ 205130812Smarcelenum report_method 206130812Smarcel{ 207130812Smarcel /* This is the initial value when then link_info structure is created. 208130812Smarcel It allows the various stages of the linker to determine whether they 209130812Smarcel allowed to set the value. */ 210130812Smarcel RM_NOT_YET_SET = 0, 211130812Smarcel RM_IGNORE, 212130812Smarcel RM_GENERATE_WARNING, 213130812Smarcel RM_GENERATE_ERROR 214130812Smarcel}; 215130812Smarcel 216130812Smarcel/* This structure holds all the information needed to communicate 217130812Smarcel between BFD and the linker when doing a link. */ 218130812Smarcel 219130812Smarcelstruct bfd_link_info 220130812Smarcel{ 221130812Smarcel /* TRUE if BFD should generate a relocatable object file. */ 222130812Smarcel unsigned int relocatable: 1; 223130812Smarcel 224130812Smarcel /* TRUE if BFD should generate relocation information in the final 225130812Smarcel executable. */ 226130812Smarcel unsigned int emitrelocations: 1; 227130812Smarcel 228130812Smarcel /* TRUE if BFD should generate a "task linked" object file, 229130812Smarcel similar to relocatable but also with globals converted to 230130812Smarcel statics. */ 231130812Smarcel unsigned int task_link: 1; 232130812Smarcel 233130812Smarcel /* TRUE if BFD should generate a shared object. */ 234130812Smarcel unsigned int shared: 1; 235130812Smarcel 236130812Smarcel /* TRUE if BFD should pre-bind symbols in a shared object. */ 237130812Smarcel unsigned int symbolic: 1; 238130812Smarcel 239130812Smarcel /* TRUE if BFD should export all symbols in the dynamic symbol table 240130812Smarcel of an executable, rather than only those used. */ 241130812Smarcel unsigned int export_dynamic: 1; 242130812Smarcel 243130812Smarcel /* TRUE if shared objects should be linked directly, not shared. */ 244130812Smarcel unsigned int static_link: 1; 245130812Smarcel 246130812Smarcel /* TRUE if the output file should be in a traditional format. This 247130812Smarcel is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag 248130812Smarcel on the output file, but may be checked when reading the input 249130812Smarcel files. */ 250130812Smarcel unsigned int traditional_format: 1; 251130812Smarcel 252130812Smarcel /* TRUE if we want to produced optimized output files. This might 253130812Smarcel need much more time and therefore must be explicitly selected. */ 254130812Smarcel unsigned int optimize: 1; 255130812Smarcel 256130812Smarcel /* TRUE if ok to have multiple definition. */ 257130812Smarcel unsigned int allow_multiple_definition: 1; 258130812Smarcel 259130812Smarcel /* TRUE if ok to have version with no definition. */ 260130812Smarcel unsigned int allow_undefined_version: 1; 261130812Smarcel 262130812Smarcel /* TRUE if symbols should be retained in memory, FALSE if they 263130812Smarcel should be freed and reread. */ 264130812Smarcel unsigned int keep_memory: 1; 265130812Smarcel 266130812Smarcel /* TRUE if every symbol should be reported back via the notice 267130812Smarcel callback. */ 268130812Smarcel unsigned int notice_all: 1; 269130812Smarcel 270130812Smarcel /* TRUE if executable should not contain copy relocs. 271130812Smarcel Setting this true may result in a non-sharable text segment. */ 272130812Smarcel unsigned int nocopyreloc: 1; 273130812Smarcel 274130812Smarcel /* TRUE if the new ELF dynamic tags are enabled. */ 275130812Smarcel unsigned int new_dtags: 1; 276130812Smarcel 277130812Smarcel /* TRUE if non-PLT relocs should be merged into one reloc section 278130812Smarcel and sorted so that relocs against the same symbol come together. */ 279130812Smarcel unsigned int combreloc: 1; 280130812Smarcel 281130812Smarcel /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment 282130812Smarcel should be created. */ 283130812Smarcel unsigned int eh_frame_hdr: 1; 284130812Smarcel 285130812Smarcel /* TRUE if global symbols in discarded sections should be stripped. */ 286130812Smarcel unsigned int strip_discarded: 1; 287130812Smarcel 288130812Smarcel /* TRUE if the final relax pass is needed. */ 289130812Smarcel unsigned int need_relax_finalize: 1; 290130812Smarcel 291130812Smarcel /* TRUE if generating a position independent executable. */ 292130812Smarcel unsigned int pie: 1; 293130812Smarcel 294130812Smarcel /* TRUE if generating an executable, position independent or not. */ 295130812Smarcel unsigned int executable : 1; 296130812Smarcel 297130812Smarcel /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X 298130812Smarcel flags. */ 299130812Smarcel unsigned int execstack: 1; 300130812Smarcel 301130812Smarcel /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W 302130812Smarcel flags. */ 303130812Smarcel unsigned int noexecstack: 1; 304130812Smarcel 305130812Smarcel /* What to do with unresolved symbols in an object file. 306130812Smarcel When producing static binaries the default is GENERATE_ERROR. 307130812Smarcel When producing dynamic binaries the default is IGNORE. The 308130812Smarcel assumption with dynamic binaries is that the reference will be 309130812Smarcel resolved at load/execution time. */ 310130812Smarcel enum report_method unresolved_syms_in_objects; 311130812Smarcel 312130812Smarcel /* What to do with unresolved symbols in a shared library. 313130812Smarcel The same defaults apply. */ 314130812Smarcel enum report_method unresolved_syms_in_shared_libs; 315130812Smarcel 316130812Smarcel /* Which symbols to strip. */ 317130812Smarcel enum bfd_link_strip strip; 318130812Smarcel 319130812Smarcel /* Which local symbols to discard. */ 320130812Smarcel enum bfd_link_discard discard; 321130812Smarcel 322130812Smarcel /* Criteria for skipping symbols when detemining 323130812Smarcel whether to include an object from an archive. */ 324130812Smarcel enum bfd_link_common_skip_ar_aymbols common_skip_ar_aymbols; 325130812Smarcel 326130812Smarcel /* Function callbacks. */ 327130812Smarcel const struct bfd_link_callbacks *callbacks; 328130812Smarcel 329130812Smarcel /* Hash table handled by BFD. */ 330130812Smarcel struct bfd_link_hash_table *hash; 331130812Smarcel 332130812Smarcel /* Hash table of symbols to keep. This is NULL unless strip is 333130812Smarcel strip_some. */ 334130812Smarcel struct bfd_hash_table *keep_hash; 335130812Smarcel 336130812Smarcel /* Hash table of symbols to report back via the notice callback. If 337130812Smarcel this is NULL, and notice_all is FALSE, then no symbols are 338130812Smarcel reported back. */ 339130812Smarcel struct bfd_hash_table *notice_hash; 340130812Smarcel 341130812Smarcel /* Hash table of symbols which are being wrapped (the --wrap linker 342130812Smarcel option). If this is NULL, no symbols are being wrapped. */ 343130812Smarcel struct bfd_hash_table *wrap_hash; 344130812Smarcel 345130812Smarcel /* The list of input BFD's involved in the link. These are chained 346130812Smarcel together via the link_next field. */ 347130812Smarcel bfd *input_bfds; 348130812Smarcel 349130812Smarcel /* If a symbol should be created for each input BFD, this is section 350130812Smarcel where those symbols should be placed. It must be a section in 351130812Smarcel the output BFD. It may be NULL, in which case no such symbols 352130812Smarcel will be created. This is to support CREATE_OBJECT_SYMBOLS in the 353130812Smarcel linker command language. */ 354130812Smarcel asection *create_object_symbols_section; 355130812Smarcel 356130812Smarcel /* List of global symbol names that are starting points for marking 357130812Smarcel sections against garbage collection. */ 358130812Smarcel struct bfd_sym_chain *gc_sym_list; 359130812Smarcel 360130812Smarcel /* If a base output file is wanted, then this points to it */ 361130812Smarcel void *base_file; 362130812Smarcel 363130812Smarcel /* The function to call when the executable or shared object is 364130812Smarcel loaded. */ 365130812Smarcel const char *init_function; 366130812Smarcel 367130812Smarcel /* The function to call when the executable or shared object is 368130812Smarcel unloaded. */ 369130812Smarcel const char *fini_function; 370130812Smarcel 371130812Smarcel /* Non-zero if auto-import thunks for DATA items in pei386 DLLs 372130812Smarcel should be generated/linked against. Set to 1 if this feature 373130812Smarcel is explicitly requested by the user, -1 if enabled by default. */ 374130812Smarcel int pei386_auto_import; 375130812Smarcel 376130812Smarcel /* Non-zero if runtime relocs for DATA items with non-zero addends 377130812Smarcel in pei386 DLLs should be generated. Set to 1 if this feature 378130812Smarcel is explicitly requested by the user, -1 if enabled by default. */ 379130812Smarcel int pei386_runtime_pseudo_reloc; 380130812Smarcel 381130812Smarcel /* How many spare .dynamic DT_NULL entries should be added? */ 382130812Smarcel unsigned int spare_dynamic_tags; 383130812Smarcel 384130812Smarcel /* May be used to set DT_FLAGS for ELF. */ 385130812Smarcel bfd_vma flags; 386130812Smarcel 387130812Smarcel /* May be used to set DT_FLAGS_1 for ELF. */ 388130812Smarcel bfd_vma flags_1; 389130812Smarcel}; 390130812Smarcel 391130812Smarcel/* This structures holds a set of callback functions. These are 392130812Smarcel called by the BFD linker routines. The first argument to each 393130812Smarcel callback function is the bfd_link_info structure being used. Each 394130812Smarcel function returns a boolean value. If the function returns FALSE, 395130812Smarcel then the BFD function which called it will return with a failure 396130812Smarcel indication. */ 397130812Smarcel 398130812Smarcelstruct bfd_link_callbacks 399130812Smarcel{ 400130812Smarcel /* A function which is called when an object is added from an 401130812Smarcel archive. ABFD is the archive element being added. NAME is the 402130812Smarcel name of the symbol which caused the archive element to be pulled 403130812Smarcel in. */ 404130812Smarcel bfd_boolean (*add_archive_element) 405130812Smarcel (struct bfd_link_info *, bfd *abfd, const char *name); 406130812Smarcel /* A function which is called when a symbol is found with multiple 407130812Smarcel definitions. NAME is the symbol which is defined multiple times. 408130812Smarcel OBFD is the old BFD, OSEC is the old section, OVAL is the old 409130812Smarcel value, NBFD is the new BFD, NSEC is the new section, and NVAL is 410130812Smarcel the new value. OBFD may be NULL. OSEC and NSEC may be 411130812Smarcel bfd_com_section or bfd_ind_section. */ 412130812Smarcel bfd_boolean (*multiple_definition) 413130812Smarcel (struct bfd_link_info *, const char *name, 414130812Smarcel bfd *obfd, asection *osec, bfd_vma oval, 415130812Smarcel bfd *nbfd, asection *nsec, bfd_vma nval); 416130812Smarcel /* A function which is called when a common symbol is defined 417130812Smarcel multiple times. NAME is the symbol appearing multiple times. 418130812Smarcel OBFD is the BFD of the existing symbol; it may be NULL if this is 419130812Smarcel not known. OTYPE is the type of the existing symbol, which may 420130812Smarcel be bfd_link_hash_defined, bfd_link_hash_defweak, 421130812Smarcel bfd_link_hash_common, or bfd_link_hash_indirect. If OTYPE is 422130812Smarcel bfd_link_hash_common, OSIZE is the size of the existing symbol. 423130812Smarcel NBFD is the BFD of the new symbol. NTYPE is the type of the new 424130812Smarcel symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or 425130812Smarcel bfd_link_hash_indirect. If NTYPE is bfd_link_hash_common, NSIZE 426130812Smarcel is the size of the new symbol. */ 427130812Smarcel bfd_boolean (*multiple_common) 428130812Smarcel (struct bfd_link_info *, const char *name, 429130812Smarcel bfd *obfd, enum bfd_link_hash_type otype, bfd_vma osize, 430130812Smarcel bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize); 431130812Smarcel /* A function which is called to add a symbol to a set. ENTRY is 432130812Smarcel the link hash table entry for the set itself (e.g., 433130812Smarcel __CTOR_LIST__). RELOC is the relocation to use for an entry in 434130812Smarcel the set when generating a relocatable file, and is also used to 435130812Smarcel get the size of the entry when generating an executable file. 436130812Smarcel ABFD, SEC and VALUE identify the value to add to the set. */ 437130812Smarcel bfd_boolean (*add_to_set) 438130812Smarcel (struct bfd_link_info *, struct bfd_link_hash_entry *entry, 439130812Smarcel bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value); 440130812Smarcel /* A function which is called when the name of a g++ constructor or 441130812Smarcel destructor is found. This is only called by some object file 442130812Smarcel formats. CONSTRUCTOR is TRUE for a constructor, FALSE for a 443130812Smarcel destructor. This will use BFD_RELOC_CTOR when generating a 444130812Smarcel relocatable file. NAME is the name of the symbol found. ABFD, 445130812Smarcel SECTION and VALUE are the value of the symbol. */ 446130812Smarcel bfd_boolean (*constructor) 447130812Smarcel (struct bfd_link_info *, bfd_boolean constructor, const char *name, 448130812Smarcel bfd *abfd, asection *sec, bfd_vma value); 449130812Smarcel /* A function which is called to issue a linker warning. For 450130812Smarcel example, this is called when there is a reference to a warning 451130812Smarcel symbol. WARNING is the warning to be issued. SYMBOL is the name 452130812Smarcel of the symbol which triggered the warning; it may be NULL if 453130812Smarcel there is none. ABFD, SECTION and ADDRESS identify the location 454130812Smarcel which trigerred the warning; either ABFD or SECTION or both may 455130812Smarcel be NULL if the location is not known. */ 456130812Smarcel bfd_boolean (*warning) 457130812Smarcel (struct bfd_link_info *, const char *warning, const char *symbol, 458130812Smarcel bfd *abfd, asection *section, bfd_vma address); 459130812Smarcel /* A function which is called when a relocation is attempted against 460130812Smarcel an undefined symbol. NAME is the symbol which is undefined. 461130812Smarcel ABFD, SECTION and ADDRESS identify the location from which the 462130812Smarcel reference is made. FATAL indicates whether an undefined symbol is 463130812Smarcel a fatal error or not. In some cases SECTION may be NULL. */ 464130812Smarcel bfd_boolean (*undefined_symbol) 465130812Smarcel (struct bfd_link_info *, const char *name, bfd *abfd, 466130812Smarcel asection *section, bfd_vma address, bfd_boolean fatal); 467130812Smarcel /* A function which is called when a reloc overflow occurs. NAME is 468130812Smarcel the name of the symbol or section the reloc is against, 469130812Smarcel RELOC_NAME is the name of the relocation, and ADDEND is any 470130812Smarcel addend that is used. ABFD, SECTION and ADDRESS identify the 471130812Smarcel location at which the overflow occurs; if this is the result of a 472130812Smarcel bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 473130812Smarcel ABFD will be NULL. */ 474130812Smarcel bfd_boolean (*reloc_overflow) 475130812Smarcel (struct bfd_link_info *, const char *name, const char *reloc_name, 476130812Smarcel bfd_vma addend, bfd *abfd, asection *section, bfd_vma address); 477130812Smarcel /* A function which is called when a dangerous reloc is performed. 478130812Smarcel The canonical example is an a29k IHCONST reloc which does not 479130812Smarcel follow an IHIHALF reloc. MESSAGE is an appropriate message. 480130812Smarcel ABFD, SECTION and ADDRESS identify the location at which the 481130812Smarcel problem occurred; if this is the result of a 482130812Smarcel bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 483130812Smarcel ABFD will be NULL. */ 484130812Smarcel bfd_boolean (*reloc_dangerous) 485130812Smarcel (struct bfd_link_info *, const char *message, 486130812Smarcel bfd *abfd, asection *section, bfd_vma address); 487130812Smarcel /* A function which is called when a reloc is found to be attached 488130812Smarcel to a symbol which is not being written out. NAME is the name of 489130812Smarcel the symbol. ABFD, SECTION and ADDRESS identify the location of 490130812Smarcel the reloc; if this is the result of a 491130812Smarcel bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 492130812Smarcel ABFD will be NULL. */ 493130812Smarcel bfd_boolean (*unattached_reloc) 494130812Smarcel (struct bfd_link_info *, const char *name, 495130812Smarcel bfd *abfd, asection *section, bfd_vma address); 496130812Smarcel /* A function which is called when a symbol in notice_hash is 497130812Smarcel defined or referenced. NAME is the symbol. ABFD, SECTION and 498130812Smarcel ADDRESS are the value of the symbol. If SECTION is 499130812Smarcel bfd_und_section, this is a reference. */ 500130812Smarcel bfd_boolean (*notice) 501130812Smarcel (struct bfd_link_info *, const char *name, 502130812Smarcel bfd *abfd, asection *section, bfd_vma address); 503130812Smarcel /* A function which is called for reporting a linker error. ID is the 504130812Smarcel error identifier. The remaining input is the same as einfo () in 505130812Smarcel ld. */ 506130812Smarcel bfd_boolean (*error_handler) 507130812Smarcel (int id, const char *fmt, ...); 508130812Smarcel 509130812Smarcel/* Identifiers of linker error messages used by error_handler. */ 510130812Smarcel#define LD_DEFINITION_IN_DISCARDED_SECTION 1 511130812Smarcel}; 512130812Smarcel 513130812Smarcel/* The linker builds link_order structures which tell the code how to 514130812Smarcel include input data in the output file. */ 515130812Smarcel 516130812Smarcel/* These are the types of link_order structures. */ 517130812Smarcel 518130812Smarcelenum bfd_link_order_type 519130812Smarcel{ 520130812Smarcel bfd_undefined_link_order, /* Undefined. */ 521130812Smarcel bfd_indirect_link_order, /* Built from a section. */ 522130812Smarcel bfd_data_link_order, /* Set to explicit data. */ 523130812Smarcel bfd_section_reloc_link_order, /* Relocate against a section. */ 524130812Smarcel bfd_symbol_reloc_link_order /* Relocate against a symbol. */ 525130812Smarcel}; 526130812Smarcel 527130812Smarcel/* This is the link_order structure itself. These form a chain 528130812Smarcel attached to the section whose contents they are describing. */ 529130812Smarcel 530130812Smarcelstruct bfd_link_order 531130812Smarcel{ 532130812Smarcel /* Next link_order in chain. */ 533130812Smarcel struct bfd_link_order *next; 534130812Smarcel /* Type of link_order. */ 535130812Smarcel enum bfd_link_order_type type; 536130812Smarcel /* Offset within output section. */ 537130812Smarcel bfd_vma offset; 538130812Smarcel /* Size within output section. */ 539130812Smarcel bfd_size_type size; 540130812Smarcel /* Type specific information. */ 541130812Smarcel union 542130812Smarcel { 543130812Smarcel struct 544130812Smarcel { 545130812Smarcel /* Section to include. If this is used, then 546130812Smarcel section->output_section must be the section the 547130812Smarcel link_order is attached to, section->output_offset must 548130812Smarcel equal the link_order offset field, and section->_raw_size 549130812Smarcel must equal the link_order size field. Maybe these 550130812Smarcel restrictions should be relaxed someday. */ 551130812Smarcel asection *section; 552130812Smarcel } indirect; 553130812Smarcel struct 554130812Smarcel { 555130812Smarcel /* Size of contents, or zero when contents size == size 556130812Smarcel within output section. 557130812Smarcel A non-zero value allows filling of the output section 558130812Smarcel with an arbitrary repeated pattern. */ 559130812Smarcel unsigned int size; 560130812Smarcel /* Data to put into file. */ 561130812Smarcel bfd_byte *contents; 562130812Smarcel } data; 563130812Smarcel struct 564130812Smarcel { 565130812Smarcel /* Description of reloc to generate. Used for 566130812Smarcel bfd_section_reloc_link_order and 567130812Smarcel bfd_symbol_reloc_link_order. */ 568130812Smarcel struct bfd_link_order_reloc *p; 569130812Smarcel } reloc; 570130812Smarcel } u; 571130812Smarcel}; 572130812Smarcel 573130812Smarcel/* A linker order of type bfd_section_reloc_link_order or 574130812Smarcel bfd_symbol_reloc_link_order means to create a reloc against a 575130812Smarcel section or symbol, respectively. This is used to implement -Ur to 576130812Smarcel generate relocs for the constructor tables. The 577130812Smarcel bfd_link_order_reloc structure describes the reloc that BFD should 578130812Smarcel create. It is similar to a arelent, but I didn't use arelent 579130812Smarcel because the linker does not know anything about most symbols, and 580130812Smarcel any asymbol structure it creates will be partially meaningless. 581130812Smarcel This information could logically be in the bfd_link_order struct, 582130812Smarcel but I didn't want to waste the space since these types of relocs 583130812Smarcel are relatively rare. */ 584130812Smarcel 585130812Smarcelstruct bfd_link_order_reloc 586130812Smarcel{ 587130812Smarcel /* Reloc type. */ 588130812Smarcel bfd_reloc_code_real_type reloc; 589130812Smarcel 590130812Smarcel union 591130812Smarcel { 592130812Smarcel /* For type bfd_section_reloc_link_order, this is the section 593130812Smarcel the reloc should be against. This must be a section in the 594130812Smarcel output BFD, not any of the input BFDs. */ 595130812Smarcel asection *section; 596130812Smarcel /* For type bfd_symbol_reloc_link_order, this is the name of the 597130812Smarcel symbol the reloc should be against. */ 598130812Smarcel const char *name; 599130812Smarcel } u; 600130812Smarcel 601130812Smarcel /* Addend to use. The object file should contain zero. The BFD 602130812Smarcel backend is responsible for filling in the contents of the object 603130812Smarcel file correctly. For some object file formats (e.g., COFF) the 604130812Smarcel addend must be stored into in the object file, and for some 605130812Smarcel (e.g., SPARC a.out) it is kept in the reloc. */ 606130812Smarcel bfd_vma addend; 607130812Smarcel}; 608130812Smarcel 609130812Smarcel/* Allocate a new link_order for a section. */ 610130812Smarcelextern struct bfd_link_order *bfd_new_link_order (bfd *, asection *); 611130812Smarcel 612130812Smarcel/* These structures are used to describe version information for the 613130812Smarcel ELF linker. These structures could be manipulated entirely inside 614130812Smarcel BFD, but it would be a pain. Instead, the regular linker sets up 615130812Smarcel these structures, and then passes them into BFD. */ 616130812Smarcel 617130812Smarcel/* Glob pattern for a version. */ 618130812Smarcel 619130812Smarcelstruct bfd_elf_version_expr 620130812Smarcel{ 621130812Smarcel /* Next glob pattern for this version. */ 622130812Smarcel struct bfd_elf_version_expr *next; 623130812Smarcel /* Glob pattern. */ 624130812Smarcel const char *pattern; 625130812Smarcel /* NULL for a glob pattern, otherwise a straight symbol. */ 626130812Smarcel const char *symbol; 627130812Smarcel /* Defined by ".symver". */ 628130812Smarcel unsigned int symver : 1; 629130812Smarcel /* Defined by version script. */ 630130812Smarcel unsigned int script : 1; 631130812Smarcel /* Pattern type. */ 632130812Smarcel#define BFD_ELF_VERSION_C_TYPE 1 633130812Smarcel#define BFD_ELF_VERSION_CXX_TYPE 2 634130812Smarcel#define BFD_ELF_VERSION_JAVA_TYPE 4 635130812Smarcel unsigned int mask : 3; 636130812Smarcel}; 637130812Smarcel 638130812Smarcelstruct bfd_elf_version_expr_head 639130812Smarcel{ 640130812Smarcel /* List of all patterns, both wildcards and non-wildcards. */ 641130812Smarcel struct bfd_elf_version_expr *list; 642130812Smarcel /* Hash table for non-wildcards. */ 643130812Smarcel void *htab; 644130812Smarcel /* Remaining patterns. */ 645130812Smarcel struct bfd_elf_version_expr *remaining; 646130812Smarcel /* What kind of pattern types are present in list (bitmask). */ 647130812Smarcel unsigned int mask; 648130812Smarcel}; 649130812Smarcel 650130812Smarcel/* Version dependencies. */ 651130812Smarcel 652130812Smarcelstruct bfd_elf_version_deps 653130812Smarcel{ 654130812Smarcel /* Next dependency for this version. */ 655130812Smarcel struct bfd_elf_version_deps *next; 656130812Smarcel /* The version which this version depends upon. */ 657130812Smarcel struct bfd_elf_version_tree *version_needed; 658130812Smarcel}; 659130812Smarcel 660130812Smarcel/* A node in the version tree. */ 661130812Smarcel 662130812Smarcelstruct bfd_elf_version_tree 663130812Smarcel{ 664130812Smarcel /* Next version. */ 665130812Smarcel struct bfd_elf_version_tree *next; 666130812Smarcel /* Name of this version. */ 667130812Smarcel const char *name; 668130812Smarcel /* Version number. */ 669130812Smarcel unsigned int vernum; 670130812Smarcel /* Regular expressions for global symbols in this version. */ 671130812Smarcel struct bfd_elf_version_expr_head globals; 672130812Smarcel /* Regular expressions for local symbols in this version. */ 673130812Smarcel struct bfd_elf_version_expr_head locals; 674130812Smarcel /* List of versions which this version depends upon. */ 675130812Smarcel struct bfd_elf_version_deps *deps; 676130812Smarcel /* Index of the version name. This is used within BFD. */ 677130812Smarcel unsigned int name_indx; 678130812Smarcel /* Whether this version tree was used. This is used within BFD. */ 679130812Smarcel int used; 680130812Smarcel /* Matching hook. */ 681130812Smarcel struct bfd_elf_version_expr *(*match) 682130812Smarcel (struct bfd_elf_version_expr_head *head, 683130812Smarcel struct bfd_elf_version_expr *prev, const char *sym); 684130812Smarcel}; 685130812Smarcel 686130812Smarcel#endif 687