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