1 /* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically 2 generated from "libcoff-in.h" and "coffcode.h". 3 Run "make headers" in your build bfd/ to regenerate. */ 4 5 /* BFD COFF object file private structure. 6 Copyright (C) 1990-2024 Free Software Foundation, Inc. 7 Written by Cygnus Support. 8 9 This file is part of BFD, the Binary File Descriptor library. 10 11 This program is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 3 of the License, or 14 (at your option) any later version. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 24 MA 02110-1301, USA. */ 25 26 #ifndef _LIBCOFF_H 27 #define _LIBCOFF_H 1 28 29 #include "bfdlink.h" 30 #include "coff-bfd.h" 31 #include "hashtab.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* Object file tdata; access macros. */ 38 39 #define coff_data(bfd) ((bfd)->tdata.coff_obj_data) 40 #define obj_pe(bfd) (coff_data (bfd)->pe) 41 #define obj_go32(bfd) (coff_data (bfd)->go32) 42 #define obj_symbols(bfd) (coff_data (bfd)->symbols) 43 #define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos) 44 #define obj_relocbase(bfd) (coff_data (bfd)->relocbase) 45 #define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments) 46 #define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count) 47 #define obj_convert(bfd) (coff_data (bfd)->conversion_table) 48 #define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size) 49 #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) 50 #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) 51 #define obj_coff_strings(bfd) (coff_data (bfd)->strings) 52 #define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len) 53 #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) 54 #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) 55 #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) 56 #define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map) 57 58 /* `Tdata' information kept for COFF files. */ 59 60 typedef struct coff_tdata 61 { 62 struct coff_symbol_struct *symbols; /* Symtab for input bfd. */ 63 unsigned int *conversion_table; 64 int conv_table_size; 65 file_ptr sym_filepos; 66 67 struct coff_ptr_struct *raw_syments; 68 unsigned long raw_syment_count; 69 70 /* These are only valid once writing has begun. */ 71 unsigned long int relocbase; 72 73 /* These members communicate important constants about the symbol table 74 to GDB's symbol-reading code. These `constants' unfortunately vary 75 from coff implementation to implementation... */ 76 unsigned local_n_btmask; 77 unsigned local_n_btshft; 78 unsigned local_n_tmask; 79 unsigned local_n_tshift; 80 unsigned local_symesz; 81 unsigned local_auxesz; 82 unsigned local_linesz; 83 84 /* The unswapped external symbols. May be NULL. Read by 85 _bfd_coff_get_external_symbols. */ 86 void * external_syms; 87 88 /* The string table. May be NULL. Read by 89 _bfd_coff_read_string_table. */ 90 char *strings; 91 /* The length of the strings table. For error checking. */ 92 bfd_size_type strings_len; 93 94 /* Set if long section names are supported. A writable copy of the COFF 95 backend flag _bfd_coff_long_section_names. */ 96 bool long_section_names; 97 98 /* If this is TRUE, the external_syms may not be freed. */ 99 bool keep_syms; 100 /* If this is TRUE, the strings may not be freed. */ 101 bool keep_strings; 102 /* If this is TRUE, the strings have been written out already. */ 103 bool strings_written; 104 105 /* Is this a GO32 coff file? */ 106 bool go32; 107 108 /* Is this a PE format coff file? */ 109 bool pe; 110 111 /* Copy of some of the f_flags bits in the COFF filehdr structure, 112 used by ARM code. */ 113 flagword flags; 114 115 /* Used by the COFF backend linker. */ 116 struct coff_link_hash_entry **sym_hashes; 117 118 /* Used by the pe linker for PowerPC. */ 119 int *local_toc_sym_map; 120 121 struct bfd_link_info *link_info; 122 123 /* Used by coff_find_nearest_line. */ 124 void * line_info; 125 126 /* A place to stash dwarf2 info for this bfd. */ 127 void * dwarf2_find_line_info; 128 129 /* The timestamp from the COFF file header. */ 130 long timestamp; 131 132 /* A stub (extra data prepended before the COFF image) and its size. 133 Used by coff-go32-exe, it contains executable data that loads the 134 COFF object into memory. */ 135 char * stub; 136 bfd_size_type stub_size; 137 138 /* Hash table containing sections by target index. */ 139 htab_t section_by_target_index; 140 141 /* Hash table containing sections by index. */ 142 htab_t section_by_index; 143 144 } coff_data_type; 145 146 /* Tdata for pe image files. */ 147 typedef struct pe_tdata 148 { 149 coff_data_type coff; 150 struct internal_extra_pe_aouthdr pe_opthdr; 151 int dll; 152 int has_reloc_section; 153 int dont_strip_reloc; 154 char dos_message[64]; 155 /* The timestamp to insert into the output file. 156 If the timestamp is -1 then the current time is used. */ 157 int timestamp; 158 bool (*in_reloc_p) (bfd *, reloc_howto_type *); 159 flagword real_flags; 160 161 /* Build-id info. */ 162 struct 163 { 164 bool (*after_write_object_contents) (bfd *); 165 const char *style; 166 asection *sec; 167 } build_id; 168 169 htab_t comdat_hash; 170 } pe_data_type; 171 172 #define pe_data(bfd) ((bfd)->tdata.pe_obj_data) 173 174 struct comdat_hash_entry 175 { 176 int target_index; 177 struct internal_syment isym; 178 char *symname; 179 flagword sec_flags; 180 char *comdat_name; 181 long comdat_symbol; 182 }; 183 184 /* Tdata for XCOFF files. */ 185 186 struct xcoff_tdata 187 { 188 /* Basic COFF information. */ 189 coff_data_type coff; 190 191 /* TRUE if this is an XCOFF64 file. */ 192 bool xcoff64; 193 194 /* TRUE if a large a.out header should be generated. */ 195 bool full_aouthdr; 196 197 /* TOC value. */ 198 bfd_vma toc; 199 200 /* Index of section holding TOC. */ 201 int sntoc; 202 203 /* Index of section holding entry point. */ 204 int snentry; 205 206 /* .text alignment from optional header. */ 207 int text_align_power; 208 209 /* .data alignment from optional header. */ 210 int data_align_power; 211 212 /* modtype from optional header. */ 213 short modtype; 214 215 /* cputype from optional header. */ 216 short cputype; 217 218 /* maxdata from optional header. */ 219 bfd_vma maxdata; 220 221 /* maxstack from optional header. */ 222 bfd_vma maxstack; 223 224 /* Used by the XCOFF backend linker. */ 225 asection **csects; 226 long *debug_indices; 227 unsigned int *lineno_counts; 228 unsigned int import_file_id; 229 }; 230 231 #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data) 232 233 /* We take the address of the first element of an asymbol to ensure that the 234 macro is only ever applied to an asymbol. */ 235 #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) 236 237 /* Tdata for sections in XCOFF files. This is used by the linker. */ 238 239 struct xcoff_section_tdata 240 { 241 /* Used for XCOFF csects created by the linker; points to the real 242 XCOFF section which contains this csect. */ 243 asection *enclosing; 244 /* The lineno_count field for the enclosing section, because we are 245 going to clobber it there. */ 246 unsigned int lineno_count; 247 /* The first and last symbol indices for symbols used by this csect. */ 248 unsigned long first_symndx; 249 unsigned long last_symndx; 250 }; 251 252 /* An accessor macro the xcoff_section_tdata structure. */ 253 #define xcoff_section_data(abfd, sec) \ 254 ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 255 256 /* Tdata for sections in PE files. */ 257 258 struct pei_section_tdata 259 { 260 /* The virtual size of the section. */ 261 bfd_size_type virt_size; 262 /* The PE section flags. */ 263 long pe_flags; 264 }; 265 266 /* An accessor macro for the pei_section_tdata structure. */ 267 #define pei_section_data(abfd, sec) \ 268 ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 269 270 /* COFF linker hash table entries. */ 271 272 struct coff_link_hash_entry 273 { 274 struct bfd_link_hash_entry root; 275 276 /* Symbol index in output file. This is initialized to -1. It is 277 set to -2 if the symbol is used by a reloc. It is set to -3 if 278 this symbol is defined in a discarded section. */ 279 long indx; 280 281 /* Symbol type. */ 282 unsigned short type; 283 284 /* Symbol class. */ 285 unsigned char symbol_class; 286 287 /* Number of auxiliary entries. */ 288 char numaux; 289 290 /* BFD to take auxiliary entries from. */ 291 bfd *auxbfd; 292 293 /* Pointer to array of auxiliary entries, if any. */ 294 union internal_auxent *aux; 295 296 /* Flag word; legal values follow. */ 297 unsigned short coff_link_hash_flags; 298 /* Symbol is a PE section symbol. */ 299 #define COFF_LINK_HASH_PE_SECTION_SYMBOL (01) 300 }; 301 302 /* COFF linker hash table. */ 303 304 struct coff_link_hash_table 305 { 306 struct bfd_link_hash_table root; 307 /* A pointer to information used to link stabs in sections. */ 308 struct stab_info stab_info; 309 /* Hash table that maps undecorated names to their respective 310 * decorated coff_link_hash_entry as found in fixup_stdcalls */ 311 struct bfd_hash_table decoration_hash; 312 }; 313 314 struct coff_reloc_cookie 315 { 316 struct internal_reloc * rels; 317 struct internal_reloc * rel; 318 struct internal_reloc * relend; 319 struct coff_symbol_struct * symbols; /* Symtab for input bfd. */ 320 bfd * abfd; 321 struct coff_link_hash_entry ** sym_hashes; 322 }; 323 324 /* Look up an entry in a COFF linker hash table. */ 325 326 #define coff_link_hash_lookup(table, string, create, copy, follow) \ 327 ((struct coff_link_hash_entry *) \ 328 bfd_link_hash_lookup (&(table)->root, (string), (create), \ 329 (copy), (follow))) 330 331 /* Traverse a COFF linker hash table. */ 332 333 #define coff_link_hash_traverse(table, func, info) \ 334 (bfd_link_hash_traverse \ 335 (&(table)->root, \ 336 (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \ 337 (info))) 338 339 /* Get the COFF linker hash table from a link_info structure. */ 340 341 #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) 342 343 struct decoration_hash_entry 344 { 345 struct bfd_hash_entry root; 346 struct bfd_link_hash_entry *decorated_link; 347 }; 348 349 /* Functions in coffgen.c. */ 350 extern void coff_object_cleanup 351 (bfd *); 352 extern bfd_cleanup coff_real_object_p 353 (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *); 354 extern bfd_cleanup coff_object_p 355 (bfd *); 356 extern struct bfd_section *coff_section_from_bfd_index 357 (bfd *, int); 358 extern long coff_get_symtab_upper_bound 359 (bfd *); 360 extern long coff_canonicalize_symtab 361 (bfd *, asymbol **); 362 extern int coff_count_linenumbers 363 (bfd *); 364 extern bool coff_renumber_symbols 365 (bfd *, int *); 366 extern void coff_mangle_symbols 367 (bfd *); 368 extern bool coff_write_symbols 369 (bfd *); 370 extern bool coff_write_alien_symbol 371 (bfd *, asymbol *, struct internal_syment *, bfd_vma *, 372 struct bfd_strtab_hash *, bool, asection **, bfd_size_type *); 373 extern bool coff_write_linenumbers 374 (bfd *); 375 extern alent *coff_get_lineno 376 (bfd *, asymbol *); 377 extern asymbol *coff_section_symbol 378 (bfd *, char *); 379 extern bool _bfd_coff_get_external_symbols 380 (bfd *); 381 extern const char *_bfd_coff_read_string_table 382 (bfd *); 383 extern bool _bfd_coff_free_symbols 384 (bfd *); 385 extern struct coff_ptr_struct *coff_get_normalized_symtab 386 (bfd *); 387 extern long coff_get_reloc_upper_bound 388 (bfd *, sec_ptr); 389 extern asymbol *coff_make_empty_symbol 390 (bfd *); 391 extern void coff_print_symbol 392 (bfd *, void * filep, asymbol *, bfd_print_symbol_type); 393 extern void coff_get_symbol_info 394 (bfd *, asymbol *, symbol_info *ret); 395 #define coff_get_symbol_version_string \ 396 _bfd_nosymbols_get_symbol_version_string 397 extern bool _bfd_coff_is_local_label_name 398 (bfd *, const char *); 399 extern asymbol *coff_bfd_make_debug_symbol 400 (bfd *); 401 extern bool coff_find_nearest_line 402 (bfd *, asymbol **, asection *, bfd_vma, 403 const char **, const char **, unsigned int *, unsigned int *); 404 #define coff_find_nearest_line_with_alt \ 405 _bfd_nosymbols_find_nearest_line_with_alt 406 #define coff_find_line _bfd_nosymbols_find_line 407 struct dwarf_debug_section; 408 extern bool coff_find_nearest_line_with_names 409 (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **, 410 unsigned int *, const struct dwarf_debug_section *); 411 extern bool coff_find_inliner_info 412 (bfd *, const char **, const char **, unsigned int *); 413 extern int coff_sizeof_headers 414 (bfd *, struct bfd_link_info *); 415 extern bool bfd_coff_reloc16_relax_section 416 (bfd *, asection *, struct bfd_link_info *, bool *); 417 extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents 418 (bfd *, struct bfd_link_info *, struct bfd_link_order *, 419 bfd_byte *, bool, asymbol **); 420 extern bfd_vma bfd_coff_reloc16_get_value 421 (arelent *, struct bfd_link_info *, asection *); 422 extern void bfd_perform_slip 423 (bfd *, unsigned int, asection *, bfd_vma); 424 extern bool _bfd_coff_free_cached_info 425 (bfd *); 426 427 /* Functions and types in cofflink.c. */ 428 429 #define STRING_SIZE_SIZE 4 430 431 /* We use a hash table to merge identical enum, struct, and union 432 definitions in the linker. */ 433 434 /* Information we keep for a single element (an enum value, a 435 structure or union field) in the debug merge hash table. */ 436 437 struct coff_debug_merge_element 438 { 439 /* Next element. */ 440 struct coff_debug_merge_element *next; 441 442 /* Name. */ 443 const char *name; 444 445 /* Type. */ 446 unsigned int type; 447 448 /* Symbol index for complex type. */ 449 long tagndx; 450 }; 451 452 /* A linked list of debug merge entries for a given name. */ 453 454 struct coff_debug_merge_type 455 { 456 /* Next type with the same name. */ 457 struct coff_debug_merge_type *next; 458 459 /* Class of type. */ 460 int type_class; 461 462 /* Symbol index where this type is defined. */ 463 long indx; 464 465 /* List of elements. */ 466 struct coff_debug_merge_element *elements; 467 }; 468 469 /* Information we store in the debug merge hash table. */ 470 471 struct coff_debug_merge_hash_entry 472 { 473 struct bfd_hash_entry root; 474 475 /* A list of types with this name. */ 476 struct coff_debug_merge_type *types; 477 }; 478 479 /* The debug merge hash table. */ 480 481 struct coff_debug_merge_hash_table 482 { 483 struct bfd_hash_table root; 484 }; 485 486 /* Initialize a COFF debug merge hash table. */ 487 488 #define coff_debug_merge_hash_table_init(table) \ 489 (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \ 490 sizeof (struct coff_debug_merge_hash_entry))) 491 492 /* Free a COFF debug merge hash table. */ 493 494 #define coff_debug_merge_hash_table_free(table) \ 495 (bfd_hash_table_free (&(table)->root)) 496 497 /* Look up an entry in a COFF debug merge hash table. */ 498 499 #define coff_debug_merge_hash_lookup(table, string, create, copy) \ 500 ((struct coff_debug_merge_hash_entry *) \ 501 bfd_hash_lookup (&(table)->root, (string), (create), (copy))) 502 503 /* Information we keep for each section in the output file when doing 504 a relocatable link. */ 505 506 struct coff_link_section_info 507 { 508 /* The relocs to be output. */ 509 struct internal_reloc *relocs; 510 /* For each reloc against a global symbol whose index was not known 511 when the reloc was handled, the global hash table entry. */ 512 struct coff_link_hash_entry **rel_hashes; 513 }; 514 515 /* Information that we pass around while doing the final link step. */ 516 517 struct coff_final_link_info 518 { 519 /* General link information. */ 520 struct bfd_link_info *info; 521 /* Output BFD. */ 522 bfd *output_bfd; 523 /* Used to indicate failure in traversal routine. */ 524 bool failed; 525 /* If doing "task linking" set only during the time when we want the 526 global symbol writer to convert the storage class of defined global 527 symbols from global to static. */ 528 bool global_to_static; 529 /* Hash table for long symbol names. */ 530 struct bfd_strtab_hash *strtab; 531 /* When doing a relocatable link, an array of information kept for 532 each output section, indexed by the target_index field. */ 533 struct coff_link_section_info *section_info; 534 /* Symbol index of last C_FILE symbol (-1 if none). */ 535 long last_file_index; 536 /* Contents of last C_FILE symbol. */ 537 struct internal_syment last_file; 538 /* Symbol index of first aux entry of last .bf symbol with an empty 539 endndx field (-1 if none). */ 540 long last_bf_index; 541 /* Contents of last_bf_index aux entry. */ 542 union internal_auxent last_bf; 543 /* Hash table used to merge debug information. */ 544 struct coff_debug_merge_hash_table debug_merge; 545 /* Buffer large enough to hold swapped symbols of any input file. */ 546 struct internal_syment *internal_syms; 547 /* Buffer large enough to hold sections of symbols of any input file. */ 548 asection **sec_ptrs; 549 /* Buffer large enough to hold output indices of symbols of any 550 input file. */ 551 long *sym_indices; 552 /* Buffer large enough to hold output symbols for any input file. */ 553 bfd_byte *outsyms; 554 /* Buffer large enough to hold external line numbers for any input 555 section. */ 556 bfd_byte *linenos; 557 /* Buffer large enough to hold any input section. */ 558 bfd_byte *contents; 559 /* Buffer large enough to hold external relocs of any input section. */ 560 bfd_byte *external_relocs; 561 /* Buffer large enough to hold swapped relocs of any input section. */ 562 struct internal_reloc *internal_relocs; 563 }; 564 565 /* Most COFF variants have no way to record the alignment of a 566 section. This struct is used to set a specific alignment based on 567 the name of the section. */ 568 569 struct coff_section_alignment_entry 570 { 571 /* The section name. */ 572 const char *name; 573 574 /* This is either (unsigned int) -1, indicating that the section 575 name must match exactly, or it is the number of letters which 576 must match at the start of the name. */ 577 unsigned int comparison_length; 578 579 /* These macros may be used to fill in the first two fields in a 580 structure initialization. */ 581 #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1) 582 #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1) 583 584 /* Only use this entry if the default section alignment for this 585 target is at least that much (as a power of two). If this field 586 is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 587 unsigned int default_alignment_min; 588 589 /* Only use this entry if the default section alignment for this 590 target is no greater than this (as a power of two). If this 591 field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 592 unsigned int default_alignment_max; 593 594 #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1) 595 596 /* The desired alignment for this section (as a power of two). */ 597 unsigned int alignment_power; 598 }; 599 600 extern struct bfd_hash_entry *_decoration_hash_newfunc 601 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 602 extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc 603 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 604 extern bool _bfd_coff_link_hash_table_init 605 (struct coff_link_hash_table *, bfd *, 606 struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 607 struct bfd_hash_table *, 608 const char *), 609 unsigned int); 610 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create 611 (bfd *); 612 extern const char *_bfd_coff_internal_syment_name 613 (bfd *, const struct internal_syment *, char *); 614 extern bool _bfd_coff_section_already_linked 615 (bfd *, asection *, struct bfd_link_info *); 616 extern bool _bfd_coff_link_add_symbols 617 (bfd *, struct bfd_link_info *); 618 extern bool _bfd_coff_final_link 619 (bfd *, struct bfd_link_info *); 620 extern struct internal_reloc *_bfd_coff_read_internal_relocs 621 (bfd *, asection *, bool, bfd_byte *, bool, 622 struct internal_reloc *); 623 extern bool _bfd_coff_generic_relocate_section 624 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 625 struct internal_reloc *, struct internal_syment *, asection **); 626 extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc 627 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 628 extern bool _bfd_coff_write_global_sym 629 (struct bfd_hash_entry *, void *); 630 extern bool _bfd_coff_write_task_globals 631 (struct coff_link_hash_entry *, void *); 632 extern bool _bfd_coff_link_input_bfd 633 (struct coff_final_link_info *, bfd *); 634 extern bool _bfd_coff_reloc_link_order 635 (bfd *, struct coff_final_link_info *, asection *, 636 struct bfd_link_order *); 637 extern bool bfd_coff_gc_sections 638 (bfd *, struct bfd_link_info *); 639 extern const char *bfd_coff_group_name 640 (bfd *, const asection *); 641 642 /* Functions in xcofflink.c. */ 643 644 extern long _bfd_xcoff_get_dynamic_symtab_upper_bound 645 (bfd *); 646 extern long _bfd_xcoff_canonicalize_dynamic_symtab 647 (bfd *, asymbol **); 648 extern long _bfd_xcoff_get_dynamic_reloc_upper_bound 649 (bfd *); 650 extern long _bfd_xcoff_canonicalize_dynamic_reloc 651 (bfd *, arelent **, asymbol **); 652 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create 653 (bfd *); 654 extern bool _bfd_xcoff_bfd_link_add_symbols 655 (bfd *, struct bfd_link_info *); 656 extern bool _bfd_xcoff_bfd_final_link 657 (bfd *, struct bfd_link_info *); 658 extern bool _bfd_xcoff_define_common_symbol 659 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *); 660 extern bool _bfd_ppc_xcoff_relocate_section 661 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 662 struct internal_reloc *, struct internal_syment *, asection **); 663 /* Extracted from coffcode.h. */ 664 typedef struct coff_ptr_struct 665 { 666 /* Remembers the offset from the first symbol in the file for 667 this symbol. Generated by coff_renumber_symbols. */ 668 unsigned int offset; 669 670 /* Selects between the elements of the union below. */ 671 unsigned int is_sym : 1; 672 673 /* Selects between the elements of the x_sym.x_tagndx union. If set, 674 p is valid and the field will be renumbered. */ 675 unsigned int fix_tag : 1; 676 677 /* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx 678 union. If set, p is valid and the field will be renumbered. */ 679 unsigned int fix_end : 1; 680 681 /* Selects between the elements of the x_csect.x_scnlen union. If set, 682 p is valid and the field will be renumbered. */ 683 unsigned int fix_scnlen : 1; 684 685 /* If set, u.syment.n_value contains a pointer to a symbol. The final 686 value will be the offset field. Used for XCOFF C_BSTAT symbols. */ 687 unsigned int fix_value : 1; 688 689 /* If set, u.syment.n_value is an index into the line number entries. 690 Used for XCOFF C_BINCL/C_EINCL symbols. */ 691 unsigned int fix_line : 1; 692 693 /* The container for the symbol structure as read and translated 694 from the file. */ 695 union 696 { 697 union internal_auxent auxent; 698 struct internal_syment syment; 699 } u; 700 701 /* An extra pointer which can used by format based on COFF (like XCOFF) 702 to provide extra information to their backend. */ 703 void *extrap; 704 } combined_entry_type; 705 706 /* Each canonical asymbol really looks like this: */ 707 708 typedef struct coff_symbol_struct 709 { 710 /* The actual symbol which the rest of BFD works with */ 711 asymbol symbol; 712 713 /* A pointer to the hidden information for this symbol */ 714 combined_entry_type *native; 715 716 /* A pointer to the linenumber information for this symbol */ 717 struct lineno_cache_entry *lineno; 718 719 /* Have the line numbers been relocated yet ? */ 720 bool done_lineno; 721 } coff_symbol_type; 722 723 /* COFF symbol classifications. */ 724 725 enum coff_symbol_classification 726 { 727 /* Global symbol. */ 728 COFF_SYMBOL_GLOBAL, 729 /* Common symbol. */ 730 COFF_SYMBOL_COMMON, 731 /* Undefined symbol. */ 732 COFF_SYMBOL_UNDEFINED, 733 /* Local symbol. */ 734 COFF_SYMBOL_LOCAL, 735 /* PE section symbol. */ 736 COFF_SYMBOL_PE_SECTION 737 }; 738 739 typedef asection * (*coff_gc_mark_hook_fn) 740 (asection *, struct bfd_link_info *, struct internal_reloc *, 741 struct coff_link_hash_entry *, struct internal_syment *); 742 743 typedef struct 744 { 745 void (*_bfd_coff_swap_aux_in) 746 (bfd *, void *, int, int, int, int, void *); 747 748 void (*_bfd_coff_swap_sym_in) 749 (bfd *, void *, void *); 750 751 void (*_bfd_coff_swap_lineno_in) 752 (bfd *, void *, void *); 753 754 unsigned int (*_bfd_coff_swap_aux_out) 755 (bfd *, void *, int, int, int, int, void *); 756 757 unsigned int (*_bfd_coff_swap_sym_out) 758 (bfd *, void *, void *); 759 760 unsigned int (*_bfd_coff_swap_lineno_out) 761 (bfd *, void *, void *); 762 763 unsigned int (*_bfd_coff_swap_reloc_out) 764 (bfd *, void *, void *); 765 766 unsigned int (*_bfd_coff_swap_filehdr_out) 767 (bfd *, void *, void *); 768 769 unsigned int (*_bfd_coff_swap_aouthdr_out) 770 (bfd *, void *, void *); 771 772 unsigned int (*_bfd_coff_swap_scnhdr_out) 773 (bfd *, void *, void *); 774 775 unsigned int _bfd_filhsz; 776 unsigned int _bfd_aoutsz; 777 unsigned int _bfd_scnhsz; 778 unsigned int _bfd_symesz; 779 unsigned int _bfd_auxesz; 780 unsigned int _bfd_relsz; 781 unsigned int _bfd_linesz; 782 unsigned int _bfd_filnmlen; 783 bool _bfd_coff_long_filenames; 784 785 bool _bfd_coff_long_section_names; 786 bool (*_bfd_coff_set_long_section_names) 787 (bfd *, int); 788 789 unsigned int _bfd_coff_default_section_alignment_power; 790 bool _bfd_coff_force_symnames_in_strings; 791 unsigned int _bfd_coff_debug_string_prefix_length; 792 unsigned int _bfd_coff_max_nscns; 793 794 void (*_bfd_coff_swap_filehdr_in) 795 (bfd *, void *, void *); 796 797 void (*_bfd_coff_swap_aouthdr_in) 798 (bfd *, void *, void *); 799 800 void (*_bfd_coff_swap_scnhdr_in) 801 (bfd *, void *, void *); 802 803 void (*_bfd_coff_swap_reloc_in) 804 (bfd *abfd, void *, void *); 805 806 bool (*_bfd_coff_bad_format_hook) 807 (bfd *, void *); 808 809 bool (*_bfd_coff_set_arch_mach_hook) 810 (bfd *, void *); 811 812 void * (*_bfd_coff_mkobject_hook) 813 (bfd *, void *, void *); 814 815 bool (*_bfd_styp_to_sec_flags_hook) 816 (bfd *, void *, const char *, asection *, flagword *); 817 818 void (*_bfd_set_alignment_hook) 819 (bfd *, asection *, void *); 820 821 bool (*_bfd_coff_slurp_symbol_table) 822 (bfd *); 823 824 bool (*_bfd_coff_symname_in_debug) 825 (bfd *, struct internal_syment *); 826 827 bool (*_bfd_coff_pointerize_aux_hook) 828 (bfd *, combined_entry_type *, combined_entry_type *, 829 unsigned int, combined_entry_type *); 830 831 bool (*_bfd_coff_print_aux) 832 (bfd *, FILE *, combined_entry_type *, combined_entry_type *, 833 combined_entry_type *, unsigned int); 834 835 bool (*_bfd_coff_reloc16_extra_cases) 836 (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, 837 bfd_byte *, size_t *, size_t *); 838 839 int (*_bfd_coff_reloc16_estimate) 840 (bfd *, asection *, arelent *, unsigned int, 841 struct bfd_link_info *); 842 843 enum coff_symbol_classification (*_bfd_coff_classify_symbol) 844 (bfd *, struct internal_syment *); 845 846 bool (*_bfd_coff_compute_section_file_positions) 847 (bfd *); 848 849 bool (*_bfd_coff_start_final_link) 850 (bfd *, struct bfd_link_info *); 851 852 bool (*_bfd_coff_relocate_section) 853 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 854 struct internal_reloc *, struct internal_syment *, asection **); 855 856 reloc_howto_type *(*_bfd_coff_rtype_to_howto) 857 (bfd *, asection *, struct internal_reloc *, 858 struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *); 859 860 bool (*_bfd_coff_adjust_symndx) 861 (bfd *, struct bfd_link_info *, bfd *, asection *, 862 struct internal_reloc *, bool *); 863 864 bool (*_bfd_coff_link_add_one_symbol) 865 (struct bfd_link_info *, bfd *, const char *, flagword, 866 asection *, bfd_vma, const char *, bool, bool, 867 struct bfd_link_hash_entry **); 868 869 bool (*_bfd_coff_link_output_has_begun) 870 (bfd *, struct coff_final_link_info *); 871 872 bool (*_bfd_coff_final_link_postscript) 873 (bfd *, struct coff_final_link_info *); 874 875 bool (*_bfd_coff_print_pdata) 876 (bfd *, void *); 877 878 } bfd_coff_backend_data; 879 880 #define coff_backend_info(abfd) \ 881 ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data) 882 883 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ 884 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) 885 886 #define bfd_coff_swap_sym_in(a,e,i) \ 887 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) 888 889 #define bfd_coff_swap_lineno_in(a,e,i) \ 890 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) 891 892 #define bfd_coff_swap_reloc_out(abfd, i, o) \ 893 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) 894 895 #define bfd_coff_swap_lineno_out(abfd, i, o) \ 896 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) 897 898 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ 899 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) 900 901 #define bfd_coff_swap_sym_out(abfd, i,o) \ 902 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) 903 904 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \ 905 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) 906 907 #define bfd_coff_swap_filehdr_out(abfd, i,o) \ 908 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) 909 910 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \ 911 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) 912 913 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) 914 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) 915 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) 916 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) 917 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) 918 #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) 919 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) 920 #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen) 921 #define bfd_coff_long_filenames(abfd) \ 922 (coff_backend_info (abfd)->_bfd_coff_long_filenames) 923 #define bfd_coff_long_section_names(abfd) \ 924 (coff_data (abfd)->long_section_names) 925 #define bfd_coff_set_long_section_names(abfd, enable) \ 926 ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) 927 #define bfd_coff_default_section_alignment_power(abfd) \ 928 (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) 929 #define bfd_coff_max_nscns(abfd) \ 930 (coff_backend_info (abfd)->_bfd_coff_max_nscns) 931 932 #define bfd_coff_swap_filehdr_in(abfd, i,o) \ 933 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) 934 935 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \ 936 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) 937 938 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \ 939 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) 940 941 #define bfd_coff_swap_reloc_in(abfd, i, o) \ 942 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) 943 944 #define bfd_coff_bad_format_hook(abfd, filehdr) \ 945 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) 946 947 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ 948 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) 949 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ 950 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\ 951 (abfd, filehdr, aouthdr)) 952 953 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\ 954 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\ 955 (abfd, scnhdr, name, section, flags_ptr)) 956 957 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ 958 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) 959 960 #define bfd_coff_slurp_symbol_table(abfd)\ 961 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) 962 963 #define bfd_coff_symname_in_debug(abfd, sym)\ 964 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) 965 966 #define bfd_coff_force_symnames_in_strings(abfd)\ 967 (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings) 968 969 #define bfd_coff_debug_string_prefix_length(abfd)\ 970 (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length) 971 972 #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ 973 ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ 974 (abfd, file, base, symbol, aux, indaux)) 975 976 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\ 977 reloc, data, src_ptr, dst_ptr)\ 978 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ 979 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) 980 981 #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ 982 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ 983 (abfd, section, reloc, shrink, link_info)) 984 985 #define bfd_coff_classify_symbol(abfd, sym)\ 986 ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\ 987 (abfd, sym)) 988 989 #define bfd_coff_compute_section_file_positions(abfd)\ 990 ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ 991 (abfd)) 992 993 #define bfd_coff_start_final_link(obfd, info)\ 994 ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ 995 (obfd, info)) 996 #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ 997 ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ 998 (obfd, info, ibfd, o, con, rel, isyms, secs)) 999 #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ 1000 ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ 1001 (abfd, sec, rel, h, sym, addendp)) 1002 #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ 1003 ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ 1004 (obfd, info, ibfd, sec, rel, adjustedp)) 1005 #define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\ 1006 value, string, cp, coll, hashp)\ 1007 ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ 1008 (info, abfd, name, flags, section, value, string, cp, coll, hashp)) 1009 1010 #define bfd_coff_link_output_has_begun(a,p) \ 1011 ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p)) 1012 #define bfd_coff_final_link_postscript(a,p) \ 1013 ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p)) 1014 1015 #define bfd_coff_have_print_pdata(a) \ 1016 (coff_backend_info (a)->_bfd_coff_print_pdata) 1017 #define bfd_coff_print_pdata(a,p) \ 1018 ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p)) 1019 1020 /* Macro: Returns true if the bfd is a PE executable as opposed to a 1021 PE object file. */ 1022 #define bfd_pei_p(abfd) \ 1023 (startswith ((abfd)->xvec->name, "pei-")) 1024 #ifdef __cplusplus 1025 } 1026 #endif 1027 #endif 1028