1259698Sdim/* BFD COFF object file private structure. 2259698Sdim Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3259698Sdim 2000, 2001, 2002, 2003, 2004, 2005, 2006 4259698Sdim Free Software Foundation, Inc. 5259698Sdim Written by Cygnus Support. 6259698Sdim 7259698Sdim This file is part of BFD, the Binary File Descriptor library. 8259698Sdim 9259698Sdim This program is free software; you can redistribute it and/or modify 10259698Sdim it under the terms of the GNU General Public License as published by 11259698Sdim the Free Software Foundation; either version 2 of the License, or 12259698Sdim (at your option) any later version. 13259698Sdim 14259698Sdim This program is distributed in the hope that it will be useful, 15259698Sdim but WITHOUT ANY WARRANTY; without even the implied warranty of 16259698Sdim MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17259698Sdim GNU General Public License for more details. 18259698Sdim 19259698Sdim You should have received a copy of the GNU General Public License 20259698Sdim along with this program; if not, write to the Free Software 21259698Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 22259698Sdim 23259698Sdim#include "bfdlink.h" 24259698Sdim 25259698Sdim/* Object file tdata; access macros. */ 26259698Sdim 27259698Sdim#define coff_data(bfd) ((bfd)->tdata.coff_obj_data) 28259698Sdim#define exec_hdr(bfd) (coff_data (bfd)->hdr) 29259698Sdim#define obj_pe(bfd) (coff_data (bfd)->pe) 30259698Sdim#define obj_symbols(bfd) (coff_data (bfd)->symbols) 31259698Sdim#define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos) 32259698Sdim#define obj_relocbase(bfd) (coff_data (bfd)->relocbase) 33259698Sdim#define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments) 34259698Sdim#define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count) 35259698Sdim#define obj_convert(bfd) (coff_data (bfd)->conversion_table) 36259698Sdim#define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size) 37259698Sdim#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) 38259698Sdim#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) 39259698Sdim#define obj_coff_strings(bfd) (coff_data (bfd)->strings) 40259698Sdim#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) 41259698Sdim#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) 42259698Sdim#define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) 43259698Sdim#define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map) 44259698Sdim 45259698Sdim/* `Tdata' information kept for COFF files. */ 46259698Sdim 47259698Sdimtypedef struct coff_tdata 48259698Sdim{ 49259698Sdim struct coff_symbol_struct *symbols; /* Symtab for input bfd. */ 50259698Sdim unsigned int *conversion_table; 51259698Sdim int conv_table_size; 52259698Sdim file_ptr sym_filepos; 53259698Sdim 54259698Sdim struct coff_ptr_struct *raw_syments; 55259698Sdim unsigned long raw_syment_count; 56259698Sdim 57259698Sdim /* These are only valid once writing has begun. */ 58259698Sdim long int relocbase; 59259698Sdim 60259698Sdim /* These members communicate important constants about the symbol table 61259698Sdim to GDB's symbol-reading code. These `constants' unfortunately vary 62259698Sdim from coff implementation to implementation... */ 63259698Sdim unsigned local_n_btmask; 64259698Sdim unsigned local_n_btshft; 65259698Sdim unsigned local_n_tmask; 66259698Sdim unsigned local_n_tshift; 67259698Sdim unsigned local_symesz; 68259698Sdim unsigned local_auxesz; 69259698Sdim unsigned local_linesz; 70259698Sdim 71259698Sdim /* The unswapped external symbols. May be NULL. Read by 72259698Sdim _bfd_coff_get_external_symbols. */ 73259698Sdim void * external_syms; 74259698Sdim /* If this is TRUE, the external_syms may not be freed. */ 75259698Sdim bfd_boolean keep_syms; 76259698Sdim 77259698Sdim /* The string table. May be NULL. Read by 78259698Sdim _bfd_coff_read_string_table. */ 79259698Sdim char *strings; 80259698Sdim /* If this is TRUE, the strings may not be freed. */ 81259698Sdim bfd_boolean keep_strings; 82259698Sdim /* If this is TRUE, the strings have been written out already. */ 83259698Sdim bfd_boolean strings_written; 84259698Sdim 85259698Sdim /* Is this a PE format coff file? */ 86259698Sdim int pe; 87259698Sdim /* Used by the COFF backend linker. */ 88259698Sdim struct coff_link_hash_entry **sym_hashes; 89259698Sdim 90259698Sdim /* Used by the pe linker for PowerPC. */ 91259698Sdim int *local_toc_sym_map; 92259698Sdim 93259698Sdim struct bfd_link_info *link_info; 94259698Sdim 95259698Sdim /* Used by coff_find_nearest_line. */ 96259698Sdim void * line_info; 97259698Sdim 98259698Sdim /* A place to stash dwarf2 info for this bfd. */ 99259698Sdim void * dwarf2_find_line_info; 100259698Sdim 101259698Sdim /* The timestamp from the COFF file header. */ 102259698Sdim long timestamp; 103259698Sdim 104259698Sdim /* Copy of some of the f_flags bits in the COFF filehdr structure, 105259698Sdim used by ARM code. */ 106259698Sdim flagword flags; 107259698Sdim 108259698Sdim} coff_data_type; 109259698Sdim 110259698Sdim/* Tdata for pe image files. */ 111259698Sdimtypedef struct pe_tdata 112259698Sdim{ 113259698Sdim coff_data_type coff; 114259698Sdim struct internal_extra_pe_aouthdr pe_opthdr; 115259698Sdim int dll; 116259698Sdim int has_reloc_section; 117259698Sdim bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *); 118259698Sdim flagword real_flags; 119259698Sdim int target_subsystem; 120259698Sdim bfd_boolean force_minimum_alignment; 121259698Sdim} pe_data_type; 122259698Sdim 123259698Sdim#define pe_data(bfd) ((bfd)->tdata.pe_obj_data) 124259698Sdim 125259698Sdim/* Tdata for XCOFF files. */ 126259698Sdim 127259698Sdimstruct xcoff_tdata 128259698Sdim{ 129259698Sdim /* Basic COFF information. */ 130259698Sdim coff_data_type coff; 131259698Sdim 132259698Sdim /* TRUE if this is an XCOFF64 file. */ 133259698Sdim bfd_boolean xcoff64; 134259698Sdim 135259698Sdim /* TRUE if a large a.out header should be generated. */ 136259698Sdim bfd_boolean full_aouthdr; 137259698Sdim 138259698Sdim /* TOC value. */ 139259698Sdim bfd_vma toc; 140259698Sdim 141259698Sdim /* Index of section holding TOC. */ 142259698Sdim int sntoc; 143259698Sdim 144259698Sdim /* Index of section holding entry point. */ 145259698Sdim int snentry; 146259698Sdim 147259698Sdim /* .text alignment from optional header. */ 148259698Sdim int text_align_power; 149259698Sdim 150259698Sdim /* .data alignment from optional header. */ 151259698Sdim int data_align_power; 152259698Sdim 153259698Sdim /* modtype from optional header. */ 154259698Sdim short modtype; 155259698Sdim 156259698Sdim /* cputype from optional header. */ 157259698Sdim short cputype; 158259698Sdim 159259698Sdim /* maxdata from optional header. */ 160259698Sdim bfd_vma maxdata; 161259698Sdim 162259698Sdim /* maxstack from optional header. */ 163259698Sdim bfd_vma maxstack; 164259698Sdim 165259698Sdim /* Used by the XCOFF backend linker. */ 166259698Sdim asection **csects; 167259698Sdim unsigned long *debug_indices; 168259698Sdim unsigned int import_file_id; 169259698Sdim}; 170259698Sdim 171259698Sdim#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data) 172259698Sdim 173259698Sdim/* We take the address of the first element of an asymbol to ensure that the 174259698Sdim macro is only ever applied to an asymbol. */ 175259698Sdim#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) 176259698Sdim 177259698Sdim/* The used_by_bfd field of a section may be set to a pointer to this 178259698Sdim structure. */ 179259698Sdim 180259698Sdimstruct coff_section_tdata 181259698Sdim{ 182259698Sdim /* The relocs, swapped into COFF internal form. This may be NULL. */ 183259698Sdim struct internal_reloc *relocs; 184259698Sdim /* If this is TRUE, the relocs entry may not be freed. */ 185259698Sdim bfd_boolean keep_relocs; 186259698Sdim /* The section contents. This may be NULL. */ 187259698Sdim bfd_byte *contents; 188259698Sdim /* If this is TRUE, the contents entry may not be freed. */ 189259698Sdim bfd_boolean keep_contents; 190259698Sdim /* Information cached by coff_find_nearest_line. */ 191259698Sdim bfd_vma offset; 192259698Sdim unsigned int i; 193259698Sdim const char *function; 194259698Sdim /* Optional information about a COMDAT entry; NULL if not COMDAT. */ 195259698Sdim struct coff_comdat_info *comdat; 196259698Sdim int line_base; 197259698Sdim /* A pointer used for .stab linking optimizations. */ 198259698Sdim void * stab_info; 199259698Sdim /* Available for individual backends. */ 200259698Sdim void * tdata; 201259698Sdim}; 202259698Sdim 203259698Sdim/* An accessor macro for the coff_section_tdata structure. */ 204259698Sdim#define coff_section_data(abfd, sec) \ 205259698Sdim ((struct coff_section_tdata *) (sec)->used_by_bfd) 206259698Sdim 207259698Sdim/* Tdata for sections in XCOFF files. This is used by the linker. */ 208259698Sdim 209259698Sdimstruct xcoff_section_tdata 210259698Sdim{ 211259698Sdim /* Used for XCOFF csects created by the linker; points to the real 212259698Sdim XCOFF section which contains this csect. */ 213259698Sdim asection *enclosing; 214259698Sdim /* The lineno_count field for the enclosing section, because we are 215259698Sdim going to clobber it there. */ 216259698Sdim unsigned int lineno_count; 217259698Sdim /* The first and one past the last symbol indices for symbols used 218259698Sdim by this csect. */ 219259698Sdim unsigned long first_symndx; 220259698Sdim unsigned long last_symndx; 221259698Sdim}; 222259698Sdim 223259698Sdim/* An accessor macro the xcoff_section_tdata structure. */ 224259698Sdim#define xcoff_section_data(abfd, sec) \ 225259698Sdim ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 226259698Sdim 227259698Sdim/* Tdata for sections in PE files. */ 228259698Sdim 229259698Sdimstruct pei_section_tdata 230259698Sdim{ 231259698Sdim /* The virtual size of the section. */ 232259698Sdim bfd_size_type virt_size; 233259698Sdim /* The PE section flags. */ 234259698Sdim long pe_flags; 235259698Sdim}; 236259698Sdim 237259698Sdim/* An accessor macro for the pei_section_tdata structure. */ 238259698Sdim#define pei_section_data(abfd, sec) \ 239259698Sdim ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 240259698Sdim 241259698Sdim/* COFF linker hash table entries. */ 242259698Sdim 243259698Sdimstruct coff_link_hash_entry 244259698Sdim{ 245259698Sdim struct bfd_link_hash_entry root; 246259698Sdim 247259698Sdim /* Symbol index in output file. Set to -1 initially. Set to -2 if 248259698Sdim there is a reloc against this symbol. */ 249259698Sdim long indx; 250259698Sdim 251259698Sdim /* Symbol type. */ 252259698Sdim unsigned short type; 253259698Sdim 254259698Sdim /* Symbol class. */ 255259698Sdim unsigned char class; 256259698Sdim 257259698Sdim /* Number of auxiliary entries. */ 258259698Sdim char numaux; 259259698Sdim 260259698Sdim /* BFD to take auxiliary entries from. */ 261259698Sdim bfd *auxbfd; 262259698Sdim 263259698Sdim /* Pointer to array of auxiliary entries, if any. */ 264259698Sdim union internal_auxent *aux; 265259698Sdim 266259698Sdim /* Flag word; legal values follow. */ 267259698Sdim unsigned short coff_link_hash_flags; 268259698Sdim /* Symbol is a PE section symbol. */ 269259698Sdim#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01) 270259698Sdim}; 271259698Sdim 272259698Sdim/* COFF linker hash table. */ 273259698Sdim 274259698Sdimstruct coff_link_hash_table 275259698Sdim{ 276259698Sdim struct bfd_link_hash_table root; 277259698Sdim /* A pointer to information used to link stabs in sections. */ 278259698Sdim struct stab_info stab_info; 279259698Sdim}; 280259698Sdim 281259698Sdim/* Look up an entry in a COFF linker hash table. */ 282259698Sdim 283259698Sdim#define coff_link_hash_lookup(table, string, create, copy, follow) \ 284259698Sdim ((struct coff_link_hash_entry *) \ 285259698Sdim bfd_link_hash_lookup (&(table)->root, (string), (create), \ 286259698Sdim (copy), (follow))) 287259698Sdim 288259698Sdim/* Traverse a COFF linker hash table. */ 289259698Sdim 290259698Sdim#define coff_link_hash_traverse(table, func, info) \ 291259698Sdim (bfd_link_hash_traverse \ 292259698Sdim (&(table)->root, \ 293259698Sdim (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \ 294259698Sdim (info))) 295259698Sdim 296259698Sdim/* Get the COFF linker hash table from a link_info structure. */ 297259698Sdim 298259698Sdim#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) 299259698Sdim 300259698Sdim/* Functions in coffgen.c. */ 301259698Sdimextern const bfd_target *coff_object_p 302259698Sdim (bfd *); 303259698Sdimextern struct bfd_section *coff_section_from_bfd_index 304259698Sdim (bfd *, int); 305259698Sdimextern long coff_get_symtab_upper_bound 306259698Sdim (bfd *); 307259698Sdimextern long coff_canonicalize_symtab 308259698Sdim (bfd *, asymbol **); 309259698Sdimextern int coff_count_linenumbers 310259698Sdim (bfd *); 311259698Sdimextern struct coff_symbol_struct *coff_symbol_from 312259698Sdim (bfd *, asymbol *); 313259698Sdimextern bfd_boolean coff_renumber_symbols 314259698Sdim (bfd *, int *); 315259698Sdimextern void coff_mangle_symbols 316259698Sdim (bfd *); 317259698Sdimextern bfd_boolean coff_write_symbols 318259698Sdim (bfd *); 319259698Sdimextern bfd_boolean coff_write_linenumbers 320259698Sdim (bfd *); 321259698Sdimextern alent *coff_get_lineno 322259698Sdim (bfd *, asymbol *); 323259698Sdimextern asymbol *coff_section_symbol 324259698Sdim (bfd *, char *); 325259698Sdimextern bfd_boolean _bfd_coff_get_external_symbols 326259698Sdim (bfd *); 327259698Sdimextern const char *_bfd_coff_read_string_table 328259698Sdim (bfd *); 329259698Sdimextern bfd_boolean _bfd_coff_free_symbols 330259698Sdim (bfd *); 331259698Sdimextern struct coff_ptr_struct *coff_get_normalized_symtab 332259698Sdim (bfd *); 333259698Sdimextern long coff_get_reloc_upper_bound 334259698Sdim (bfd *, sec_ptr); 335259698Sdimextern asymbol *coff_make_empty_symbol 336259698Sdim (bfd *); 337259698Sdimextern void coff_print_symbol 338259698Sdim (bfd *, void * filep, asymbol *, bfd_print_symbol_type); 339259698Sdimextern void coff_get_symbol_info 340259698Sdim (bfd *, asymbol *, symbol_info *ret); 341259698Sdimextern bfd_boolean _bfd_coff_is_local_label_name 342259698Sdim (bfd *, const char *); 343259698Sdimextern asymbol *coff_bfd_make_debug_symbol 344259698Sdim (bfd *, void *, unsigned long); 345259698Sdimextern bfd_boolean coff_find_nearest_line 346259698Sdim (bfd *, asection *, asymbol **, bfd_vma, const char **, 347259698Sdim const char **, unsigned int *); 348259698Sdimextern bfd_boolean coff_find_inliner_info 349259698Sdim (bfd *, const char **, const char **, unsigned int *); 350259698Sdimextern int coff_sizeof_headers 351259698Sdim (bfd *, struct bfd_link_info *); 352259698Sdimextern bfd_boolean bfd_coff_reloc16_relax_section 353259698Sdim (bfd *, asection *, struct bfd_link_info *, bfd_boolean *); 354259698Sdimextern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents 355259698Sdim (bfd *, struct bfd_link_info *, struct bfd_link_order *, 356259698Sdim bfd_byte *, bfd_boolean, asymbol **); 357259698Sdimextern bfd_vma bfd_coff_reloc16_get_value 358259698Sdim (arelent *, struct bfd_link_info *, asection *); 359259698Sdimextern void bfd_perform_slip 360259698Sdim (bfd *, unsigned int, asection *, bfd_vma); 361259698Sdim 362259698Sdim/* Functions and types in cofflink.c. */ 363259698Sdim 364259698Sdim#define STRING_SIZE_SIZE 4 365259698Sdim 366259698Sdim/* We use a hash table to merge identical enum, struct, and union 367259698Sdim definitions in the linker. */ 368259698Sdim 369259698Sdim/* Information we keep for a single element (an enum value, a 370259698Sdim structure or union field) in the debug merge hash table. */ 371259698Sdim 372259698Sdimstruct coff_debug_merge_element 373259698Sdim{ 374259698Sdim /* Next element. */ 375259698Sdim struct coff_debug_merge_element *next; 376259698Sdim 377259698Sdim /* Name. */ 378259698Sdim const char *name; 379259698Sdim 380259698Sdim /* Type. */ 381259698Sdim unsigned int type; 382259698Sdim 383259698Sdim /* Symbol index for complex type. */ 384259698Sdim long tagndx; 385259698Sdim}; 386259698Sdim 387259698Sdim/* A linked list of debug merge entries for a given name. */ 388259698Sdim 389259698Sdimstruct coff_debug_merge_type 390259698Sdim{ 391259698Sdim /* Next type with the same name. */ 392259698Sdim struct coff_debug_merge_type *next; 393259698Sdim 394259698Sdim /* Class of type. */ 395259698Sdim int class; 396259698Sdim 397259698Sdim /* Symbol index where this type is defined. */ 398259698Sdim long indx; 399259698Sdim 400259698Sdim /* List of elements. */ 401259698Sdim struct coff_debug_merge_element *elements; 402259698Sdim}; 403259698Sdim 404259698Sdim/* Information we store in the debug merge hash table. */ 405259698Sdim 406259698Sdimstruct coff_debug_merge_hash_entry 407259698Sdim{ 408259698Sdim struct bfd_hash_entry root; 409259698Sdim 410259698Sdim /* A list of types with this name. */ 411259698Sdim struct coff_debug_merge_type *types; 412259698Sdim}; 413259698Sdim 414259698Sdim/* The debug merge hash table. */ 415259698Sdim 416259698Sdimstruct coff_debug_merge_hash_table 417259698Sdim{ 418259698Sdim struct bfd_hash_table root; 419259698Sdim}; 420259698Sdim 421259698Sdim/* Initialize a COFF debug merge hash table. */ 422259698Sdim 423259698Sdim#define coff_debug_merge_hash_table_init(table) \ 424259698Sdim (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \ 425259698Sdim sizeof (struct coff_debug_merge_hash_entry))) 426259698Sdim 427259698Sdim/* Free a COFF debug merge hash table. */ 428259698Sdim 429259698Sdim#define coff_debug_merge_hash_table_free(table) \ 430259698Sdim (bfd_hash_table_free (&(table)->root)) 431259698Sdim 432259698Sdim/* Look up an entry in a COFF debug merge hash table. */ 433259698Sdim 434259698Sdim#define coff_debug_merge_hash_lookup(table, string, create, copy) \ 435259698Sdim ((struct coff_debug_merge_hash_entry *) \ 436259698Sdim bfd_hash_lookup (&(table)->root, (string), (create), (copy))) 437259698Sdim 438259698Sdim/* Information we keep for each section in the output file when doing 439259698Sdim a relocatable link. */ 440259698Sdim 441259698Sdimstruct coff_link_section_info 442259698Sdim{ 443259698Sdim /* The relocs to be output. */ 444259698Sdim struct internal_reloc *relocs; 445259698Sdim /* For each reloc against a global symbol whose index was not known 446259698Sdim when the reloc was handled, the global hash table entry. */ 447259698Sdim struct coff_link_hash_entry **rel_hashes; 448259698Sdim}; 449259698Sdim 450259698Sdim/* Information that we pass around while doing the final link step. */ 451259698Sdim 452259698Sdimstruct coff_final_link_info 453259698Sdim{ 454259698Sdim /* General link information. */ 455259698Sdim struct bfd_link_info *info; 456259698Sdim /* Output BFD. */ 457259698Sdim bfd *output_bfd; 458259698Sdim /* Used to indicate failure in traversal routine. */ 459259698Sdim bfd_boolean failed; 460259698Sdim /* If doing "task linking" set only during the time when we want the 461259698Sdim global symbol writer to convert the storage class of defined global 462259698Sdim symbols from global to static. */ 463259698Sdim bfd_boolean global_to_static; 464259698Sdim /* Hash table for long symbol names. */ 465259698Sdim struct bfd_strtab_hash *strtab; 466259698Sdim /* When doing a relocatable link, an array of information kept for 467259698Sdim each output section, indexed by the target_index field. */ 468259698Sdim struct coff_link_section_info *section_info; 469259698Sdim /* Symbol index of last C_FILE symbol (-1 if none). */ 470259698Sdim long last_file_index; 471259698Sdim /* Contents of last C_FILE symbol. */ 472259698Sdim struct internal_syment last_file; 473259698Sdim /* Symbol index of first aux entry of last .bf symbol with an empty 474259698Sdim endndx field (-1 if none). */ 475259698Sdim long last_bf_index; 476259698Sdim /* Contents of last_bf_index aux entry. */ 477259698Sdim union internal_auxent last_bf; 478259698Sdim /* Hash table used to merge debug information. */ 479259698Sdim struct coff_debug_merge_hash_table debug_merge; 480259698Sdim /* Buffer large enough to hold swapped symbols of any input file. */ 481259698Sdim struct internal_syment *internal_syms; 482259698Sdim /* Buffer large enough to hold sections of symbols of any input file. */ 483259698Sdim asection **sec_ptrs; 484259698Sdim /* Buffer large enough to hold output indices of symbols of any 485259698Sdim input file. */ 486259698Sdim long *sym_indices; 487259698Sdim /* Buffer large enough to hold output symbols for any input file. */ 488259698Sdim bfd_byte *outsyms; 489259698Sdim /* Buffer large enough to hold external line numbers for any input 490259698Sdim section. */ 491259698Sdim bfd_byte *linenos; 492259698Sdim /* Buffer large enough to hold any input section. */ 493259698Sdim bfd_byte *contents; 494259698Sdim /* Buffer large enough to hold external relocs of any input section. */ 495259698Sdim bfd_byte *external_relocs; 496259698Sdim /* Buffer large enough to hold swapped relocs of any input section. */ 497259698Sdim struct internal_reloc *internal_relocs; 498259698Sdim}; 499259698Sdim 500259698Sdim/* Most COFF variants have no way to record the alignment of a 501259698Sdim section. This struct is used to set a specific alignment based on 502259698Sdim the name of the section. */ 503259698Sdim 504259698Sdimstruct coff_section_alignment_entry 505259698Sdim{ 506259698Sdim /* The section name. */ 507259698Sdim const char *name; 508 509 /* This is either (unsigned int) -1, indicating that the section 510 name must match exactly, or it is the number of letters which 511 must match at the start of the name. */ 512 unsigned int comparison_length; 513 514 /* These macros may be used to fill in the first two fields in a 515 structure initialization. */ 516#define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1) 517#define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1) 518 519 /* Only use this entry if the default section alignment for this 520 target is at least that much (as a power of two). If this field 521 is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 522 unsigned int default_alignment_min; 523 524 /* Only use this entry if the default section alignment for this 525 target is no greater than this (as a power of two). If this 526 field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 527 unsigned int default_alignment_max; 528 529#define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1) 530 531 /* The desired alignment for this section (as a power of two). */ 532 unsigned int alignment_power; 533}; 534 535extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc 536 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 537extern bfd_boolean _bfd_coff_link_hash_table_init 538 (struct coff_link_hash_table *, bfd *, 539 struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 540 struct bfd_hash_table *, 541 const char *), 542 unsigned int); 543extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create 544 (bfd *); 545extern const char *_bfd_coff_internal_syment_name 546 (bfd *, const struct internal_syment *, char *); 547extern bfd_boolean _bfd_coff_link_add_symbols 548 (bfd *, struct bfd_link_info *); 549extern bfd_boolean _bfd_coff_final_link 550 (bfd *, struct bfd_link_info *); 551extern struct internal_reloc *_bfd_coff_read_internal_relocs 552 (bfd *, asection *, bfd_boolean, bfd_byte *, bfd_boolean, 553 struct internal_reloc *); 554extern bfd_boolean _bfd_coff_generic_relocate_section 555 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 556 struct internal_reloc *, struct internal_syment *, asection **); 557extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc 558 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 559extern bfd_boolean _bfd_coff_write_global_sym 560 (struct coff_link_hash_entry *, void *); 561extern bfd_boolean _bfd_coff_write_task_globals 562 (struct coff_link_hash_entry *, void *); 563extern bfd_boolean _bfd_coff_link_input_bfd 564 (struct coff_final_link_info *, bfd *); 565extern bfd_boolean _bfd_coff_reloc_link_order 566 (bfd *, struct coff_final_link_info *, asection *, 567 struct bfd_link_order *); 568 569 570#define coff_get_section_contents_in_window \ 571 _bfd_generic_get_section_contents_in_window 572 573/* Functions in xcofflink.c. */ 574 575extern long _bfd_xcoff_get_dynamic_symtab_upper_bound 576 (bfd *); 577extern long _bfd_xcoff_canonicalize_dynamic_symtab 578 (bfd *, asymbol **); 579extern long _bfd_xcoff_get_dynamic_reloc_upper_bound 580 (bfd *); 581extern long _bfd_xcoff_canonicalize_dynamic_reloc 582 (bfd *, arelent **, asymbol **); 583extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create 584 (bfd *); 585extern void _bfd_xcoff_bfd_link_hash_table_free 586 (struct bfd_link_hash_table *); 587extern bfd_boolean _bfd_xcoff_bfd_link_add_symbols 588 (bfd *, struct bfd_link_info *); 589extern bfd_boolean _bfd_xcoff_bfd_final_link 590 (bfd *, struct bfd_link_info *); 591extern bfd_boolean _bfd_ppc_xcoff_relocate_section 592 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 593 struct internal_reloc *, struct internal_syment *, asection **); 594 595/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the 596 linker, and so should start with bfd and be declared in bfd.h. */ 597 598extern bfd_boolean ppc_allocate_toc_section 599 (struct bfd_link_info *); 600extern bfd_boolean ppc_process_before_allocation 601 (bfd *, struct bfd_link_info *); 602 603