133965Sjdp/* BFD COFF object file private structure. 278828Sobrien Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3218822Sdim 2000, 2001, 2002, 2003, 2004, 2005, 2006 433965Sjdp Free Software Foundation, Inc. 533965Sjdp Written by Cygnus Support. 633965Sjdp 7218822Sdim This file is part of BFD, the Binary File Descriptor library. 833965Sjdp 9218822Sdim This program is free software; you can redistribute it and/or modify 10218822Sdim it under the terms of the GNU General Public License as published by 11218822Sdim the Free Software Foundation; either version 2 of the License, or 12218822Sdim (at your option) any later version. 1333965Sjdp 14218822Sdim This program is distributed in the hope that it will be useful, 15218822Sdim but WITHOUT ANY WARRANTY; without even the implied warranty of 16218822Sdim MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17218822Sdim GNU General Public License for more details. 1833965Sjdp 19218822Sdim You should have received a copy of the GNU General Public License 20218822Sdim along with this program; if not, write to the Free Software 21218822Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 2233965Sjdp 2333965Sjdp#include "bfdlink.h" 2433965Sjdp 25218822Sdim/* Object file tdata; access macros. */ 2633965Sjdp 27218822Sdim#define coff_data(bfd) ((bfd)->tdata.coff_obj_data) 28218822Sdim#define exec_hdr(bfd) (coff_data (bfd)->hdr) 29218822Sdim#define obj_pe(bfd) (coff_data (bfd)->pe) 30218822Sdim#define obj_symbols(bfd) (coff_data (bfd)->symbols) 31218822Sdim#define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos) 32218822Sdim#define obj_relocbase(bfd) (coff_data (bfd)->relocbase) 33218822Sdim#define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments) 34218822Sdim#define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count) 35218822Sdim#define obj_convert(bfd) (coff_data (bfd)->conversion_table) 36218822Sdim#define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size) 37218822Sdim#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) 38218822Sdim#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) 39218822Sdim#define obj_coff_strings(bfd) (coff_data (bfd)->strings) 40218822Sdim#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) 41218822Sdim#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) 4277298Sobrien#define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) 43218822Sdim#define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map) 4433965Sjdp 4533965Sjdp/* `Tdata' information kept for COFF files. */ 4633965Sjdp 4733965Sjdptypedef struct coff_tdata 4833965Sjdp{ 49218822Sdim struct coff_symbol_struct *symbols; /* Symtab for input bfd. */ 5033965Sjdp unsigned int *conversion_table; 5133965Sjdp int conv_table_size; 5233965Sjdp file_ptr sym_filepos; 5333965Sjdp 5433965Sjdp struct coff_ptr_struct *raw_syments; 5560484Sobrien unsigned long raw_syment_count; 5633965Sjdp 57218822Sdim /* These are only valid once writing has begun. */ 5833965Sjdp long int relocbase; 5933965Sjdp 6033965Sjdp /* These members communicate important constants about the symbol table 6133965Sjdp to GDB's symbol-reading code. These `constants' unfortunately vary 6233965Sjdp from coff implementation to implementation... */ 6333965Sjdp unsigned local_n_btmask; 6433965Sjdp unsigned local_n_btshft; 6533965Sjdp unsigned local_n_tmask; 6633965Sjdp unsigned local_n_tshift; 6733965Sjdp unsigned local_symesz; 6833965Sjdp unsigned local_auxesz; 6933965Sjdp unsigned local_linesz; 7033965Sjdp 7133965Sjdp /* The unswapped external symbols. May be NULL. Read by 7233965Sjdp _bfd_coff_get_external_symbols. */ 73218822Sdim void * external_syms; 74130561Sobrien /* If this is TRUE, the external_syms may not be freed. */ 75130561Sobrien bfd_boolean keep_syms; 7633965Sjdp 7733965Sjdp /* The string table. May be NULL. Read by 7833965Sjdp _bfd_coff_read_string_table. */ 7933965Sjdp char *strings; 80130561Sobrien /* If this is TRUE, the strings may not be freed. */ 81130561Sobrien bfd_boolean keep_strings; 82130561Sobrien /* If this is TRUE, the strings have been written out already. */ 83130561Sobrien bfd_boolean strings_written; 8433965Sjdp 85218822Sdim /* Is this a PE format coff file? */ 8633965Sjdp int pe; 8733965Sjdp /* Used by the COFF backend linker. */ 8833965Sjdp struct coff_link_hash_entry **sym_hashes; 8933965Sjdp 90218822Sdim /* Used by the pe linker for PowerPC. */ 9133965Sjdp int *local_toc_sym_map; 9233965Sjdp 9333965Sjdp struct bfd_link_info *link_info; 9433965Sjdp 9533965Sjdp /* Used by coff_find_nearest_line. */ 96218822Sdim void * line_info; 9738889Sjdp 98218822Sdim /* A place to stash dwarf2 info for this bfd. */ 99218822Sdim void * dwarf2_find_line_info; 10077298Sobrien 10160484Sobrien /* The timestamp from the COFF file header. */ 10260484Sobrien long timestamp; 10360484Sobrien 10438889Sjdp /* Copy of some of the f_flags bits in the COFF filehdr structure, 10538889Sjdp used by ARM code. */ 10638889Sjdp flagword flags; 10738889Sjdp 10833965Sjdp} coff_data_type; 10933965Sjdp 110218822Sdim/* Tdata for pe image files. */ 11133965Sjdptypedef struct pe_tdata 11233965Sjdp{ 11333965Sjdp coff_data_type coff; 11433965Sjdp struct internal_extra_pe_aouthdr pe_opthdr; 11533965Sjdp int dll; 11633965Sjdp int has_reloc_section; 117218822Sdim bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *); 11833965Sjdp flagword real_flags; 11978828Sobrien int target_subsystem; 120130561Sobrien bfd_boolean force_minimum_alignment; 12133965Sjdp} pe_data_type; 12233965Sjdp 12333965Sjdp#define pe_data(bfd) ((bfd)->tdata.pe_obj_data) 12433965Sjdp 12533965Sjdp/* Tdata for XCOFF files. */ 12633965Sjdp 12733965Sjdpstruct xcoff_tdata 12833965Sjdp{ 12933965Sjdp /* Basic COFF information. */ 13033965Sjdp coff_data_type coff; 13133965Sjdp 132130561Sobrien /* TRUE if this is an XCOFF64 file. */ 133130561Sobrien bfd_boolean xcoff64; 13477298Sobrien 135130561Sobrien /* TRUE if a large a.out header should be generated. */ 136130561Sobrien bfd_boolean full_aouthdr; 13733965Sjdp 13833965Sjdp /* TOC value. */ 13933965Sjdp bfd_vma toc; 14033965Sjdp 14133965Sjdp /* Index of section holding TOC. */ 14233965Sjdp int sntoc; 14333965Sjdp 14433965Sjdp /* Index of section holding entry point. */ 14533965Sjdp int snentry; 14633965Sjdp 14733965Sjdp /* .text alignment from optional header. */ 14833965Sjdp int text_align_power; 14933965Sjdp 15033965Sjdp /* .data alignment from optional header. */ 15133965Sjdp int data_align_power; 15233965Sjdp 15333965Sjdp /* modtype from optional header. */ 15433965Sjdp short modtype; 15533965Sjdp 15633965Sjdp /* cputype from optional header. */ 15733965Sjdp short cputype; 15833965Sjdp 15933965Sjdp /* maxdata from optional header. */ 16078828Sobrien bfd_vma maxdata; 16133965Sjdp 16233965Sjdp /* maxstack from optional header. */ 16378828Sobrien bfd_vma maxstack; 16433965Sjdp 16533965Sjdp /* Used by the XCOFF backend linker. */ 16633965Sjdp asection **csects; 16733965Sjdp unsigned long *debug_indices; 16833965Sjdp unsigned int import_file_id; 16933965Sjdp}; 17033965Sjdp 17133965Sjdp#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data) 17233965Sjdp 17389857Sobrien/* We take the address of the first element of an asymbol to ensure that the 174218822Sdim macro is only ever applied to an asymbol. */ 17533965Sjdp#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) 17633965Sjdp 17733965Sjdp/* The used_by_bfd field of a section may be set to a pointer to this 17833965Sjdp structure. */ 17933965Sjdp 18033965Sjdpstruct coff_section_tdata 18133965Sjdp{ 18233965Sjdp /* The relocs, swapped into COFF internal form. This may be NULL. */ 18333965Sjdp struct internal_reloc *relocs; 184130561Sobrien /* If this is TRUE, the relocs entry may not be freed. */ 185130561Sobrien bfd_boolean keep_relocs; 18633965Sjdp /* The section contents. This may be NULL. */ 18733965Sjdp bfd_byte *contents; 188130561Sobrien /* If this is TRUE, the contents entry may not be freed. */ 189130561Sobrien bfd_boolean keep_contents; 19033965Sjdp /* Information cached by coff_find_nearest_line. */ 19133965Sjdp bfd_vma offset; 19233965Sjdp unsigned int i; 19333965Sjdp const char *function; 194218822Sdim /* Optional information about a COMDAT entry; NULL if not COMDAT. */ 195218822Sdim struct coff_comdat_info *comdat; 19633965Sjdp int line_base; 19733965Sjdp /* A pointer used for .stab linking optimizations. */ 198218822Sdim void * stab_info; 19933965Sjdp /* Available for individual backends. */ 200218822Sdim void * tdata; 20133965Sjdp}; 20233965Sjdp 20333965Sjdp/* An accessor macro for the coff_section_tdata structure. */ 20433965Sjdp#define coff_section_data(abfd, sec) \ 20533965Sjdp ((struct coff_section_tdata *) (sec)->used_by_bfd) 20633965Sjdp 20733965Sjdp/* Tdata for sections in XCOFF files. This is used by the linker. */ 20833965Sjdp 20933965Sjdpstruct xcoff_section_tdata 21033965Sjdp{ 21133965Sjdp /* Used for XCOFF csects created by the linker; points to the real 21233965Sjdp XCOFF section which contains this csect. */ 21333965Sjdp asection *enclosing; 21433965Sjdp /* The lineno_count field for the enclosing section, because we are 21533965Sjdp going to clobber it there. */ 21633965Sjdp unsigned int lineno_count; 21733965Sjdp /* The first and one past the last symbol indices for symbols used 21833965Sjdp by this csect. */ 21933965Sjdp unsigned long first_symndx; 22033965Sjdp unsigned long last_symndx; 22133965Sjdp}; 22233965Sjdp 22333965Sjdp/* An accessor macro the xcoff_section_tdata structure. */ 22433965Sjdp#define xcoff_section_data(abfd, sec) \ 22533965Sjdp ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 22633965Sjdp 22760484Sobrien/* Tdata for sections in PE files. */ 22833965Sjdp 22933965Sjdpstruct pei_section_tdata 23033965Sjdp{ 23133965Sjdp /* The virtual size of the section. */ 23233965Sjdp bfd_size_type virt_size; 23360484Sobrien /* The PE section flags. */ 23460484Sobrien long pe_flags; 23533965Sjdp}; 23633965Sjdp 23733965Sjdp/* An accessor macro for the pei_section_tdata structure. */ 23833965Sjdp#define pei_section_data(abfd, sec) \ 23933965Sjdp ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 24033965Sjdp 24133965Sjdp/* COFF linker hash table entries. */ 24233965Sjdp 24333965Sjdpstruct coff_link_hash_entry 24433965Sjdp{ 24533965Sjdp struct bfd_link_hash_entry root; 24633965Sjdp 24733965Sjdp /* Symbol index in output file. Set to -1 initially. Set to -2 if 24833965Sjdp there is a reloc against this symbol. */ 24933965Sjdp long indx; 25033965Sjdp 25133965Sjdp /* Symbol type. */ 25233965Sjdp unsigned short type; 25333965Sjdp 25433965Sjdp /* Symbol class. */ 25533965Sjdp unsigned char class; 25633965Sjdp 25733965Sjdp /* Number of auxiliary entries. */ 25833965Sjdp char numaux; 25933965Sjdp 26033965Sjdp /* BFD to take auxiliary entries from. */ 26133965Sjdp bfd *auxbfd; 26233965Sjdp 26333965Sjdp /* Pointer to array of auxiliary entries, if any. */ 26433965Sjdp union internal_auxent *aux; 26560484Sobrien 26660484Sobrien /* Flag word; legal values follow. */ 26760484Sobrien unsigned short coff_link_hash_flags; 26860484Sobrien /* Symbol is a PE section symbol. */ 26960484Sobrien#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01) 27033965Sjdp}; 27133965Sjdp 27233965Sjdp/* COFF linker hash table. */ 27333965Sjdp 27433965Sjdpstruct coff_link_hash_table 27533965Sjdp{ 27633965Sjdp struct bfd_link_hash_table root; 27733965Sjdp /* A pointer to information used to link stabs in sections. */ 278218822Sdim struct stab_info stab_info; 27933965Sjdp}; 28033965Sjdp 28133965Sjdp/* Look up an entry in a COFF linker hash table. */ 28233965Sjdp 28333965Sjdp#define coff_link_hash_lookup(table, string, create, copy, follow) \ 28433965Sjdp ((struct coff_link_hash_entry *) \ 28533965Sjdp bfd_link_hash_lookup (&(table)->root, (string), (create), \ 28633965Sjdp (copy), (follow))) 28733965Sjdp 28833965Sjdp/* Traverse a COFF linker hash table. */ 28933965Sjdp 29033965Sjdp#define coff_link_hash_traverse(table, func, info) \ 29133965Sjdp (bfd_link_hash_traverse \ 29233965Sjdp (&(table)->root, \ 293218822Sdim (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \ 29433965Sjdp (info))) 29533965Sjdp 29633965Sjdp/* Get the COFF linker hash table from a link_info structure. */ 29733965Sjdp 29833965Sjdp#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) 29933965Sjdp 30033965Sjdp/* Functions in coffgen.c. */ 30189857Sobrienextern const bfd_target *coff_object_p 302218822Sdim (bfd *); 303130561Sobrienextern struct bfd_section *coff_section_from_bfd_index 304218822Sdim (bfd *, int); 30589857Sobrienextern long coff_get_symtab_upper_bound 306218822Sdim (bfd *); 307130561Sobrienextern long coff_canonicalize_symtab 308218822Sdim (bfd *, asymbol **); 30989857Sobrienextern int coff_count_linenumbers 310218822Sdim (bfd *); 31189857Sobrienextern struct coff_symbol_struct *coff_symbol_from 312218822Sdim (bfd *, asymbol *); 313130561Sobrienextern bfd_boolean coff_renumber_symbols 314218822Sdim (bfd *, int *); 31589857Sobrienextern void coff_mangle_symbols 316218822Sdim (bfd *); 317130561Sobrienextern bfd_boolean coff_write_symbols 318218822Sdim (bfd *); 319130561Sobrienextern bfd_boolean coff_write_linenumbers 320218822Sdim (bfd *); 32189857Sobrienextern alent *coff_get_lineno 322218822Sdim (bfd *, asymbol *); 32389857Sobrienextern asymbol *coff_section_symbol 324218822Sdim (bfd *, char *); 325130561Sobrienextern bfd_boolean _bfd_coff_get_external_symbols 326218822Sdim (bfd *); 32789857Sobrienextern const char *_bfd_coff_read_string_table 328218822Sdim (bfd *); 329130561Sobrienextern bfd_boolean _bfd_coff_free_symbols 330218822Sdim (bfd *); 33189857Sobrienextern struct coff_ptr_struct *coff_get_normalized_symtab 332218822Sdim (bfd *); 33389857Sobrienextern long coff_get_reloc_upper_bound 334218822Sdim (bfd *, sec_ptr); 33589857Sobrienextern asymbol *coff_make_empty_symbol 336218822Sdim (bfd *); 33789857Sobrienextern void coff_print_symbol 338218822Sdim (bfd *, void * filep, asymbol *, bfd_print_symbol_type); 33989857Sobrienextern void coff_get_symbol_info 340218822Sdim (bfd *, asymbol *, symbol_info *ret); 341130561Sobrienextern bfd_boolean _bfd_coff_is_local_label_name 342218822Sdim (bfd *, const char *); 34389857Sobrienextern asymbol *coff_bfd_make_debug_symbol 344218822Sdim (bfd *, void *, unsigned long); 345130561Sobrienextern bfd_boolean coff_find_nearest_line 346218822Sdim (bfd *, asection *, asymbol **, bfd_vma, const char **, 347218822Sdim const char **, unsigned int *); 348218822Sdimextern bfd_boolean coff_find_inliner_info 349218822Sdim (bfd *, const char **, const char **, unsigned int *); 35089857Sobrienextern int coff_sizeof_headers 351218822Sdim (bfd *, struct bfd_link_info *); 352130561Sobrienextern bfd_boolean bfd_coff_reloc16_relax_section 353218822Sdim (bfd *, asection *, struct bfd_link_info *, bfd_boolean *); 35433965Sjdpextern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents 355218822Sdim (bfd *, struct bfd_link_info *, struct bfd_link_order *, 356218822Sdim bfd_byte *, bfd_boolean, asymbol **); 35789857Sobrienextern bfd_vma bfd_coff_reloc16_get_value 358218822Sdim (arelent *, struct bfd_link_info *, asection *); 35989857Sobrienextern void bfd_perform_slip 360218822Sdim (bfd *, unsigned int, asection *, bfd_vma); 36133965Sjdp 36233965Sjdp/* Functions and types in cofflink.c. */ 36333965Sjdp 364218822Sdim#define STRING_SIZE_SIZE 4 36533965Sjdp 36633965Sjdp/* We use a hash table to merge identical enum, struct, and union 36733965Sjdp definitions in the linker. */ 36833965Sjdp 36933965Sjdp/* Information we keep for a single element (an enum value, a 37033965Sjdp structure or union field) in the debug merge hash table. */ 37133965Sjdp 37233965Sjdpstruct coff_debug_merge_element 37333965Sjdp{ 37433965Sjdp /* Next element. */ 37533965Sjdp struct coff_debug_merge_element *next; 37633965Sjdp 37733965Sjdp /* Name. */ 37833965Sjdp const char *name; 37933965Sjdp 38033965Sjdp /* Type. */ 38133965Sjdp unsigned int type; 38233965Sjdp 38333965Sjdp /* Symbol index for complex type. */ 38433965Sjdp long tagndx; 38533965Sjdp}; 38633965Sjdp 38733965Sjdp/* A linked list of debug merge entries for a given name. */ 38833965Sjdp 38933965Sjdpstruct coff_debug_merge_type 39033965Sjdp{ 39133965Sjdp /* Next type with the same name. */ 39233965Sjdp struct coff_debug_merge_type *next; 39333965Sjdp 39433965Sjdp /* Class of type. */ 39533965Sjdp int class; 39633965Sjdp 39733965Sjdp /* Symbol index where this type is defined. */ 39833965Sjdp long indx; 39933965Sjdp 40033965Sjdp /* List of elements. */ 40133965Sjdp struct coff_debug_merge_element *elements; 40233965Sjdp}; 40333965Sjdp 40433965Sjdp/* Information we store in the debug merge hash table. */ 40533965Sjdp 40633965Sjdpstruct coff_debug_merge_hash_entry 40733965Sjdp{ 40833965Sjdp struct bfd_hash_entry root; 40933965Sjdp 41033965Sjdp /* A list of types with this name. */ 41133965Sjdp struct coff_debug_merge_type *types; 41233965Sjdp}; 41333965Sjdp 41433965Sjdp/* The debug merge hash table. */ 41533965Sjdp 41633965Sjdpstruct coff_debug_merge_hash_table 41733965Sjdp{ 41833965Sjdp struct bfd_hash_table root; 41933965Sjdp}; 42033965Sjdp 42133965Sjdp/* Initialize a COFF debug merge hash table. */ 42233965Sjdp 42333965Sjdp#define coff_debug_merge_hash_table_init(table) \ 424218822Sdim (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \ 425218822Sdim sizeof (struct coff_debug_merge_hash_entry))) 42633965Sjdp 42733965Sjdp/* Free a COFF debug merge hash table. */ 42833965Sjdp 42933965Sjdp#define coff_debug_merge_hash_table_free(table) \ 43033965Sjdp (bfd_hash_table_free (&(table)->root)) 43133965Sjdp 43233965Sjdp/* Look up an entry in a COFF debug merge hash table. */ 43333965Sjdp 43433965Sjdp#define coff_debug_merge_hash_lookup(table, string, create, copy) \ 43533965Sjdp ((struct coff_debug_merge_hash_entry *) \ 43633965Sjdp bfd_hash_lookup (&(table)->root, (string), (create), (copy))) 43733965Sjdp 43833965Sjdp/* Information we keep for each section in the output file when doing 439130561Sobrien a relocatable link. */ 44033965Sjdp 44133965Sjdpstruct coff_link_section_info 44233965Sjdp{ 44333965Sjdp /* The relocs to be output. */ 44433965Sjdp struct internal_reloc *relocs; 44533965Sjdp /* For each reloc against a global symbol whose index was not known 44633965Sjdp when the reloc was handled, the global hash table entry. */ 44733965Sjdp struct coff_link_hash_entry **rel_hashes; 44833965Sjdp}; 44933965Sjdp 45033965Sjdp/* Information that we pass around while doing the final link step. */ 45133965Sjdp 45233965Sjdpstruct coff_final_link_info 45333965Sjdp{ 45433965Sjdp /* General link information. */ 45533965Sjdp struct bfd_link_info *info; 45633965Sjdp /* Output BFD. */ 45733965Sjdp bfd *output_bfd; 45833965Sjdp /* Used to indicate failure in traversal routine. */ 459130561Sobrien bfd_boolean failed; 46038889Sjdp /* If doing "task linking" set only during the time when we want the 46138889Sjdp global symbol writer to convert the storage class of defined global 46238889Sjdp symbols from global to static. */ 463130561Sobrien bfd_boolean global_to_static; 46433965Sjdp /* Hash table for long symbol names. */ 46533965Sjdp struct bfd_strtab_hash *strtab; 466130561Sobrien /* When doing a relocatable link, an array of information kept for 46733965Sjdp each output section, indexed by the target_index field. */ 46833965Sjdp struct coff_link_section_info *section_info; 46933965Sjdp /* Symbol index of last C_FILE symbol (-1 if none). */ 47033965Sjdp long last_file_index; 47133965Sjdp /* Contents of last C_FILE symbol. */ 47233965Sjdp struct internal_syment last_file; 47333965Sjdp /* Symbol index of first aux entry of last .bf symbol with an empty 47433965Sjdp endndx field (-1 if none). */ 47533965Sjdp long last_bf_index; 47633965Sjdp /* Contents of last_bf_index aux entry. */ 47733965Sjdp union internal_auxent last_bf; 47833965Sjdp /* Hash table used to merge debug information. */ 47933965Sjdp struct coff_debug_merge_hash_table debug_merge; 48033965Sjdp /* Buffer large enough to hold swapped symbols of any input file. */ 48133965Sjdp struct internal_syment *internal_syms; 48233965Sjdp /* Buffer large enough to hold sections of symbols of any input file. */ 48333965Sjdp asection **sec_ptrs; 48433965Sjdp /* Buffer large enough to hold output indices of symbols of any 48533965Sjdp input file. */ 48633965Sjdp long *sym_indices; 48733965Sjdp /* Buffer large enough to hold output symbols for any input file. */ 48833965Sjdp bfd_byte *outsyms; 48933965Sjdp /* Buffer large enough to hold external line numbers for any input 49033965Sjdp section. */ 49133965Sjdp bfd_byte *linenos; 49233965Sjdp /* Buffer large enough to hold any input section. */ 49333965Sjdp bfd_byte *contents; 49433965Sjdp /* Buffer large enough to hold external relocs of any input section. */ 49533965Sjdp bfd_byte *external_relocs; 49633965Sjdp /* Buffer large enough to hold swapped relocs of any input section. */ 49733965Sjdp struct internal_reloc *internal_relocs; 49833965Sjdp}; 49933965Sjdp 50060484Sobrien/* Most COFF variants have no way to record the alignment of a 50160484Sobrien section. This struct is used to set a specific alignment based on 50260484Sobrien the name of the section. */ 50360484Sobrien 50460484Sobrienstruct coff_section_alignment_entry 50560484Sobrien{ 50660484Sobrien /* The section name. */ 50760484Sobrien const char *name; 50860484Sobrien 50960484Sobrien /* This is either (unsigned int) -1, indicating that the section 51060484Sobrien name must match exactly, or it is the number of letters which 51160484Sobrien must match at the start of the name. */ 51260484Sobrien unsigned int comparison_length; 51360484Sobrien 51460484Sobrien /* These macros may be used to fill in the first two fields in a 51560484Sobrien structure initialization. */ 51660484Sobrien#define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1) 51760484Sobrien#define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1) 51860484Sobrien 51960484Sobrien /* Only use this entry if the default section alignment for this 52060484Sobrien target is at least that much (as a power of two). If this field 52160484Sobrien is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 52260484Sobrien unsigned int default_alignment_min; 52360484Sobrien 52460484Sobrien /* Only use this entry if the default section alignment for this 52560484Sobrien target is no greater than this (as a power of two). If this 52660484Sobrien field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 52760484Sobrien unsigned int default_alignment_max; 52860484Sobrien 52960484Sobrien#define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1) 53060484Sobrien 53160484Sobrien /* The desired alignment for this section (as a power of two). */ 53260484Sobrien unsigned int alignment_power; 53360484Sobrien}; 53460484Sobrien 53533965Sjdpextern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc 536218822Sdim (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 537130561Sobrienextern bfd_boolean _bfd_coff_link_hash_table_init 538218822Sdim (struct coff_link_hash_table *, bfd *, 539218822Sdim struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 540218822Sdim struct bfd_hash_table *, 541218822Sdim const char *), 542218822Sdim unsigned int); 54333965Sjdpextern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create 544218822Sdim (bfd *); 54533965Sjdpextern const char *_bfd_coff_internal_syment_name 546218822Sdim (bfd *, const struct internal_syment *, char *); 547130561Sobrienextern bfd_boolean _bfd_coff_link_add_symbols 548218822Sdim (bfd *, struct bfd_link_info *); 549130561Sobrienextern bfd_boolean _bfd_coff_final_link 550218822Sdim (bfd *, struct bfd_link_info *); 55133965Sjdpextern struct internal_reloc *_bfd_coff_read_internal_relocs 552218822Sdim (bfd *, asection *, bfd_boolean, bfd_byte *, bfd_boolean, 553218822Sdim struct internal_reloc *); 554130561Sobrienextern bfd_boolean _bfd_coff_generic_relocate_section 555218822Sdim (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 556218822Sdim struct internal_reloc *, struct internal_syment *, asection **); 55733965Sjdpextern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc 558218822Sdim (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); 559130561Sobrienextern bfd_boolean _bfd_coff_write_global_sym 560218822Sdim (struct coff_link_hash_entry *, void *); 561130561Sobrienextern bfd_boolean _bfd_coff_write_task_globals 562218822Sdim (struct coff_link_hash_entry *, void *); 563130561Sobrienextern bfd_boolean _bfd_coff_link_input_bfd 564218822Sdim (struct coff_final_link_info *, bfd *); 565130561Sobrienextern bfd_boolean _bfd_coff_reloc_link_order 566218822Sdim (bfd *, struct coff_final_link_info *, asection *, 567218822Sdim struct bfd_link_order *); 56833965Sjdp 56933965Sjdp 57033965Sjdp#define coff_get_section_contents_in_window \ 57133965Sjdp _bfd_generic_get_section_contents_in_window 57233965Sjdp 57333965Sjdp/* Functions in xcofflink.c. */ 57433965Sjdp 57589857Sobrienextern long _bfd_xcoff_get_dynamic_symtab_upper_bound 576218822Sdim (bfd *); 57733965Sjdpextern long _bfd_xcoff_canonicalize_dynamic_symtab 578218822Sdim (bfd *, asymbol **); 57989857Sobrienextern long _bfd_xcoff_get_dynamic_reloc_upper_bound 580218822Sdim (bfd *); 58133965Sjdpextern long _bfd_xcoff_canonicalize_dynamic_reloc 582218822Sdim (bfd *, arelent **, asymbol **); 58333965Sjdpextern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create 584218822Sdim (bfd *); 585104834Sobrienextern void _bfd_xcoff_bfd_link_hash_table_free 586218822Sdim (struct bfd_link_hash_table *); 587130561Sobrienextern bfd_boolean _bfd_xcoff_bfd_link_add_symbols 588218822Sdim (bfd *, struct bfd_link_info *); 589130561Sobrienextern bfd_boolean _bfd_xcoff_bfd_final_link 590218822Sdim (bfd *, struct bfd_link_info *); 591130561Sobrienextern bfd_boolean _bfd_ppc_xcoff_relocate_section 592218822Sdim (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 593218822Sdim struct internal_reloc *, struct internal_syment *, asection **); 59433965Sjdp 59533965Sjdp/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the 59633965Sjdp linker, and so should start with bfd and be declared in bfd.h. */ 59733965Sjdp 598130561Sobrienextern bfd_boolean ppc_allocate_toc_section 599218822Sdim (struct bfd_link_info *); 600130561Sobrienextern bfd_boolean ppc_process_before_allocation 601218822Sdim (bfd *, struct bfd_link_info *); 60233965Sjdp 603