libcoff.h revision 33965
1149487Stjr/* BFD COFF object file private structure. 260786Sps Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 3161478Sdelphij Free Software Foundation, Inc. 460786Sps Written by Cygnus Support. 560786Sps 660786Sps** NOTE: libcoff.h is a GENERATED file. Don't change it; instead, 760786Sps** change libcoff-in.h or coffcode.h. 860786Sps 960786SpsThis file is part of BFD, the Binary File Descriptor library. 1060786Sps 1160786SpsThis program is free software; you can redistribute it and/or modify 1260786Spsit under the terms of the GNU General Public License as published by 1360786Spsthe Free Software Foundation; either version 2 of the License, or 1460786Sps(at your option) any later version. 1560786Sps 1660786SpsThis program is distributed in the hope that it will be useful, 1760786Spsbut WITHOUT ANY WARRANTY; without even the implied warranty of 1860786SpsMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1960786SpsGNU General Public License for more details. 20161478Sdelphij 2160786SpsYou should have received a copy of the GNU General Public License 22161478Sdelphijalong with this program; if not, write to the Free Software 2389019SpsFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2489019Sps 2560786Sps#include "bfdlink.h" 26161478Sdelphij 2760786Sps/* Object file tdata; access macros */ 2889019Sps 2989019Sps#define coff_data(bfd) ((bfd)->tdata.coff_obj_data) 3089019Sps#define exec_hdr(bfd) (coff_data(bfd)->hdr) 3160786Sps#define obj_pe(bfd) (coff_data(bfd)->pe) 3260786Sps#define obj_symbols(bfd) (coff_data(bfd)->symbols) 3360786Sps#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos) 3460786Sps 3560786Sps#define obj_relocbase(bfd) (coff_data(bfd)->relocbase) 36128345Stjr#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments) 3760786Sps#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count) 3863128Sps#define obj_convert(bfd) (coff_data(bfd)->conversion_table) 39161478Sdelphij#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size) 4060786Sps 4160786Sps#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) 4260786Sps#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) 43161478Sdelphij#define obj_coff_strings(bfd) (coff_data (bfd)->strings) 4460786Sps#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) 45161478Sdelphij#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) 46161478Sdelphij 4760786Sps#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map) 4860786Sps 49161478Sdelphij/* `Tdata' information kept for COFF files. */ 5060786Sps 5160786Spstypedef struct coff_tdata 5260786Sps{ 5360786Sps struct coff_symbol_struct *symbols; /* symtab for input bfd */ 5460786Sps unsigned int *conversion_table; 5563128Sps int conv_table_size; 5660786Sps file_ptr sym_filepos; 5760786Sps 5860786Sps struct coff_ptr_struct *raw_syments; 5960786Sps unsigned int raw_syment_count; 6060786Sps 6160786Sps /* These are only valid once writing has begun */ 6260786Sps long int relocbase; 6363128Sps 6463128Sps /* These members communicate important constants about the symbol table 6560786Sps to GDB's symbol-reading code. These `constants' unfortunately vary 66161478Sdelphij from coff implementation to implementation... */ 67161478Sdelphij unsigned local_n_btmask; 68161478Sdelphij unsigned local_n_btshft; 69161478Sdelphij unsigned local_n_tmask; 70161478Sdelphij unsigned local_n_tshift; 7160786Sps unsigned local_symesz; 7260786Sps unsigned local_auxesz; 7360786Sps unsigned local_linesz; 7460786Sps 7560786Sps /* The unswapped external symbols. May be NULL. Read by 7660786Sps _bfd_coff_get_external_symbols. */ 7760786Sps PTR external_syms; 7860786Sps /* If this is true, the external_syms may not be freed. */ 7960786Sps boolean keep_syms; 80161478Sdelphij 81161478Sdelphij /* The string table. May be NULL. Read by 82161478Sdelphij _bfd_coff_read_string_table. */ 83161478Sdelphij char *strings; 84161478Sdelphij /* If this is true, the strings may not be freed. */ 8589019Sps boolean keep_strings; 8689019Sps 8789019Sps /* is this a PE format coff file */ 8860786Sps int pe; 8960786Sps /* Used by the COFF backend linker. */ 9060786Sps struct coff_link_hash_entry **sym_hashes; 9189019Sps 9289019Sps /* used by the pe linker for PowerPC */ 93161478Sdelphij int *local_toc_sym_map; 9489019Sps 9589019Sps struct bfd_link_info *link_info; 96161478Sdelphij 97161478Sdelphij /* Used by coff_find_nearest_line. */ 98161478Sdelphij PTR line_info; 99161478Sdelphij} coff_data_type; 100161478Sdelphij 101161478Sdelphij/* Tdata for pe image files. */ 102161478Sdelphijtypedef struct pe_tdata 103161478Sdelphij{ 10489019Sps coff_data_type coff; 10589019Sps struct internal_extra_pe_aouthdr pe_opthdr; 106161478Sdelphij int dll; 10789019Sps int has_reloc_section; 10889019Sps boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *)); 10989019Sps flagword real_flags; 11089019Sps} pe_data_type; 11189019Sps 11289019Sps#define pe_data(bfd) ((bfd)->tdata.pe_obj_data) 11389019Sps 11489019Sps/* Tdata for XCOFF files. */ 115161478Sdelphij 116161478Sdelphijstruct xcoff_tdata 117161478Sdelphij{ 118161478Sdelphij /* Basic COFF information. */ 119161478Sdelphij coff_data_type coff; 120161478Sdelphij 121161478Sdelphij /* True if a large a.out header should be generated. */ 122161478Sdelphij boolean full_aouthdr; 123161478Sdelphij 124161478Sdelphij /* TOC value. */ 125161478Sdelphij bfd_vma toc; 126161478Sdelphij 12789019Sps /* Index of section holding TOC. */ 12889019Sps int sntoc; 129128345Stjr 130128345Stjr /* Index of section holding entry point. */ 131161478Sdelphij int snentry; 13289019Sps 13389019Sps /* .text alignment from optional header. */ 13489019Sps int text_align_power; 13589019Sps 13689019Sps /* .data alignment from optional header. */ 13789019Sps int data_align_power; 13889019Sps 139161478Sdelphij /* modtype from optional header. */ 140161478Sdelphij short modtype; 141161478Sdelphij 142161478Sdelphij /* cputype from optional header. */ 143161478Sdelphij short cputype; 144161478Sdelphij 145161478Sdelphij /* maxdata from optional header. */ 146161478Sdelphij bfd_size_type maxdata; 147161478Sdelphij 148161478Sdelphij /* maxstack from optional header. */ 14960786Sps bfd_size_type maxstack; 15060786Sps 15160786Sps /* Used by the XCOFF backend linker. */ 15260786Sps asection **csects; 15360786Sps unsigned long *debug_indices; 15460786Sps unsigned int import_file_id; 15560786Sps}; 156161478Sdelphij 15760786Sps#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data) 158161478Sdelphij 159161478Sdelphij/* We take the address of the first element of a asymbol to ensure that the 16060786Sps * macro is only ever applied to an asymbol. */ 16160786Sps#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) 16263128Sps 163128345Stjr/* The used_by_bfd field of a section may be set to a pointer to this 164128345Stjr structure. */ 16589019Sps 166161478Sdelphijstruct coff_section_tdata 16789019Sps{ 16860786Sps /* The relocs, swapped into COFF internal form. This may be NULL. */ 16960786Sps struct internal_reloc *relocs; 17060786Sps /* If this is true, the relocs entry may not be freed. */ 17160786Sps boolean keep_relocs; 17260786Sps /* The section contents. This may be NULL. */ 17360786Sps bfd_byte *contents; 17460786Sps /* If this is true, the contents entry may not be freed. */ 17560786Sps boolean keep_contents; 17660786Sps /* Information cached by coff_find_nearest_line. */ 177128345Stjr bfd_vma offset; 17860786Sps unsigned int i; 17960786Sps const char *function; 18063128Sps int line_base; 18163128Sps /* A pointer used for .stab linking optimizations. */ 18263128Sps PTR stab_info; 18363128Sps /* Available for individual backends. */ 18463128Sps PTR tdata; 18563128Sps}; 18663128Sps 18763128Sps/* An accessor macro for the coff_section_tdata structure. */ 18863128Sps#define coff_section_data(abfd, sec) \ 18963128Sps ((struct coff_section_tdata *) (sec)->used_by_bfd) 190128345Stjr 19163128Sps/* Tdata for sections in XCOFF files. This is used by the linker. */ 19263128Sps 19360786Spsstruct xcoff_section_tdata 19463128Sps{ 19560786Sps /* Used for XCOFF csects created by the linker; points to the real 19663128Sps XCOFF section which contains this csect. */ 19763128Sps asection *enclosing; 19863128Sps /* The lineno_count field for the enclosing section, because we are 19963128Sps going to clobber it there. */ 20063128Sps unsigned int lineno_count; 201161478Sdelphij /* The first and one past the last symbol indices for symbols used 20263128Sps by this csect. */ 203161478Sdelphij unsigned long first_symndx; 20463128Sps unsigned long last_symndx; 20563128Sps}; 20663128Sps 20760786Sps/* An accessor macro the xcoff_section_tdata structure. */ 20863128Sps#define xcoff_section_data(abfd, sec) \ 20963128Sps ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 21060786Sps 21163128Sps/* Tdata for sections in PEI image files. */ 21263128Sps 213128345Stjrstruct pei_section_tdata 214128345Stjr{ 215128345Stjr /* The virtual size of the section. */ 216128345Stjr bfd_size_type virt_size; 217128345Stjr}; 218128345Stjr 219128345Stjr/* An accessor macro for the pei_section_tdata structure. */ 220128345Stjr#define pei_section_data(abfd, sec) \ 221128345Stjr ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 222128345Stjr 223128345Stjr/* COFF linker hash table entries. */ 224128345Stjr 225128345Stjrstruct coff_link_hash_entry 226128345Stjr{ 22763128Sps struct bfd_link_hash_entry root; 228128345Stjr 22960786Sps /* Symbol index in output file. Set to -1 initially. Set to -2 if 23063128Sps there is a reloc against this symbol. */ 23160786Sps long indx; 23263128Sps 23360786Sps /* Symbol type. */ 23460786Sps unsigned short type; 23560786Sps 23660786Sps /* Symbol class. */ 23763128Sps unsigned char class; 23860786Sps 23960786Sps /* Number of auxiliary entries. */ 24060786Sps char numaux; 241161478Sdelphij 242161478Sdelphij /* BFD to take auxiliary entries from. */ 24360786Sps bfd *auxbfd; 244161478Sdelphij 245161478Sdelphij /* Pointer to array of auxiliary entries, if any. */ 246161478Sdelphij union internal_auxent *aux; 247161478Sdelphij}; 248161478Sdelphij 249161478Sdelphij/* COFF linker hash table. */ 250161478Sdelphij 251161478Sdelphijstruct coff_link_hash_table 252161478Sdelphij{ 25389019Sps struct bfd_link_hash_table root; 254161478Sdelphij /* A pointer to information used to link stabs in sections. */ 255161478Sdelphij PTR stab_info; 256161478Sdelphij}; 25789019Sps 258161478Sdelphij/* Look up an entry in a COFF linker hash table. */ 259161478Sdelphij 260161478Sdelphij#define coff_link_hash_lookup(table, string, create, copy, follow) \ 261161478Sdelphij ((struct coff_link_hash_entry *) \ 262161478Sdelphij bfd_link_hash_lookup (&(table)->root, (string), (create), \ 263161478Sdelphij (copy), (follow))) 26489019Sps 265161478Sdelphij/* Traverse a COFF linker hash table. */ 266161478Sdelphij 26789019Sps#define coff_link_hash_traverse(table, func, info) \ 268161478Sdelphij (bfd_link_hash_traverse \ 26989019Sps (&(table)->root, \ 270161478Sdelphij (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ 271161478Sdelphij (info))) 27289019Sps 273161478Sdelphij/* Get the COFF linker hash table from a link_info structure. */ 274161478Sdelphij 275161478Sdelphij#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) 276161478Sdelphij 277161478Sdelphij/* Functions in coffgen.c. */ 278161478Sdelphijextern const bfd_target *coff_object_p PARAMS ((bfd *)); 279161478Sdelphijextern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int)); 280161478Sdelphijextern long coff_get_symtab_upper_bound PARAMS ((bfd *)); 281161478Sdelphijextern long coff_get_symtab PARAMS ((bfd *, asymbol **)); 282161478Sdelphijextern int coff_count_linenumbers PARAMS ((bfd *)); 283161478Sdelphijextern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *)); 284161478Sdelphijextern boolean coff_renumber_symbols PARAMS ((bfd *, int *)); 285161478Sdelphijextern void coff_mangle_symbols PARAMS ((bfd *)); 286161478Sdelphijextern boolean coff_write_symbols PARAMS ((bfd *)); 287161478Sdelphijextern boolean coff_write_linenumbers PARAMS ((bfd *)); 288161478Sdelphijextern alent *coff_get_lineno PARAMS ((bfd *, asymbol *)); 289161478Sdelphijextern asymbol *coff_section_symbol PARAMS ((bfd *, char *)); 290161478Sdelphijextern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *)); 291161478Sdelphijextern const char *_bfd_coff_read_string_table PARAMS ((bfd *)); 292161478Sdelphijextern boolean _bfd_coff_free_symbols PARAMS ((bfd *)); 293161478Sdelphijextern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *)); 294161478Sdelphijextern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); 295161478Sdelphijextern asymbol *coff_make_empty_symbol PARAMS ((bfd *)); 296161478Sdelphijextern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *, 297161478Sdelphij bfd_print_symbol_type how)); 298161478Sdelphijextern void coff_get_symbol_info PARAMS ((bfd *, asymbol *, 299161478Sdelphij symbol_info *ret)); 30089019Spsextern boolean _bfd_coff_is_local_label_name PARAMS ((bfd *, const char *)); 30189019Spsextern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR, 302161478Sdelphij unsigned long)); 303161478Sdelphijextern boolean coff_find_nearest_line PARAMS ((bfd *, 304161478Sdelphij asection *, 305161478Sdelphij asymbol **, 306161478Sdelphij bfd_vma offset, 307161478Sdelphij CONST char **filename_ptr, 308161478Sdelphij CONST char **functionname_ptr, 309161478Sdelphij unsigned int *line_ptr)); 310161478Sdelphijextern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc)); 311161478Sdelphijextern boolean bfd_coff_reloc16_relax_section 312161478Sdelphij PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); 313161478Sdelphijextern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents 314161478Sdelphij PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, 315161478Sdelphij bfd_byte *, boolean relocateable, asymbol **)); 316161478Sdelphijextern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *, 317161478Sdelphij struct bfd_link_info *, 318161478Sdelphij asection *)); 319161478Sdelphijextern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip, 320161478Sdelphij asection *input_section, 321161478Sdelphij bfd_vma val)); 322161478Sdelphij 323161478Sdelphij/* Functions and types in cofflink.c. */ 324161478Sdelphij 325161478Sdelphij#define STRING_SIZE_SIZE (4) 326161478Sdelphij 327161478Sdelphij/* We use a hash table to merge identical enum, struct, and union 328161478Sdelphij definitions in the linker. */ 329161478Sdelphij 330161478Sdelphij/* Information we keep for a single element (an enum value, a 331161478Sdelphij structure or union field) in the debug merge hash table. */ 332161478Sdelphij 333161478Sdelphijstruct coff_debug_merge_element 334161478Sdelphij{ 33589019Sps /* Next element. */ 336161478Sdelphij struct coff_debug_merge_element *next; 337161478Sdelphij 338161478Sdelphij /* Name. */ 33989019Sps const char *name; 34089019Sps 34189019Sps /* Type. */ 342161478Sdelphij unsigned int type; 343161478Sdelphij 344161478Sdelphij /* Symbol index for complex type. */ 345161478Sdelphij long tagndx; 346161478Sdelphij}; 347161478Sdelphij 34860786Sps/* A linked list of debug merge entries for a given name. */ 349161478Sdelphij 35060786Spsstruct coff_debug_merge_type 351161478Sdelphij{ 352161478Sdelphij /* Next type with the same name. */ 35360786Sps struct coff_debug_merge_type *next; 354161478Sdelphij 355161478Sdelphij /* Class of type. */ 356161478Sdelphij int class; 35760786Sps 35860786Sps /* Symbol index where this type is defined. */ 35960786Sps long indx; 360161478Sdelphij 36160786Sps /* List of elements. */ 362161478Sdelphij struct coff_debug_merge_element *elements; 363161478Sdelphij}; 36460786Sps 365161478Sdelphij/* Information we store in the debug merge hash table. */ 36660786Sps 36760786Spsstruct coff_debug_merge_hash_entry 36860786Sps{ 36960786Sps struct bfd_hash_entry root; 37060786Sps 37160786Sps /* A list of types with this name. */ 37260786Sps struct coff_debug_merge_type *types; 37360786Sps}; 37460786Sps 37560786Sps/* The debug merge hash table. */ 376161478Sdelphij 377161478Sdelphijstruct coff_debug_merge_hash_table 378161478Sdelphij{ 379161478Sdelphij struct bfd_hash_table root; 380161478Sdelphij}; 381161478Sdelphij 382161478Sdelphij/* Initialize a COFF debug merge hash table. */ 383161478Sdelphij 384161478Sdelphij#define coff_debug_merge_hash_table_init(table) \ 385161478Sdelphij (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc)) 386161478Sdelphij 387161478Sdelphij/* Free a COFF debug merge hash table. */ 388161478Sdelphij 389161478Sdelphij#define coff_debug_merge_hash_table_free(table) \ 39060786Sps (bfd_hash_table_free (&(table)->root)) 39160786Sps 39260786Sps/* Look up an entry in a COFF debug merge hash table. */ 39360786Sps 39460786Sps#define coff_debug_merge_hash_lookup(table, string, create, copy) \ 39560786Sps ((struct coff_debug_merge_hash_entry *) \ 39660786Sps bfd_hash_lookup (&(table)->root, (string), (create), (copy))) 39760786Sps 39860786Sps/* Information we keep for each section in the output file when doing 39960786Sps a relocateable link. */ 400161478Sdelphij 401161478Sdelphijstruct coff_link_section_info 402161478Sdelphij{ 403161478Sdelphij /* The relocs to be output. */ 404161478Sdelphij struct internal_reloc *relocs; 405161478Sdelphij /* For each reloc against a global symbol whose index was not known 406161478Sdelphij when the reloc was handled, the global hash table entry. */ 407161478Sdelphij struct coff_link_hash_entry **rel_hashes; 408161478Sdelphij}; 409161478Sdelphij 410161478Sdelphij/* Information that we pass around while doing the final link step. */ 411161478Sdelphij 412161478Sdelphijstruct coff_final_link_info 413161478Sdelphij{ 41460786Sps /* General link information. */ 41560786Sps struct bfd_link_info *info; 41660786Sps /* Output BFD. */ 41760786Sps bfd *output_bfd; 41860786Sps /* Used to indicate failure in traversal routine. */ 41960786Sps boolean failed; 42060786Sps /* Hash table for long symbol names. */ 42160786Sps struct bfd_strtab_hash *strtab; 42260786Sps /* When doing a relocateable link, an array of information kept for 423161478Sdelphij each output section, indexed by the target_index field. */ 424161478Sdelphij struct coff_link_section_info *section_info; 42560786Sps /* Symbol index of last C_FILE symbol (-1 if none). */ 426161478Sdelphij long last_file_index; 42760786Sps /* Contents of last C_FILE symbol. */ 428161478Sdelphij struct internal_syment last_file; 42960786Sps /* Symbol index of first aux entry of last .bf symbol with an empty 430161478Sdelphij endndx field (-1 if none). */ 43160786Sps long last_bf_index; 432161478Sdelphij /* Contents of last_bf_index aux entry. */ 433161478Sdelphij union internal_auxent last_bf; 43460786Sps /* Hash table used to merge debug information. */ 435161478Sdelphij struct coff_debug_merge_hash_table debug_merge; 43660786Sps /* Buffer large enough to hold swapped symbols of any input file. */ 437161478Sdelphij struct internal_syment *internal_syms; 438161478Sdelphij /* Buffer large enough to hold sections of symbols of any input file. */ 439161478Sdelphij asection **sec_ptrs; 440161478Sdelphij /* Buffer large enough to hold output indices of symbols of any 441161478Sdelphij input file. */ 442161478Sdelphij long *sym_indices; 443161478Sdelphij /* Buffer large enough to hold output symbols for any input file. */ 444161478Sdelphij bfd_byte *outsyms; 445161478Sdelphij /* Buffer large enough to hold external line numbers for any input 446161478Sdelphij section. */ 447161478Sdelphij bfd_byte *linenos; 448161478Sdelphij /* Buffer large enough to hold any input section. */ 449161478Sdelphij bfd_byte *contents; 450161478Sdelphij /* Buffer large enough to hold external relocs of any input section. */ 451161478Sdelphij bfd_byte *external_relocs; 452161478Sdelphij /* Buffer large enough to hold swapped relocs of any input section. */ 453161478Sdelphij struct internal_reloc *internal_relocs; 454161478Sdelphij}; 455161478Sdelphij 456161478Sdelphijextern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc 457161478Sdelphij PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 458161478Sdelphijextern boolean _bfd_coff_link_hash_table_init 459161478Sdelphij PARAMS ((struct coff_link_hash_table *, bfd *, 460161478Sdelphij struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 461161478Sdelphij struct bfd_hash_table *, 462161478Sdelphij const char *))); 463161478Sdelphijextern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create 464161478Sdelphij PARAMS ((bfd *)); 465161478Sdelphijextern const char *_bfd_coff_internal_syment_name 46660786Sps PARAMS ((bfd *, const struct internal_syment *, char *)); 46760786Spsextern boolean _bfd_coff_link_add_symbols 468161478Sdelphij PARAMS ((bfd *, struct bfd_link_info *)); 46960786Spsextern boolean _bfd_coff_final_link 47060786Sps PARAMS ((bfd *, struct bfd_link_info *)); 47160786Spsextern struct internal_reloc *_bfd_coff_read_internal_relocs 472161478Sdelphij PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean, 473161478Sdelphij struct internal_reloc *)); 474161478Sdelphijextern boolean _bfd_coff_generic_relocate_section 47560786Sps PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 476161478Sdelphij struct internal_reloc *, struct internal_syment *, asection **)); 477161478Sdelphij 47860786Spsextern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc 47960786Sps PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 48060786Spsextern boolean _bfd_coff_write_global_sym 48160786Sps PARAMS ((struct coff_link_hash_entry *, PTR)); 48260786Spsextern boolean _bfd_coff_link_input_bfd 483161478Sdelphij PARAMS ((struct coff_final_link_info *, bfd *)); 484161478Sdelphijextern boolean _bfd_coff_reloc_link_order 48560786Sps PARAMS ((bfd *, struct coff_final_link_info *, asection *, 486161478Sdelphij struct bfd_link_order *)); 48760786Sps 48860786Sps 489161478Sdelphij#define coff_get_section_contents_in_window \ 490161478Sdelphij _bfd_generic_get_section_contents_in_window 491161478Sdelphij 492161478Sdelphij/* Functions in xcofflink.c. */ 493161478Sdelphij 494161478Sdelphijextern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *)); 495161478Sdelphijextern long _bfd_xcoff_canonicalize_dynamic_symtab 496161478Sdelphij PARAMS ((bfd *, asymbol **)); 497161478Sdelphijextern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *)); 498161478Sdelphijextern long _bfd_xcoff_canonicalize_dynamic_reloc 499161478Sdelphij PARAMS ((bfd *, arelent **, asymbol **)); 500161478Sdelphijextern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create 501161478Sdelphij PARAMS ((bfd *)); 502161478Sdelphijextern boolean _bfd_xcoff_bfd_link_add_symbols 503161478Sdelphij PARAMS ((bfd *, struct bfd_link_info *)); 504161478Sdelphijextern boolean _bfd_xcoff_bfd_final_link 505161478Sdelphij PARAMS ((bfd *, struct bfd_link_info *)); 506161478Sdelphijextern boolean _bfd_ppc_xcoff_relocate_section 507161478Sdelphij PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 508161478Sdelphij struct internal_reloc *, struct internal_syment *, asection **)); 50960786Sps 51060786Sps/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the 51160786Sps linker, and so should start with bfd and be declared in bfd.h. */ 51260786Sps 51360786Spsextern boolean ppc_allocate_toc_section PARAMS ((struct bfd_link_info *)); 51460786Spsextern boolean ppc_process_before_allocation 51560786Sps PARAMS ((bfd *, struct bfd_link_info *)); 51660786Sps 517161478Sdelphij/* And more taken from the source .. */ 51860786Sps 51960786Spstypedef struct coff_ptr_struct 52060786Sps{ 52160786Sps 52260786Sps /* Remembers the offset from the first symbol in the file for 523161478Sdelphij this symbol. Generated by coff_renumber_symbols. */ 52460786Spsunsigned int offset; 525161478Sdelphij 526161478Sdelphij /* Should the value of this symbol be renumbered. Used for 52760786Sps XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */ 528161478Sdelphijunsigned int fix_value : 1; 52960786Sps 53060786Sps /* Should the tag field of this symbol be renumbered. 53160786Sps Created by coff_pointerize_aux. */ 53260786Spsunsigned int fix_tag : 1; 53360786Sps 53460786Sps /* Should the endidx field of this symbol be renumbered. 53589019Sps Created by coff_pointerize_aux. */ 53689019Spsunsigned int fix_end : 1; 53789019Sps 538161478Sdelphij /* Should the x_csect.x_scnlen field be renumbered. 539161478Sdelphij Created by coff_pointerize_aux. */ 54089019Spsunsigned int fix_scnlen : 1; 541161478Sdelphij 542161478Sdelphij /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the 543161478Sdelphij index into the line number entries. Set by 54489019Sps coff_slurp_symbol_table. */ 54589019Spsunsigned int fix_line : 1; 54689019Sps 547161478Sdelphij /* The container for the symbol structure as read and translated 548161478Sdelphij from the file. */ 549161478Sdelphij 550161478Sdelphijunion { 551161478Sdelphij union internal_auxent auxent; 552161478Sdelphij struct internal_syment syment; 553161478Sdelphij } u; 554161478Sdelphij} combined_entry_type; 555161478Sdelphij 556161478Sdelphij 557161478Sdelphij /* Each canonical asymbol really looks like this: */ 558161478Sdelphij 559161478Sdelphijtypedef struct coff_symbol_struct 560161478Sdelphij{ 56160786Sps /* The actual symbol which the rest of BFD works with */ 56260786Spsasymbol symbol; 563161478Sdelphij 564161478Sdelphij /* A pointer to the hidden information for this symbol */ 565161478Sdelphijcombined_entry_type *native; 566161478Sdelphij 56789019Sps /* A pointer to the linenumber information for this symbol */ 56860786Spsstruct lineno_cache_entry *lineno; 569161478Sdelphij 570161478Sdelphij /* Have the line numbers been relocated yet ? */ 57160786Spsboolean done_lineno; 572161478Sdelphij} coff_symbol_type; 57360786Spstypedef struct 57460786Sps{ 575161478Sdelphij void (*_bfd_coff_swap_aux_in) PARAMS (( 576161478Sdelphij bfd *abfd, 577161478Sdelphij PTR ext, 57860786Sps int type, 579161478Sdelphij int class, 580161478Sdelphij int indaux, 581161478Sdelphij int numaux, 582161478Sdelphij PTR in)); 58360786Sps 58489019Sps void (*_bfd_coff_swap_sym_in) PARAMS (( 585161478Sdelphij bfd *abfd , 586161478Sdelphij PTR ext, 587161478Sdelphij PTR in)); 588161478Sdelphij 589161478Sdelphij void (*_bfd_coff_swap_lineno_in) PARAMS (( 590161478Sdelphij bfd *abfd, 591161478Sdelphij PTR ext, 592161478Sdelphij PTR in)); 593161478Sdelphij 594161478Sdelphij unsigned int (*_bfd_coff_swap_aux_out) PARAMS (( 595161478Sdelphij bfd *abfd, 59689019Sps PTR in, 59760786Sps int type, 598161478Sdelphij int class, 59960786Sps int indaux, 600161478Sdelphij int numaux, 601161478Sdelphij PTR ext)); 602161478Sdelphij 603161478Sdelphij unsigned int (*_bfd_coff_swap_sym_out) PARAMS (( 604161478Sdelphij bfd *abfd, 605161478Sdelphij PTR in, 606161478Sdelphij PTR ext)); 607161478Sdelphij 608161478Sdelphij unsigned int (*_bfd_coff_swap_lineno_out) PARAMS (( 60960786Sps bfd *abfd, 610161478Sdelphij PTR in, 611161478Sdelphij PTR ext)); 612161478Sdelphij 613161478Sdelphij unsigned int (*_bfd_coff_swap_reloc_out) PARAMS (( 614161478Sdelphij bfd *abfd, 615161478Sdelphij PTR src, 61660786Sps PTR dst)); 617161478Sdelphij 618161478Sdelphij unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS (( 619161478Sdelphij bfd *abfd, 620161478Sdelphij PTR in, 621161478Sdelphij PTR out)); 622161478Sdelphij 62360786Sps unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS (( 62460786Sps bfd *abfd, 62560786Sps PTR in, 62660786Sps PTR out)); 62760786Sps 62860786Sps unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS (( 629161478Sdelphij bfd *abfd, 63089019Sps PTR in, 631161478Sdelphij PTR out)); 632161478Sdelphij 633161478Sdelphij unsigned int _bfd_filhsz; 634161478Sdelphij unsigned int _bfd_aoutsz; 635161478Sdelphij unsigned int _bfd_scnhsz; 636161478Sdelphij unsigned int _bfd_symesz; 637161478Sdelphij unsigned int _bfd_auxesz; 638161478Sdelphij unsigned int _bfd_relsz; 639161478Sdelphij unsigned int _bfd_linesz; 64060786Sps boolean _bfd_coff_long_filenames; 64160786Sps boolean _bfd_coff_long_section_names; 64289019Sps unsigned int _bfd_coff_default_section_alignment_power; 64360786Sps void (*_bfd_coff_swap_filehdr_in) PARAMS (( 64489019Sps bfd *abfd, 64589019Sps PTR ext, 64689019Sps PTR in)); 64760786Sps void (*_bfd_coff_swap_aouthdr_in) PARAMS (( 648161478Sdelphij bfd *abfd, 64960786Sps PTR ext, 650161478Sdelphij PTR in)); 651161478Sdelphij void (*_bfd_coff_swap_scnhdr_in) PARAMS (( 652161478Sdelphij bfd *abfd, 65360786Sps PTR ext, 65460786Sps PTR in)); 65560786Sps void (*_bfd_coff_swap_reloc_in) PARAMS (( 65660786Sps bfd *abfd, 65760786Sps PTR ext, 65860786Sps PTR in)); 65989019Sps boolean (*_bfd_coff_bad_format_hook) PARAMS (( 66089019Sps bfd *abfd, 66189019Sps PTR internal_filehdr)); 66289019Sps boolean (*_bfd_coff_set_arch_mach_hook) PARAMS (( 66389019Sps bfd *abfd, 66489019Sps PTR internal_filehdr)); 66589019Sps PTR (*_bfd_coff_mkobject_hook) PARAMS (( 66689019Sps bfd *abfd, 66789019Sps PTR internal_filehdr, 66889019Sps PTR internal_aouthdr)); 66989019Sps flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( 67089019Sps bfd *abfd, 67189019Sps PTR internal_scnhdr, 67289019Sps const char *name)); 67389019Sps void (*_bfd_set_alignment_hook) PARAMS (( 67489019Sps bfd *abfd, 67589019Sps asection *sec, 67689019Sps PTR internal_scnhdr)); 67789019Sps boolean (*_bfd_coff_slurp_symbol_table) PARAMS (( 67889019Sps bfd *abfd)); 67989019Sps boolean (*_bfd_coff_symname_in_debug) PARAMS (( 68089019Sps bfd *abfd, 68189019Sps struct internal_syment *sym)); 68289019Sps boolean (*_bfd_coff_pointerize_aux_hook) PARAMS (( 68389019Sps bfd *abfd, 684161478Sdelphij combined_entry_type *table_base, 685161478Sdelphij combined_entry_type *symbol, 686161478Sdelphij unsigned int indaux, 68789019Sps combined_entry_type *aux)); 688161478Sdelphij boolean (*_bfd_coff_print_aux) PARAMS (( 68989019Sps bfd *abfd, 69089019Sps FILE *file, 69189019Sps combined_entry_type *table_base, 69289019Sps combined_entry_type *symbol, 693161478Sdelphij combined_entry_type *aux, 694161478Sdelphij unsigned int indaux)); 695161478Sdelphij void (*_bfd_coff_reloc16_extra_cases) PARAMS (( 696161478Sdelphij bfd *abfd, 697161478Sdelphij struct bfd_link_info *link_info, 698161478Sdelphij struct bfd_link_order *link_order, 699161478Sdelphij arelent *reloc, 700161478Sdelphij bfd_byte *data, 701161478Sdelphij unsigned int *src_ptr, 702161478Sdelphij unsigned int *dst_ptr)); 703161478Sdelphij int (*_bfd_coff_reloc16_estimate) PARAMS (( 704161478Sdelphij bfd *abfd, 705161478Sdelphij asection *input_section, 706161478Sdelphij arelent *r, 707161478Sdelphij unsigned int shrink, 708161478Sdelphij struct bfd_link_info *link_info)); 709161478Sdelphij boolean (*_bfd_coff_sym_is_global) PARAMS (( 710161478Sdelphij bfd *abfd, 711161478Sdelphij struct internal_syment *)); 712161478Sdelphij boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( 713161478Sdelphij bfd *abfd)); 714161478Sdelphij boolean (*_bfd_coff_start_final_link) PARAMS (( 715161478Sdelphij bfd *output_bfd, 716161478Sdelphij struct bfd_link_info *info)); 717161478Sdelphij boolean (*_bfd_coff_relocate_section) PARAMS (( 718161478Sdelphij bfd *output_bfd, 719161478Sdelphij struct bfd_link_info *info, 720161478Sdelphij bfd *input_bfd, 721161478Sdelphij asection *input_section, 722161478Sdelphij bfd_byte *contents, 723161478Sdelphij struct internal_reloc *relocs, 724161478Sdelphij struct internal_syment *syms, 725161478Sdelphij asection **sections)); 726161478Sdelphij reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS (( 727161478Sdelphij bfd *abfd, 728161478Sdelphij asection *sec, 729161478Sdelphij struct internal_reloc *rel, 730161478Sdelphij struct coff_link_hash_entry *h, 731161478Sdelphij struct internal_syment *sym, 732161478Sdelphij bfd_vma *addendp)); 733161478Sdelphij boolean (*_bfd_coff_adjust_symndx) PARAMS (( 734161478Sdelphij bfd *obfd, 73589019Sps struct bfd_link_info *info, 73660786Sps bfd *ibfd, 73760786Sps asection *sec, 73860786Sps struct internal_reloc *reloc, 73960786Sps boolean *adjustedp)); 74060786Sps boolean (*_bfd_coff_link_add_one_symbol) PARAMS (( 74160786Sps struct bfd_link_info *info, 742161478Sdelphij bfd *abfd, 74360786Sps const char *name, 74460786Sps flagword flags, 74560786Sps asection *section, 74660786Sps bfd_vma value, 74760786Sps const char *string, 74860786Sps boolean copy, 749161478Sdelphij boolean collect, 75060786Sps struct bfd_link_hash_entry **hashp)); 75160786Sps 75260786Sps} bfd_coff_backend_data; 75360786Sps 75460786Sps#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data) 75560786Sps 75660786Sps#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ 75760786Sps ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) 75860786Sps 75960786Sps#define bfd_coff_swap_sym_in(a,e,i) \ 760161478Sdelphij ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) 761161478Sdelphij 762161478Sdelphij#define bfd_coff_swap_lineno_in(a,e,i) \ 763161478Sdelphij ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) 764161478Sdelphij 765161478Sdelphij#define bfd_coff_swap_reloc_out(abfd, i, o) \ 766161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) 767161478Sdelphij 768161478Sdelphij#define bfd_coff_swap_lineno_out(abfd, i, o) \ 769161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) 77060786Sps 77160786Sps#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ 77260786Sps ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) 77360786Sps 77460786Sps#define bfd_coff_swap_sym_out(abfd, i,o) \ 77560786Sps ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) 77660786Sps 77760786Sps#define bfd_coff_swap_scnhdr_out(abfd, i,o) \ 77860786Sps ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) 77960786Sps 780161478Sdelphij#define bfd_coff_swap_filehdr_out(abfd, i,o) \ 781161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) 782161478Sdelphij 783161478Sdelphij#define bfd_coff_swap_aouthdr_out(abfd, i,o) \ 784161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) 785161478Sdelphij 786161478Sdelphij#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) 787161478Sdelphij#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) 788161478Sdelphij#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) 789161478Sdelphij#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) 790161478Sdelphij#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) 791161478Sdelphij#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) 792161478Sdelphij#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) 793161478Sdelphij#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames) 794161478Sdelphij#define bfd_coff_long_section_names(abfd) \ 795161478Sdelphij (coff_backend_info (abfd)->_bfd_coff_long_section_names) 796161478Sdelphij#define bfd_coff_default_section_alignment_power(abfd) \ 797161478Sdelphij (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) 798161478Sdelphij#define bfd_coff_swap_filehdr_in(abfd, i,o) \ 799161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) 800161478Sdelphij 801161478Sdelphij#define bfd_coff_swap_aouthdr_in(abfd, i,o) \ 802161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) 803161478Sdelphij 804161478Sdelphij#define bfd_coff_swap_scnhdr_in(abfd, i,o) \ 805161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) 806161478Sdelphij 807161478Sdelphij#define bfd_coff_swap_reloc_in(abfd, i, o) \ 808161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) 809161478Sdelphij 810161478Sdelphij#define bfd_coff_bad_format_hook(abfd, filehdr) \ 811161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) 812161478Sdelphij 813161478Sdelphij#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ 814161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) 815161478Sdelphij#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ 816161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) 817161478Sdelphij 818161478Sdelphij#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\ 819161478Sdelphij ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name)) 820161478Sdelphij 821161478Sdelphij#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ 822161478Sdelphij ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) 823161478Sdelphij 82460786Sps#define bfd_coff_slurp_symbol_table(abfd)\ 82560786Sps ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) 82660786Sps 82760786Sps#define bfd_coff_symname_in_debug(abfd, sym)\ 82860786Sps ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) 82960786Sps 83060786Sps#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ 83189019Sps ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ 83289019Sps (abfd, file, base, symbol, aux, indaux)) 83360786Sps 83489019Sps#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\ 835161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ 836161478Sdelphij (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) 837161478Sdelphij 838161478Sdelphij#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ 839161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ 84060786Sps (abfd, section, reloc, shrink, link_info)) 84160786Sps 84260786Sps#define bfd_coff_sym_is_global(abfd, sym)\ 84360786Sps ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\ 844161478Sdelphij (abfd, sym)) 845161478Sdelphij 846161478Sdelphij#define bfd_coff_compute_section_file_positions(abfd)\ 84760786Sps ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ 84860786Sps (abfd)) 84960786Sps 850161478Sdelphij#define bfd_coff_start_final_link(obfd, info)\ 85160786Sps ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ 852161478Sdelphij (obfd, info)) 85360786Sps#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ 854161478Sdelphij ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ 85560786Sps (obfd, info, ibfd, o, con, rel, isyms, secs)) 856161478Sdelphij#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ 85760786Sps ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ 858161478Sdelphij (abfd, sec, rel, h, sym, addendp)) 859161478Sdelphij#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ 860161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ 861161478Sdelphij (obfd, info, ibfd, sec, rel, adjustedp)) 862161478Sdelphij#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\ 863161478Sdelphij ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ 864161478Sdelphij (info, abfd, name, flags, section, value, string, cp, coll, hashp)) 865161478Sdelphij 866161478Sdelphij