bfdlink.h revision 130812
1241675Suqs/* bfdlink.h -- header file for BFD link routines 2241675Suqs Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 3241675Suqs Free Software Foundation, Inc. 4241675Suqs Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support. 5241675Suqs 6241675Suqs This file is part of BFD, the Binary File Descriptor library. 7241675Suqs 8241675Suqs This program is free software; you can redistribute it and/or modify 9241675Suqs it under the terms of the GNU General Public License as published by 10241675Suqs the Free Software Foundation; either version 2 of the License, or 11241675Suqs (at your option) any later version. 12241675Suqs 13241675Suqs This program is distributed in the hope that it will be useful, 14241675Suqs but WITHOUT ANY WARRANTY; without even the implied warranty of 15241675Suqs MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16241675Suqs GNU General Public License for more details. 17241675Suqs 18241675Suqs You should have received a copy of the GNU General Public License 19241675Suqs along with this program; if not, write to the Free Software 20241675Suqs Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21241675Suqs 22241675Suqs#ifndef BFDLINK_H 23241675Suqs#define BFDLINK_H 24241675Suqs 25241675Suqs/* Which symbols to strip during a link. */ 26241675Suqsenum bfd_link_strip 27241675Suqs{ 28241675Suqs strip_none, /* Don't strip any symbols. */ 29241675Suqs strip_debugger, /* Strip debugging symbols. */ 30241675Suqs strip_some, /* keep_hash is the list of symbols to keep. */ 31241675Suqs strip_all /* Strip all symbols. */ 32241675Suqs}; 33241675Suqs 34241675Suqs/* Which local symbols to discard during a link. This is irrelevant 35241675Suqs if strip_all is used. */ 36241675Suqsenum bfd_link_discard 37241675Suqs{ 38241675Suqs discard_sec_merge, /* Discard local temporary symbols in SEC_MERGE 39241675Suqs sections. */ 40241675Suqs discard_none, /* Don't discard any locals. */ 41241675Suqs discard_l, /* Discard local temporary symbols. */ 42241675Suqs discard_all /* Discard all locals. */ 43241675Suqs}; 44241675Suqs 45241675Suqs/* Describes the type of hash table entry structure being used. 46241675Suqs Different hash table structure have different fields and so 47241675Suqs support different linking features. */ 48241675Suqsenum bfd_link_hash_table_type 49241675Suqs { 50241675Suqs bfd_link_generic_hash_table, 51241675Suqs bfd_link_elf_hash_table 52241675Suqs }; 53241675Suqs 54241675Suqs/* These are the possible types of an entry in the BFD link hash 55241675Suqs table. */ 56241675Suqs 57241675Suqsenum bfd_link_hash_type 58241675Suqs{ 59241675Suqs bfd_link_hash_new, /* Symbol is new. */ 60241675Suqs bfd_link_hash_undefined, /* Symbol seen before, but undefined. */ 61241675Suqs bfd_link_hash_undefweak, /* Symbol is weak and undefined. */ 62241675Suqs bfd_link_hash_defined, /* Symbol is defined. */ 63241675Suqs bfd_link_hash_defweak, /* Symbol is weak and defined. */ 64241675Suqs bfd_link_hash_common, /* Symbol is common. */ 65241675Suqs bfd_link_hash_indirect, /* Symbol is an indirect link. */ 66241675Suqs bfd_link_hash_warning /* Like indirect, but warn if referenced. */ 67241675Suqs}; 68241675Suqs 69241675Suqsenum bfd_link_common_skip_ar_aymbols 70241675Suqs{ 71241675Suqs bfd_link_common_skip_none, 72241675Suqs bfd_link_common_skip_text, 73241675Suqs bfd_link_common_skip_data, 74241675Suqs bfd_link_common_skip_all 75241675Suqs}; 76241675Suqs 77241675Suqs/* The linking routines use a hash table which uses this structure for 78241675Suqs its elements. */ 79241675Suqs 80241675Suqsstruct bfd_link_hash_entry 81241675Suqs{ 82241675Suqs /* Base hash table entry structure. */ 83241675Suqs struct bfd_hash_entry root; 84241675Suqs 85241675Suqs /* Type of this entry. */ 86241675Suqs enum bfd_link_hash_type type; 87241675Suqs 88241675Suqs /* Undefined and common symbols are kept in a linked list through 89241675Suqs this field. This field is not in the union because that would 90241675Suqs force us to remove entries from the list when we changed their 91241675Suqs type, which would force the list to be doubly linked, which would 92241675Suqs waste more memory. When an undefined or common symbol is 93241675Suqs created, it should be added to this list, the head of which is in 94241675Suqs the link hash table itself. As symbols are defined, they need 95241675Suqs not be removed from the list; anything which reads the list must 96241675Suqs doublecheck the symbol type. 97241675Suqs 98241675Suqs Weak symbols are not kept on this list. 99241675Suqs 100241675Suqs Defined and defweak symbols use this field as a reference marker. 101241675Suqs If the field is not NULL, or this structure is the tail of the 102241675Suqs undefined symbol list, the symbol has been referenced. If the 103241675Suqs symbol is undefined and becomes defined, this field will 104241675Suqs automatically be non-NULL since the symbol will have been on the 105241675Suqs undefined symbol list. */ 106241675Suqs struct bfd_link_hash_entry *und_next; 107241675Suqs 108241675Suqs /* A union of information depending upon the type. */ 109241675Suqs union 110241675Suqs { 111241675Suqs /* Nothing is kept for bfd_hash_new. */ 112241675Suqs /* bfd_link_hash_undefined, bfd_link_hash_undefweak. */ 113241675Suqs struct 114241675Suqs { 115241675Suqs bfd *abfd; /* BFD symbol was found in. */ 116241675Suqs } undef; 117241675Suqs /* bfd_link_hash_defined, bfd_link_hash_defweak. */ 118241675Suqs struct 119241675Suqs { 120241675Suqs bfd_vma value; /* Symbol value. */ 121241675Suqs asection *section; /* Symbol section. */ 122241675Suqs } def; 123241675Suqs /* bfd_link_hash_indirect, bfd_link_hash_warning. */ 124241675Suqs struct 125241675Suqs { 126241675Suqs struct bfd_link_hash_entry *link; /* Real symbol. */ 127241675Suqs const char *warning; /* Warning (bfd_link_hash_warning only). */ 128241675Suqs } i; 129241675Suqs /* bfd_link_hash_common. */ 130241675Suqs struct 131241675Suqs { 132241675Suqs /* The linker needs to know three things about common 133241675Suqs symbols: the size, the alignment, and the section in 134241675Suqs which the symbol should be placed. We store the size 135241675Suqs here, and we allocate a small structure to hold the 136241675Suqs section and the alignment. The alignment is stored as a 137241675Suqs power of two. We don't store all the information 138241675Suqs directly because we don't want to increase the size of 139241675Suqs the union; this structure is a major space user in the 140241675Suqs linker. */ 141241675Suqs bfd_size_type size; /* Common symbol size. */ 142241675Suqs struct bfd_link_hash_common_entry 143241675Suqs { 144241675Suqs unsigned int alignment_power; /* Alignment. */ 145241675Suqs asection *section; /* Symbol section. */ 146241675Suqs } *p; 147241675Suqs } c; 148241675Suqs } u; 149241675Suqs}; 150241675Suqs 151241675Suqs/* This is the link hash table. It is a derived class of 152241675Suqs bfd_hash_table. */ 153241675Suqs 154241675Suqsstruct bfd_link_hash_table 155241675Suqs{ 156241675Suqs /* The hash table itself. */ 157241675Suqs struct bfd_hash_table table; 158241675Suqs /* The back end which created this hash table. This indicates the 159241675Suqs type of the entries in the hash table, which is sometimes 160241675Suqs important information when linking object files of different 161241675Suqs types together. */ 162241675Suqs const bfd_target *creator; 163241675Suqs /* A linked list of undefined and common symbols, linked through the 164241675Suqs next field in the bfd_link_hash_entry structure. */ 165241675Suqs struct bfd_link_hash_entry *undefs; 166241675Suqs /* Entries are added to the tail of the undefs list. */ 167241675Suqs struct bfd_link_hash_entry *undefs_tail; 168241675Suqs /* The type of the link hash table. */ 169241675Suqs enum bfd_link_hash_table_type type; 170241675Suqs}; 171241675Suqs 172241675Suqs/* Look up an entry in a link hash table. If FOLLOW is TRUE, this 173241675Suqs follows bfd_link_hash_indirect and bfd_link_hash_warning links to 174241675Suqs the real symbol. */ 175241675Suqsextern struct bfd_link_hash_entry *bfd_link_hash_lookup 176241675Suqs (struct bfd_link_hash_table *, const char *, bfd_boolean create, 177241675Suqs bfd_boolean copy, bfd_boolean follow); 178241675Suqs 179241675Suqs/* Look up an entry in the main linker hash table if the symbol might 180241675Suqs be wrapped. This should only be used for references to an 181241675Suqs undefined symbol, not for definitions of a symbol. */ 182241675Suqs 183241675Suqsextern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup 184241675Suqs (bfd *, struct bfd_link_info *, const char *, bfd_boolean, 185241675Suqs bfd_boolean, bfd_boolean); 186241675Suqs 187241675Suqs/* Traverse a link hash table. */ 188241675Suqsextern void bfd_link_hash_traverse 189241675Suqs (struct bfd_link_hash_table *, 190241675Suqs bfd_boolean (*) (struct bfd_link_hash_entry *, void *), 191241675Suqs void *); 192241675Suqs 193241675Suqs/* Add an entry to the undefs list. */ 194241675Suqsextern void bfd_link_add_undef 195241675Suqs (struct bfd_link_hash_table *, struct bfd_link_hash_entry *); 196241675Suqs 197241675Suqsstruct bfd_sym_chain 198241675Suqs{ 199241675Suqs struct bfd_sym_chain *next; 200241675Suqs const char *name; 201241675Suqs}; 202241675Suqs 203241675Suqs/* How to handle unresolved symbols. 204241675Suqs There are four possibilities which are enumerated below: */ 205241675Suqsenum report_method 206241675Suqs{ 207241675Suqs /* This is the initial value when then link_info structure is created. 208241675Suqs It allows the various stages of the linker to determine whether they 209241675Suqs allowed to set the value. */ 210241675Suqs RM_NOT_YET_SET = 0, 211241675Suqs RM_IGNORE, 212241675Suqs RM_GENERATE_WARNING, 213241675Suqs RM_GENERATE_ERROR 214241675Suqs}; 215241675Suqs 216241675Suqs/* This structure holds all the information needed to communicate 217241675Suqs between BFD and the linker when doing a link. */ 218241675Suqs 219241675Suqsstruct bfd_link_info 220241675Suqs{ 221241675Suqs /* TRUE if BFD should generate a relocatable object file. */ 222241675Suqs unsigned int relocatable: 1; 223241675Suqs 224241675Suqs /* TRUE if BFD should generate relocation information in the final 225241675Suqs executable. */ 226241675Suqs unsigned int emitrelocations: 1; 227241675Suqs 228241675Suqs /* TRUE if BFD should generate a "task linked" object file, 229241675Suqs similar to relocatable but also with globals converted to 230241675Suqs statics. */ 231241675Suqs unsigned int task_link: 1; 232241675Suqs 233241675Suqs /* TRUE if BFD should generate a shared object. */ 234241675Suqs unsigned int shared: 1; 235241675Suqs 236241675Suqs /* TRUE if BFD should pre-bind symbols in a shared object. */ 237241675Suqs unsigned int symbolic: 1; 238241675Suqs 239241675Suqs /* TRUE if BFD should export all symbols in the dynamic symbol table 240241675Suqs of an executable, rather than only those used. */ 241241675Suqs unsigned int export_dynamic: 1; 242241675Suqs 243241675Suqs /* TRUE if shared objects should be linked directly, not shared. */ 244241675Suqs unsigned int static_link: 1; 245241675Suqs 246241675Suqs /* TRUE if the output file should be in a traditional format. This 247241675Suqs is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag 248241675Suqs on the output file, but may be checked when reading the input 249241675Suqs files. */ 250241675Suqs unsigned int traditional_format: 1; 251241675Suqs 252241675Suqs /* TRUE if we want to produced optimized output files. This might 253241675Suqs need much more time and therefore must be explicitly selected. */ 254241675Suqs unsigned int optimize: 1; 255241675Suqs 256241675Suqs /* TRUE if ok to have multiple definition. */ 257241675Suqs unsigned int allow_multiple_definition: 1; 258241675Suqs 259241675Suqs /* TRUE if ok to have version with no definition. */ 260241675Suqs unsigned int allow_undefined_version: 1; 261241675Suqs 262241675Suqs /* TRUE if symbols should be retained in memory, FALSE if they 263241675Suqs should be freed and reread. */ 264241675Suqs unsigned int keep_memory: 1; 265241675Suqs 266241675Suqs /* TRUE if every symbol should be reported back via the notice 267241675Suqs callback. */ 268241675Suqs unsigned int notice_all: 1; 269241675Suqs 270241675Suqs /* TRUE if executable should not contain copy relocs. 271241675Suqs Setting this true may result in a non-sharable text segment. */ 272241675Suqs unsigned int nocopyreloc: 1; 273241675Suqs 274241675Suqs /* TRUE if the new ELF dynamic tags are enabled. */ 275241675Suqs unsigned int new_dtags: 1; 276241675Suqs 277241675Suqs /* TRUE if non-PLT relocs should be merged into one reloc section 278241675Suqs and sorted so that relocs against the same symbol come together. */ 279241675Suqs unsigned int combreloc: 1; 280241675Suqs 281241675Suqs /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment 282241675Suqs should be created. */ 283241675Suqs unsigned int eh_frame_hdr: 1; 284241675Suqs 285241675Suqs /* TRUE if global symbols in discarded sections should be stripped. */ 286241675Suqs unsigned int strip_discarded: 1; 287241675Suqs 288241675Suqs /* TRUE if the final relax pass is needed. */ 289241675Suqs unsigned int need_relax_finalize: 1; 290241675Suqs 291241675Suqs /* TRUE if generating a position independent executable. */ 292241675Suqs unsigned int pie: 1; 293241675Suqs 294241675Suqs /* TRUE if generating an executable, position independent or not. */ 295241675Suqs unsigned int executable : 1; 296241675Suqs 297241675Suqs /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X 298241675Suqs flags. */ 299241675Suqs unsigned int execstack: 1; 300241675Suqs 301241675Suqs /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W 302241675Suqs flags. */ 303241675Suqs unsigned int noexecstack: 1; 304241675Suqs 305241675Suqs /* What to do with unresolved symbols in an object file. 306241675Suqs When producing static binaries the default is GENERATE_ERROR. 307241675Suqs When producing dynamic binaries the default is IGNORE. The 308241675Suqs assumption with dynamic binaries is that the reference will be 309241675Suqs resolved at load/execution time. */ 310241675Suqs enum report_method unresolved_syms_in_objects; 311241675Suqs 312241675Suqs /* What to do with unresolved symbols in a shared library. 313241675Suqs The same defaults apply. */ 314241675Suqs enum report_method unresolved_syms_in_shared_libs; 315241675Suqs 316241675Suqs /* Which symbols to strip. */ 317241675Suqs enum bfd_link_strip strip; 318241675Suqs 319241675Suqs /* Which local symbols to discard. */ 320241675Suqs enum bfd_link_discard discard; 321241675Suqs 322241675Suqs /* Criteria for skipping symbols when detemining 323241675Suqs whether to include an object from an archive. */ 324241675Suqs enum bfd_link_common_skip_ar_aymbols common_skip_ar_aymbols; 325241675Suqs 326241675Suqs /* Function callbacks. */ 327241675Suqs const struct bfd_link_callbacks *callbacks; 328241675Suqs 329241675Suqs /* Hash table handled by BFD. */ 330241675Suqs struct bfd_link_hash_table *hash; 331241675Suqs 332241675Suqs /* Hash table of symbols to keep. This is NULL unless strip is 333241675Suqs strip_some. */ 334241675Suqs struct bfd_hash_table *keep_hash; 335241675Suqs 336241675Suqs /* Hash table of symbols to report back via the notice callback. If 337241675Suqs this is NULL, and notice_all is FALSE, then no symbols are 338241675Suqs reported back. */ 339241675Suqs struct bfd_hash_table *notice_hash; 340241675Suqs 341241675Suqs /* Hash table of symbols which are being wrapped (the --wrap linker 342241675Suqs option). If this is NULL, no symbols are being wrapped. */ 343241675Suqs struct bfd_hash_table *wrap_hash; 344241675Suqs 345241675Suqs /* The list of input BFD's involved in the link. These are chained 346241675Suqs together via the link_next field. */ 347241675Suqs bfd *input_bfds; 348241675Suqs 349241675Suqs /* If a symbol should be created for each input BFD, this is section 350241675Suqs where those symbols should be placed. It must be a section in 351241675Suqs the output BFD. It may be NULL, in which case no such symbols 352241675Suqs will be created. This is to support CREATE_OBJECT_SYMBOLS in the 353241675Suqs linker command language. */ 354241675Suqs asection *create_object_symbols_section; 355241675Suqs 356241675Suqs /* List of global symbol names that are starting points for marking 357241675Suqs sections against garbage collection. */ 358241675Suqs struct bfd_sym_chain *gc_sym_list; 359241675Suqs 360241675Suqs /* If a base output file is wanted, then this points to it */ 361241675Suqs void *base_file; 362241675Suqs 363241675Suqs /* The function to call when the executable or shared object is 364241675Suqs loaded. */ 365241675Suqs const char *init_function; 366241675Suqs 367241675Suqs /* The function to call when the executable or shared object is 368241675Suqs unloaded. */ 369241675Suqs const char *fini_function; 370241675Suqs 371241675Suqs /* Non-zero if auto-import thunks for DATA items in pei386 DLLs 372241675Suqs should be generated/linked against. Set to 1 if this feature 373241675Suqs is explicitly requested by the user, -1 if enabled by default. */ 374241675Suqs int pei386_auto_import; 375241675Suqs 376241675Suqs /* Non-zero if runtime relocs for DATA items with non-zero addends 377241675Suqs in pei386 DLLs should be generated. Set to 1 if this feature 378241675Suqs is explicitly requested by the user, -1 if enabled by default. */ 379241675Suqs int pei386_runtime_pseudo_reloc; 380241675Suqs 381241675Suqs /* How many spare .dynamic DT_NULL entries should be added? */ 382241675Suqs unsigned int spare_dynamic_tags; 383241675Suqs 384241675Suqs /* May be used to set DT_FLAGS for ELF. */ 385241675Suqs bfd_vma flags; 386241675Suqs 387241675Suqs /* May be used to set DT_FLAGS_1 for ELF. */ 388241675Suqs bfd_vma flags_1; 389241675Suqs}; 390241675Suqs 391241675Suqs/* This structures holds a set of callback functions. These are 392241675Suqs called by the BFD linker routines. The first argument to each 393241675Suqs callback function is the bfd_link_info structure being used. Each 394241675Suqs function returns a boolean value. If the function returns FALSE, 395241675Suqs then the BFD function which called it will return with a failure 396241675Suqs indication. */ 397241675Suqs 398241675Suqsstruct bfd_link_callbacks 399241675Suqs{ 400241675Suqs /* A function which is called when an object is added from an 401241675Suqs archive. ABFD is the archive element being added. NAME is the 402241675Suqs name of the symbol which caused the archive element to be pulled 403241675Suqs in. */ 404241675Suqs bfd_boolean (*add_archive_element) 405241675Suqs (struct bfd_link_info *, bfd *abfd, const char *name); 406241675Suqs /* A function which is called when a symbol is found with multiple 407241675Suqs definitions. NAME is the symbol which is defined multiple times. 408241675Suqs OBFD is the old BFD, OSEC is the old section, OVAL is the old 409241675Suqs value, NBFD is the new BFD, NSEC is the new section, and NVAL is 410241675Suqs the new value. OBFD may be NULL. OSEC and NSEC may be 411241675Suqs bfd_com_section or bfd_ind_section. */ 412241675Suqs bfd_boolean (*multiple_definition) 413241675Suqs (struct bfd_link_info *, const char *name, 414241675Suqs bfd *obfd, asection *osec, bfd_vma oval, 415241675Suqs bfd *nbfd, asection *nsec, bfd_vma nval); 416241675Suqs /* A function which is called when a common symbol is defined 417241675Suqs multiple times. NAME is the symbol appearing multiple times. 418241675Suqs OBFD is the BFD of the existing symbol; it may be NULL if this is 419241675Suqs not known. OTYPE is the type of the existing symbol, which may 420241675Suqs be bfd_link_hash_defined, bfd_link_hash_defweak, 421241675Suqs bfd_link_hash_common, or bfd_link_hash_indirect. If OTYPE is 422241675Suqs bfd_link_hash_common, OSIZE is the size of the existing symbol. 423241675Suqs NBFD is the BFD of the new symbol. NTYPE is the type of the new 424241675Suqs symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or 425241675Suqs bfd_link_hash_indirect. If NTYPE is bfd_link_hash_common, NSIZE 426241675Suqs is the size of the new symbol. */ 427241675Suqs bfd_boolean (*multiple_common) 428241675Suqs (struct bfd_link_info *, const char *name, 429241675Suqs bfd *obfd, enum bfd_link_hash_type otype, bfd_vma osize, 430241675Suqs bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize); 431241675Suqs /* A function which is called to add a symbol to a set. ENTRY is 432241675Suqs the link hash table entry for the set itself (e.g., 433241675Suqs __CTOR_LIST__). RELOC is the relocation to use for an entry in 434241675Suqs the set when generating a relocatable file, and is also used to 435241675Suqs get the size of the entry when generating an executable file. 436241675Suqs ABFD, SEC and VALUE identify the value to add to the set. */ 437241675Suqs bfd_boolean (*add_to_set) 438241675Suqs (struct bfd_link_info *, struct bfd_link_hash_entry *entry, 439241675Suqs bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value); 440241675Suqs /* A function which is called when the name of a g++ constructor or 441241675Suqs destructor is found. This is only called by some object file 442241675Suqs formats. CONSTRUCTOR is TRUE for a constructor, FALSE for a 443241675Suqs destructor. This will use BFD_RELOC_CTOR when generating a 444241675Suqs relocatable file. NAME is the name of the symbol found. ABFD, 445241675Suqs SECTION and VALUE are the value of the symbol. */ 446241675Suqs bfd_boolean (*constructor) 447241675Suqs (struct bfd_link_info *, bfd_boolean constructor, const char *name, 448241675Suqs bfd *abfd, asection *sec, bfd_vma value); 449241675Suqs /* A function which is called to issue a linker warning. For 450241675Suqs example, this is called when there is a reference to a warning 451241675Suqs symbol. WARNING is the warning to be issued. SYMBOL is the name 452241675Suqs of the symbol which triggered the warning; it may be NULL if 453241675Suqs there is none. ABFD, SECTION and ADDRESS identify the location 454241675Suqs which trigerred the warning; either ABFD or SECTION or both may 455241675Suqs be NULL if the location is not known. */ 456241675Suqs bfd_boolean (*warning) 457241675Suqs (struct bfd_link_info *, const char *warning, const char *symbol, 458241675Suqs bfd *abfd, asection *section, bfd_vma address); 459241675Suqs /* A function which is called when a relocation is attempted against 460241675Suqs an undefined symbol. NAME is the symbol which is undefined. 461241675Suqs ABFD, SECTION and ADDRESS identify the location from which the 462241675Suqs reference is made. FATAL indicates whether an undefined symbol is 463241675Suqs a fatal error or not. In some cases SECTION may be NULL. */ 464241675Suqs bfd_boolean (*undefined_symbol) 465241675Suqs (struct bfd_link_info *, const char *name, bfd *abfd, 466241675Suqs asection *section, bfd_vma address, bfd_boolean fatal); 467241675Suqs /* A function which is called when a reloc overflow occurs. NAME is 468241675Suqs the name of the symbol or section the reloc is against, 469241675Suqs RELOC_NAME is the name of the relocation, and ADDEND is any 470241675Suqs addend that is used. ABFD, SECTION and ADDRESS identify the 471241675Suqs location at which the overflow occurs; if this is the result of a 472241675Suqs bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 473241675Suqs ABFD will be NULL. */ 474241675Suqs bfd_boolean (*reloc_overflow) 475241675Suqs (struct bfd_link_info *, const char *name, const char *reloc_name, 476241675Suqs bfd_vma addend, bfd *abfd, asection *section, bfd_vma address); 477241675Suqs /* A function which is called when a dangerous reloc is performed. 478241675Suqs The canonical example is an a29k IHCONST reloc which does not 479241675Suqs follow an IHIHALF reloc. MESSAGE is an appropriate message. 480241675Suqs ABFD, SECTION and ADDRESS identify the location at which the 481241675Suqs problem occurred; if this is the result of a 482241675Suqs bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 483241675Suqs ABFD will be NULL. */ 484241675Suqs bfd_boolean (*reloc_dangerous) 485241675Suqs (struct bfd_link_info *, const char *message, 486241675Suqs bfd *abfd, asection *section, bfd_vma address); 487241675Suqs /* A function which is called when a reloc is found to be attached 488241675Suqs to a symbol which is not being written out. NAME is the name of 489241675Suqs the symbol. ABFD, SECTION and ADDRESS identify the location of 490241675Suqs the reloc; if this is the result of a 491241675Suqs bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then 492241675Suqs ABFD will be NULL. */ 493241675Suqs bfd_boolean (*unattached_reloc) 494241675Suqs (struct bfd_link_info *, const char *name, 495241675Suqs bfd *abfd, asection *section, bfd_vma address); 496241675Suqs /* A function which is called when a symbol in notice_hash is 497241675Suqs defined or referenced. NAME is the symbol. ABFD, SECTION and 498241675Suqs ADDRESS are the value of the symbol. If SECTION is 499241675Suqs bfd_und_section, this is a reference. */ 500241675Suqs bfd_boolean (*notice) 501241675Suqs (struct bfd_link_info *, const char *name, 502241675Suqs bfd *abfd, asection *section, bfd_vma address); 503241675Suqs /* A function which is called for reporting a linker error. ID is the 504241675Suqs error identifier. The remaining input is the same as einfo () in 505241675Suqs ld. */ 506241675Suqs bfd_boolean (*error_handler) 507241675Suqs (int id, const char *fmt, ...); 508241675Suqs 509241675Suqs/* Identifiers of linker error messages used by error_handler. */ 510241675Suqs#define LD_DEFINITION_IN_DISCARDED_SECTION 1 511241675Suqs}; 512241675Suqs 513241675Suqs/* The linker builds link_order structures which tell the code how to 514241675Suqs include input data in the output file. */ 515241675Suqs 516241675Suqs/* These are the types of link_order structures. */ 517241675Suqs 518241675Suqsenum bfd_link_order_type 519241675Suqs{ 520241675Suqs bfd_undefined_link_order, /* Undefined. */ 521241675Suqs bfd_indirect_link_order, /* Built from a section. */ 522241675Suqs bfd_data_link_order, /* Set to explicit data. */ 523241675Suqs bfd_section_reloc_link_order, /* Relocate against a section. */ 524241675Suqs bfd_symbol_reloc_link_order /* Relocate against a symbol. */ 525241675Suqs}; 526241675Suqs 527241675Suqs/* This is the link_order structure itself. These form a chain 528241675Suqs attached to the section whose contents they are describing. */ 529241675Suqs 530241675Suqsstruct bfd_link_order 531241675Suqs{ 532241675Suqs /* Next link_order in chain. */ 533241675Suqs struct bfd_link_order *next; 534241675Suqs /* Type of link_order. */ 535241675Suqs enum bfd_link_order_type type; 536241675Suqs /* Offset within output section. */ 537241675Suqs bfd_vma offset; 538241675Suqs /* Size within output section. */ 539241675Suqs bfd_size_type size; 540241675Suqs /* Type specific information. */ 541241675Suqs union 542241675Suqs { 543241675Suqs struct 544241675Suqs { 545241675Suqs /* Section to include. If this is used, then 546241675Suqs section->output_section must be the section the 547241675Suqs link_order is attached to, section->output_offset must 548241675Suqs equal the link_order offset field, and section->_raw_size 549241675Suqs must equal the link_order size field. Maybe these 550241675Suqs restrictions should be relaxed someday. */ 551241675Suqs asection *section; 552241675Suqs } indirect; 553241675Suqs struct 554241675Suqs { 555241675Suqs /* Size of contents, or zero when contents size == size 556241675Suqs within output section. 557241675Suqs A non-zero value allows filling of the output section 558241675Suqs with an arbitrary repeated pattern. */ 559241675Suqs unsigned int size; 560241675Suqs /* Data to put into file. */ 561241675Suqs bfd_byte *contents; 562241675Suqs } data; 563241675Suqs struct 564241675Suqs { 565241675Suqs /* Description of reloc to generate. Used for 566241675Suqs bfd_section_reloc_link_order and 567241675Suqs bfd_symbol_reloc_link_order. */ 568241675Suqs struct bfd_link_order_reloc *p; 569241675Suqs } reloc; 570241675Suqs } u; 571241675Suqs}; 572241675Suqs 573241675Suqs/* A linker order of type bfd_section_reloc_link_order or 574241675Suqs bfd_symbol_reloc_link_order means to create a reloc against a 575241675Suqs section or symbol, respectively. This is used to implement -Ur to 576241675Suqs generate relocs for the constructor tables. The 577241675Suqs bfd_link_order_reloc structure describes the reloc that BFD should 578241675Suqs create. It is similar to a arelent, but I didn't use arelent 579241675Suqs because the linker does not know anything about most symbols, and 580241675Suqs any asymbol structure it creates will be partially meaningless. 581241675Suqs This information could logically be in the bfd_link_order struct, 582241675Suqs but I didn't want to waste the space since these types of relocs 583241675Suqs are relatively rare. */ 584241675Suqs 585241675Suqsstruct bfd_link_order_reloc 586241675Suqs{ 587241675Suqs /* Reloc type. */ 588241675Suqs bfd_reloc_code_real_type reloc; 589241675Suqs 590241675Suqs union 591241675Suqs { 592241675Suqs /* For type bfd_section_reloc_link_order, this is the section 593241675Suqs the reloc should be against. This must be a section in the 594241675Suqs output BFD, not any of the input BFDs. */ 595241675Suqs asection *section; 596241675Suqs /* For type bfd_symbol_reloc_link_order, this is the name of the 597241675Suqs symbol the reloc should be against. */ 598241675Suqs const char *name; 599241675Suqs } u; 600241675Suqs 601241675Suqs /* Addend to use. The object file should contain zero. The BFD 602241675Suqs backend is responsible for filling in the contents of the object 603241675Suqs file correctly. For some object file formats (e.g., COFF) the 604241675Suqs addend must be stored into in the object file, and for some 605241675Suqs (e.g., SPARC a.out) it is kept in the reloc. */ 606241675Suqs bfd_vma addend; 607241675Suqs}; 608241675Suqs 609241675Suqs/* Allocate a new link_order for a section. */ 610241675Suqsextern struct bfd_link_order *bfd_new_link_order (bfd *, asection *); 611241675Suqs 612241675Suqs/* These structures are used to describe version information for the 613241675Suqs ELF linker. These structures could be manipulated entirely inside 614241675Suqs BFD, but it would be a pain. Instead, the regular linker sets up 615241675Suqs these structures, and then passes them into BFD. */ 616241675Suqs 617241675Suqs/* Glob pattern for a version. */ 618241675Suqs 619241675Suqsstruct bfd_elf_version_expr 620241675Suqs{ 621241675Suqs /* Next glob pattern for this version. */ 622241675Suqs struct bfd_elf_version_expr *next; 623241675Suqs /* Glob pattern. */ 624241675Suqs const char *pattern; 625241675Suqs /* NULL for a glob pattern, otherwise a straight symbol. */ 626241675Suqs const char *symbol; 627241675Suqs /* Defined by ".symver". */ 628241675Suqs unsigned int symver : 1; 629241675Suqs /* Defined by version script. */ 630241675Suqs unsigned int script : 1; 631241675Suqs /* Pattern type. */ 632241675Suqs#define BFD_ELF_VERSION_C_TYPE 1 633241675Suqs#define BFD_ELF_VERSION_CXX_TYPE 2 634241675Suqs#define BFD_ELF_VERSION_JAVA_TYPE 4 635241675Suqs unsigned int mask : 3; 636241675Suqs}; 637241675Suqs 638241675Suqsstruct bfd_elf_version_expr_head 639241675Suqs{ 640241675Suqs /* List of all patterns, both wildcards and non-wildcards. */ 641241675Suqs struct bfd_elf_version_expr *list; 642241675Suqs /* Hash table for non-wildcards. */ 643241675Suqs void *htab; 644241675Suqs /* Remaining patterns. */ 645241675Suqs struct bfd_elf_version_expr *remaining; 646241675Suqs /* What kind of pattern types are present in list (bitmask). */ 647241675Suqs unsigned int mask; 648241675Suqs}; 649241675Suqs 650241675Suqs/* Version dependencies. */ 651241675Suqs 652241675Suqsstruct bfd_elf_version_deps 653241675Suqs{ 654241675Suqs /* Next dependency for this version. */ 655241675Suqs struct bfd_elf_version_deps *next; 656241675Suqs /* The version which this version depends upon. */ 657241675Suqs struct bfd_elf_version_tree *version_needed; 658241675Suqs}; 659241675Suqs 660241675Suqs/* A node in the version tree. */ 661241675Suqs 662241675Suqsstruct bfd_elf_version_tree 663241675Suqs{ 664241675Suqs /* Next version. */ 665241675Suqs struct bfd_elf_version_tree *next; 666241675Suqs /* Name of this version. */ 667241675Suqs const char *name; 668241675Suqs /* Version number. */ 669241675Suqs unsigned int vernum; 670241675Suqs /* Regular expressions for global symbols in this version. */ 671241675Suqs struct bfd_elf_version_expr_head globals; 672241675Suqs /* Regular expressions for local symbols in this version. */ 673241675Suqs struct bfd_elf_version_expr_head locals; 674241675Suqs /* List of versions which this version depends upon. */ 675241675Suqs struct bfd_elf_version_deps *deps; 676241675Suqs /* Index of the version name. This is used within BFD. */ 677241675Suqs unsigned int name_indx; 678241675Suqs /* Whether this version tree was used. This is used within BFD. */ 679241675Suqs int used; 680241675Suqs /* Matching hook. */ 681241675Suqs struct bfd_elf_version_expr *(*match) 682241675Suqs (struct bfd_elf_version_expr_head *head, 683241675Suqs struct bfd_elf_version_expr *prev, const char *sym); 684241675Suqs}; 685241675Suqs 686241675Suqs#endif 687241675Suqs