libcoff-in.h revision 104834
133965Sjdp/* BFD COFF object file private structure. 278828Sobrien Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3104834Sobrien 2000, 2001, 2002 433965Sjdp Free Software Foundation, Inc. 533965Sjdp Written by Cygnus Support. 633965Sjdp 733965SjdpThis file is part of BFD, the Binary File Descriptor library. 833965Sjdp 933965SjdpThis program is free software; you can redistribute it and/or modify 1033965Sjdpit under the terms of the GNU General Public License as published by 1133965Sjdpthe Free Software Foundation; either version 2 of the License, or 1233965Sjdp(at your option) any later version. 1333965Sjdp 1433965SjdpThis program is distributed in the hope that it will be useful, 1533965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of 1633965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1733965SjdpGNU General Public License for more details. 1833965Sjdp 1933965SjdpYou should have received a copy of the GNU General Public License 2033965Sjdpalong with this program; if not, write to the Free Software 2133965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2233965Sjdp 2333965Sjdp#include "bfdlink.h" 2433965Sjdp 2533965Sjdp/* Object file tdata; access macros */ 2633965Sjdp 2733965Sjdp#define coff_data(bfd) ((bfd)->tdata.coff_obj_data) 2833965Sjdp#define exec_hdr(bfd) (coff_data(bfd)->hdr) 2933965Sjdp#define obj_pe(bfd) (coff_data(bfd)->pe) 3033965Sjdp#define obj_symbols(bfd) (coff_data(bfd)->symbols) 3133965Sjdp#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos) 3233965Sjdp 3333965Sjdp#define obj_relocbase(bfd) (coff_data(bfd)->relocbase) 3433965Sjdp#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments) 3533965Sjdp#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count) 3633965Sjdp#define obj_convert(bfd) (coff_data(bfd)->conversion_table) 3733965Sjdp#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size) 3833965Sjdp 3933965Sjdp#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) 4033965Sjdp#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) 4133965Sjdp#define obj_coff_strings(bfd) (coff_data (bfd)->strings) 4233965Sjdp#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) 4333965Sjdp#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) 4477298Sobrien#define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) 4533965Sjdp 4633965Sjdp#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map) 4733965Sjdp 4833965Sjdp/* `Tdata' information kept for COFF files. */ 4933965Sjdp 5033965Sjdptypedef struct coff_tdata 5133965Sjdp{ 5233965Sjdp struct coff_symbol_struct *symbols; /* symtab for input bfd */ 5333965Sjdp unsigned int *conversion_table; 5433965Sjdp int conv_table_size; 5533965Sjdp file_ptr sym_filepos; 5633965Sjdp 5733965Sjdp struct coff_ptr_struct *raw_syments; 5860484Sobrien unsigned long raw_syment_count; 5933965Sjdp 6033965Sjdp /* These are only valid once writing has begun */ 6133965Sjdp long int relocbase; 6233965Sjdp 6333965Sjdp /* These members communicate important constants about the symbol table 6433965Sjdp to GDB's symbol-reading code. These `constants' unfortunately vary 6533965Sjdp from coff implementation to implementation... */ 6633965Sjdp unsigned local_n_btmask; 6733965Sjdp unsigned local_n_btshft; 6833965Sjdp unsigned local_n_tmask; 6933965Sjdp unsigned local_n_tshift; 7033965Sjdp unsigned local_symesz; 7133965Sjdp unsigned local_auxesz; 7233965Sjdp unsigned local_linesz; 7333965Sjdp 7433965Sjdp /* The unswapped external symbols. May be NULL. Read by 7533965Sjdp _bfd_coff_get_external_symbols. */ 7633965Sjdp PTR external_syms; 7733965Sjdp /* If this is true, the external_syms may not be freed. */ 7833965Sjdp boolean keep_syms; 7933965Sjdp 8033965Sjdp /* The string table. May be NULL. Read by 8133965Sjdp _bfd_coff_read_string_table. */ 8233965Sjdp char *strings; 8333965Sjdp /* If this is true, the strings may not be freed. */ 8433965Sjdp boolean keep_strings; 8577298Sobrien /* If this is true, the strings have been written out already. */ 8677298Sobrien boolean strings_written; 8733965Sjdp 8833965Sjdp /* is this a PE format coff file */ 8933965Sjdp int pe; 9033965Sjdp /* Used by the COFF backend linker. */ 9133965Sjdp struct coff_link_hash_entry **sym_hashes; 9233965Sjdp 9333965Sjdp /* used by the pe linker for PowerPC */ 9433965Sjdp int *local_toc_sym_map; 9533965Sjdp 9633965Sjdp struct bfd_link_info *link_info; 9733965Sjdp 9833965Sjdp /* Used by coff_find_nearest_line. */ 9933965Sjdp PTR line_info; 10038889Sjdp 10177298Sobrien /* A place to stash dwarf2 info for this bfd. */ 10277298Sobrien PTR dwarf2_find_line_info; 10377298Sobrien 10460484Sobrien /* The timestamp from the COFF file header. */ 10560484Sobrien long timestamp; 10660484Sobrien 10738889Sjdp /* Copy of some of the f_flags bits in the COFF filehdr structure, 10838889Sjdp used by ARM code. */ 10938889Sjdp flagword flags; 11038889Sjdp 11133965Sjdp} coff_data_type; 11233965Sjdp 11333965Sjdp/* Tdata for pe image files. */ 11433965Sjdptypedef struct pe_tdata 11533965Sjdp{ 11633965Sjdp coff_data_type coff; 11733965Sjdp struct internal_extra_pe_aouthdr pe_opthdr; 11833965Sjdp int dll; 11933965Sjdp int has_reloc_section; 12033965Sjdp boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *)); 12133965Sjdp flagword real_flags; 12278828Sobrien int target_subsystem; 12378828Sobrien boolean force_minimum_alignment; 12433965Sjdp} pe_data_type; 12533965Sjdp 12633965Sjdp#define pe_data(bfd) ((bfd)->tdata.pe_obj_data) 12733965Sjdp 12833965Sjdp/* Tdata for XCOFF files. */ 12933965Sjdp 13033965Sjdpstruct xcoff_tdata 13133965Sjdp{ 13233965Sjdp /* Basic COFF information. */ 13333965Sjdp coff_data_type coff; 13433965Sjdp 13577298Sobrien /* True if this is an XCOFF64 file. */ 13677298Sobrien boolean xcoff64; 13777298Sobrien 13833965Sjdp /* True if a large a.out header should be generated. */ 13933965Sjdp boolean full_aouthdr; 14033965Sjdp 14133965Sjdp /* TOC value. */ 14233965Sjdp bfd_vma toc; 14333965Sjdp 14433965Sjdp /* Index of section holding TOC. */ 14533965Sjdp int sntoc; 14633965Sjdp 14733965Sjdp /* Index of section holding entry point. */ 14833965Sjdp int snentry; 14933965Sjdp 15033965Sjdp /* .text alignment from optional header. */ 15133965Sjdp int text_align_power; 15233965Sjdp 15333965Sjdp /* .data alignment from optional header. */ 15433965Sjdp int data_align_power; 15533965Sjdp 15633965Sjdp /* modtype from optional header. */ 15733965Sjdp short modtype; 15833965Sjdp 15933965Sjdp /* cputype from optional header. */ 16033965Sjdp short cputype; 16133965Sjdp 16233965Sjdp /* maxdata from optional header. */ 16378828Sobrien bfd_vma maxdata; 16433965Sjdp 16533965Sjdp /* maxstack from optional header. */ 16678828Sobrien bfd_vma maxstack; 16733965Sjdp 16833965Sjdp /* Used by the XCOFF backend linker. */ 16933965Sjdp asection **csects; 17033965Sjdp unsigned long *debug_indices; 17133965Sjdp unsigned int import_file_id; 17233965Sjdp}; 17333965Sjdp 17433965Sjdp#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data) 17533965Sjdp 17689857Sobrien/* We take the address of the first element of an asymbol to ensure that the 17733965Sjdp * macro is only ever applied to an asymbol. */ 17833965Sjdp#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) 17933965Sjdp 18033965Sjdp/* The used_by_bfd field of a section may be set to a pointer to this 18133965Sjdp structure. */ 18233965Sjdp 18333965Sjdpstruct coff_section_tdata 18433965Sjdp{ 18533965Sjdp /* The relocs, swapped into COFF internal form. This may be NULL. */ 18633965Sjdp struct internal_reloc *relocs; 18733965Sjdp /* If this is true, the relocs entry may not be freed. */ 18833965Sjdp boolean keep_relocs; 18933965Sjdp /* The section contents. This may be NULL. */ 19033965Sjdp bfd_byte *contents; 19133965Sjdp /* If this is true, the contents entry may not be freed. */ 19233965Sjdp boolean keep_contents; 19333965Sjdp /* Information cached by coff_find_nearest_line. */ 19433965Sjdp bfd_vma offset; 19533965Sjdp unsigned int i; 19633965Sjdp const char *function; 19733965Sjdp int line_base; 19833965Sjdp /* A pointer used for .stab linking optimizations. */ 19933965Sjdp PTR stab_info; 20033965Sjdp /* Available for individual backends. */ 20133965Sjdp PTR tdata; 20233965Sjdp}; 20333965Sjdp 20433965Sjdp/* An accessor macro for the coff_section_tdata structure. */ 20533965Sjdp#define coff_section_data(abfd, sec) \ 20633965Sjdp ((struct coff_section_tdata *) (sec)->used_by_bfd) 20733965Sjdp 20833965Sjdp/* Tdata for sections in XCOFF files. This is used by the linker. */ 20933965Sjdp 21033965Sjdpstruct xcoff_section_tdata 21133965Sjdp{ 21233965Sjdp /* Used for XCOFF csects created by the linker; points to the real 21333965Sjdp XCOFF section which contains this csect. */ 21433965Sjdp asection *enclosing; 21533965Sjdp /* The lineno_count field for the enclosing section, because we are 21633965Sjdp going to clobber it there. */ 21733965Sjdp unsigned int lineno_count; 21833965Sjdp /* The first and one past the last symbol indices for symbols used 21933965Sjdp by this csect. */ 22033965Sjdp unsigned long first_symndx; 22133965Sjdp unsigned long last_symndx; 22233965Sjdp}; 22333965Sjdp 22433965Sjdp/* An accessor macro the xcoff_section_tdata structure. */ 22533965Sjdp#define xcoff_section_data(abfd, sec) \ 22633965Sjdp ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 22733965Sjdp 22860484Sobrien/* Tdata for sections in PE files. */ 22933965Sjdp 23033965Sjdpstruct pei_section_tdata 23133965Sjdp{ 23233965Sjdp /* The virtual size of the section. */ 23333965Sjdp bfd_size_type virt_size; 23460484Sobrien /* The PE section flags. */ 23560484Sobrien long pe_flags; 23633965Sjdp}; 23733965Sjdp 23833965Sjdp/* An accessor macro for the pei_section_tdata structure. */ 23933965Sjdp#define pei_section_data(abfd, sec) \ 24033965Sjdp ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata) 24133965Sjdp 24233965Sjdp/* COFF linker hash table entries. */ 24333965Sjdp 24433965Sjdpstruct coff_link_hash_entry 24533965Sjdp{ 24633965Sjdp struct bfd_link_hash_entry root; 24733965Sjdp 24833965Sjdp /* Symbol index in output file. Set to -1 initially. Set to -2 if 24933965Sjdp there is a reloc against this symbol. */ 25033965Sjdp long indx; 25133965Sjdp 25233965Sjdp /* Symbol type. */ 25333965Sjdp unsigned short type; 25433965Sjdp 25533965Sjdp /* Symbol class. */ 25633965Sjdp unsigned char class; 25733965Sjdp 25833965Sjdp /* Number of auxiliary entries. */ 25933965Sjdp char numaux; 26033965Sjdp 26133965Sjdp /* BFD to take auxiliary entries from. */ 26233965Sjdp bfd *auxbfd; 26333965Sjdp 26433965Sjdp /* Pointer to array of auxiliary entries, if any. */ 26533965Sjdp union internal_auxent *aux; 26660484Sobrien 26760484Sobrien /* Flag word; legal values follow. */ 26860484Sobrien unsigned short coff_link_hash_flags; 26960484Sobrien /* Symbol is a PE section symbol. */ 27060484Sobrien#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01) 27133965Sjdp}; 27233965Sjdp 27333965Sjdp/* COFF linker hash table. */ 27433965Sjdp 27533965Sjdpstruct coff_link_hash_table 27633965Sjdp{ 27733965Sjdp struct bfd_link_hash_table root; 27833965Sjdp /* A pointer to information used to link stabs in sections. */ 27933965Sjdp PTR stab_info; 28033965Sjdp}; 28133965Sjdp 28233965Sjdp/* Look up an entry in a COFF linker hash table. */ 28333965Sjdp 28433965Sjdp#define coff_link_hash_lookup(table, string, create, copy, follow) \ 28533965Sjdp ((struct coff_link_hash_entry *) \ 28633965Sjdp bfd_link_hash_lookup (&(table)->root, (string), (create), \ 28733965Sjdp (copy), (follow))) 28833965Sjdp 28933965Sjdp/* Traverse a COFF linker hash table. */ 29033965Sjdp 29133965Sjdp#define coff_link_hash_traverse(table, func, info) \ 29233965Sjdp (bfd_link_hash_traverse \ 29333965Sjdp (&(table)->root, \ 29433965Sjdp (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ 29533965Sjdp (info))) 29633965Sjdp 29733965Sjdp/* Get the COFF linker hash table from a link_info structure. */ 29833965Sjdp 29933965Sjdp#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) 30033965Sjdp 30133965Sjdp/* Functions in coffgen.c. */ 30289857Sobrienextern const bfd_target *coff_object_p 30389857Sobrien PARAMS ((bfd *)); 30489857Sobrienextern struct sec *coff_section_from_bfd_index 30589857Sobrien PARAMS ((bfd *, int)); 30689857Sobrienextern long coff_get_symtab_upper_bound 30789857Sobrien PARAMS ((bfd *)); 30889857Sobrienextern long coff_get_symtab 30989857Sobrien PARAMS ((bfd *, asymbol **)); 31089857Sobrienextern int coff_count_linenumbers 31189857Sobrien PARAMS ((bfd *)); 31289857Sobrienextern struct coff_symbol_struct *coff_symbol_from 31389857Sobrien PARAMS ((bfd *, asymbol *)); 31489857Sobrienextern boolean coff_renumber_symbols 31589857Sobrien PARAMS ((bfd *, int *)); 31689857Sobrienextern void coff_mangle_symbols 31789857Sobrien PARAMS ((bfd *)); 31889857Sobrienextern boolean coff_write_symbols 31989857Sobrien PARAMS ((bfd *)); 32089857Sobrienextern boolean coff_write_linenumbers 32189857Sobrien PARAMS ((bfd *)); 32289857Sobrienextern alent *coff_get_lineno 32389857Sobrien PARAMS ((bfd *, asymbol *)); 32489857Sobrienextern asymbol *coff_section_symbol 32589857Sobrien PARAMS ((bfd *, char *)); 32689857Sobrienextern boolean _bfd_coff_get_external_symbols 32789857Sobrien PARAMS ((bfd *)); 32889857Sobrienextern const char *_bfd_coff_read_string_table 32989857Sobrien PARAMS ((bfd *)); 33089857Sobrienextern boolean _bfd_coff_free_symbols 33189857Sobrien PARAMS ((bfd *)); 33289857Sobrienextern struct coff_ptr_struct *coff_get_normalized_symtab 33389857Sobrien PARAMS ((bfd *)); 33489857Sobrienextern long coff_get_reloc_upper_bound 33589857Sobrien PARAMS ((bfd *, sec_ptr)); 33689857Sobrienextern asymbol *coff_make_empty_symbol 33789857Sobrien PARAMS ((bfd *)); 33889857Sobrienextern void coff_print_symbol 33989857Sobrien PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type)); 34089857Sobrienextern void coff_get_symbol_info 34189857Sobrien PARAMS ((bfd *, asymbol *, symbol_info *ret)); 34289857Sobrienextern boolean _bfd_coff_is_local_label_name 34389857Sobrien PARAMS ((bfd *, const char *)); 34489857Sobrienextern asymbol *coff_bfd_make_debug_symbol 34589857Sobrien PARAMS ((bfd *, PTR, unsigned long)); 34689857Sobrienextern boolean coff_find_nearest_line 34789857Sobrien PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, 34889857Sobrien const char **, unsigned int *)); 34989857Sobrienextern int coff_sizeof_headers 35089857Sobrien PARAMS ((bfd *, boolean)); 35133965Sjdpextern boolean bfd_coff_reloc16_relax_section 35233965Sjdp PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); 35333965Sjdpextern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents 35433965Sjdp PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, 35589857Sobrien bfd_byte *, boolean, asymbol **)); 35689857Sobrienextern bfd_vma bfd_coff_reloc16_get_value 35789857Sobrien PARAMS ((arelent *, struct bfd_link_info *, asection *)); 35889857Sobrienextern void bfd_perform_slip 35989857Sobrien PARAMS ((bfd *, unsigned int, asection *, bfd_vma)); 36033965Sjdp 36133965Sjdp/* Functions and types in cofflink.c. */ 36233965Sjdp 36333965Sjdp#define STRING_SIZE_SIZE (4) 36433965Sjdp 36533965Sjdp/* We use a hash table to merge identical enum, struct, and union 36633965Sjdp definitions in the linker. */ 36733965Sjdp 36833965Sjdp/* Information we keep for a single element (an enum value, a 36933965Sjdp structure or union field) in the debug merge hash table. */ 37033965Sjdp 37133965Sjdpstruct coff_debug_merge_element 37233965Sjdp{ 37333965Sjdp /* Next element. */ 37433965Sjdp struct coff_debug_merge_element *next; 37533965Sjdp 37633965Sjdp /* Name. */ 37733965Sjdp const char *name; 37833965Sjdp 37933965Sjdp /* Type. */ 38033965Sjdp unsigned int type; 38133965Sjdp 38233965Sjdp /* Symbol index for complex type. */ 38333965Sjdp long tagndx; 38433965Sjdp}; 38533965Sjdp 38633965Sjdp/* A linked list of debug merge entries for a given name. */ 38733965Sjdp 38833965Sjdpstruct coff_debug_merge_type 38933965Sjdp{ 39033965Sjdp /* Next type with the same name. */ 39133965Sjdp struct coff_debug_merge_type *next; 39233965Sjdp 39333965Sjdp /* Class of type. */ 39433965Sjdp int class; 39533965Sjdp 39633965Sjdp /* Symbol index where this type is defined. */ 39733965Sjdp long indx; 39833965Sjdp 39933965Sjdp /* List of elements. */ 40033965Sjdp struct coff_debug_merge_element *elements; 40133965Sjdp}; 40233965Sjdp 40333965Sjdp/* Information we store in the debug merge hash table. */ 40433965Sjdp 40533965Sjdpstruct coff_debug_merge_hash_entry 40633965Sjdp{ 40733965Sjdp struct bfd_hash_entry root; 40833965Sjdp 40933965Sjdp /* A list of types with this name. */ 41033965Sjdp struct coff_debug_merge_type *types; 41133965Sjdp}; 41233965Sjdp 41333965Sjdp/* The debug merge hash table. */ 41433965Sjdp 41533965Sjdpstruct coff_debug_merge_hash_table 41633965Sjdp{ 41733965Sjdp struct bfd_hash_table root; 41833965Sjdp}; 41933965Sjdp 42033965Sjdp/* Initialize a COFF debug merge hash table. */ 42133965Sjdp 42233965Sjdp#define coff_debug_merge_hash_table_init(table) \ 42333965Sjdp (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc)) 42433965Sjdp 42533965Sjdp/* Free a COFF debug merge hash table. */ 42633965Sjdp 42733965Sjdp#define coff_debug_merge_hash_table_free(table) \ 42833965Sjdp (bfd_hash_table_free (&(table)->root)) 42933965Sjdp 43033965Sjdp/* Look up an entry in a COFF debug merge hash table. */ 43133965Sjdp 43233965Sjdp#define coff_debug_merge_hash_lookup(table, string, create, copy) \ 43333965Sjdp ((struct coff_debug_merge_hash_entry *) \ 43433965Sjdp bfd_hash_lookup (&(table)->root, (string), (create), (copy))) 43533965Sjdp 43633965Sjdp/* Information we keep for each section in the output file when doing 43733965Sjdp a relocateable link. */ 43833965Sjdp 43933965Sjdpstruct coff_link_section_info 44033965Sjdp{ 44133965Sjdp /* The relocs to be output. */ 44233965Sjdp struct internal_reloc *relocs; 44333965Sjdp /* For each reloc against a global symbol whose index was not known 44433965Sjdp when the reloc was handled, the global hash table entry. */ 44533965Sjdp struct coff_link_hash_entry **rel_hashes; 44633965Sjdp}; 44733965Sjdp 44833965Sjdp/* Information that we pass around while doing the final link step. */ 44933965Sjdp 45033965Sjdpstruct coff_final_link_info 45133965Sjdp{ 45233965Sjdp /* General link information. */ 45333965Sjdp struct bfd_link_info *info; 45433965Sjdp /* Output BFD. */ 45533965Sjdp bfd *output_bfd; 45633965Sjdp /* Used to indicate failure in traversal routine. */ 45733965Sjdp boolean failed; 45838889Sjdp /* If doing "task linking" set only during the time when we want the 45938889Sjdp global symbol writer to convert the storage class of defined global 46038889Sjdp symbols from global to static. */ 46138889Sjdp boolean global_to_static; 46233965Sjdp /* Hash table for long symbol names. */ 46333965Sjdp struct bfd_strtab_hash *strtab; 46433965Sjdp /* When doing a relocateable link, an array of information kept for 46533965Sjdp each output section, indexed by the target_index field. */ 46633965Sjdp struct coff_link_section_info *section_info; 46733965Sjdp /* Symbol index of last C_FILE symbol (-1 if none). */ 46833965Sjdp long last_file_index; 46933965Sjdp /* Contents of last C_FILE symbol. */ 47033965Sjdp struct internal_syment last_file; 47133965Sjdp /* Symbol index of first aux entry of last .bf symbol with an empty 47233965Sjdp endndx field (-1 if none). */ 47333965Sjdp long last_bf_index; 47433965Sjdp /* Contents of last_bf_index aux entry. */ 47533965Sjdp union internal_auxent last_bf; 47633965Sjdp /* Hash table used to merge debug information. */ 47733965Sjdp struct coff_debug_merge_hash_table debug_merge; 47833965Sjdp /* Buffer large enough to hold swapped symbols of any input file. */ 47933965Sjdp struct internal_syment *internal_syms; 48033965Sjdp /* Buffer large enough to hold sections of symbols of any input file. */ 48133965Sjdp asection **sec_ptrs; 48233965Sjdp /* Buffer large enough to hold output indices of symbols of any 48333965Sjdp input file. */ 48433965Sjdp long *sym_indices; 48533965Sjdp /* Buffer large enough to hold output symbols for any input file. */ 48633965Sjdp bfd_byte *outsyms; 48733965Sjdp /* Buffer large enough to hold external line numbers for any input 48833965Sjdp section. */ 48933965Sjdp bfd_byte *linenos; 49033965Sjdp /* Buffer large enough to hold any input section. */ 49133965Sjdp bfd_byte *contents; 49233965Sjdp /* Buffer large enough to hold external relocs of any input section. */ 49333965Sjdp bfd_byte *external_relocs; 49433965Sjdp /* Buffer large enough to hold swapped relocs of any input section. */ 49533965Sjdp struct internal_reloc *internal_relocs; 49633965Sjdp}; 49733965Sjdp 49860484Sobrien/* Most COFF variants have no way to record the alignment of a 49960484Sobrien section. This struct is used to set a specific alignment based on 50060484Sobrien the name of the section. */ 50160484Sobrien 50260484Sobrienstruct coff_section_alignment_entry 50360484Sobrien{ 50460484Sobrien /* The section name. */ 50560484Sobrien const char *name; 50660484Sobrien 50760484Sobrien /* This is either (unsigned int) -1, indicating that the section 50860484Sobrien name must match exactly, or it is the number of letters which 50960484Sobrien must match at the start of the name. */ 51060484Sobrien unsigned int comparison_length; 51160484Sobrien 51260484Sobrien /* These macros may be used to fill in the first two fields in a 51360484Sobrien structure initialization. */ 51460484Sobrien#define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1) 51560484Sobrien#define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1) 51660484Sobrien 51760484Sobrien /* Only use this entry if the default section alignment for this 51860484Sobrien target is at least that much (as a power of two). If this field 51960484Sobrien is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 52060484Sobrien unsigned int default_alignment_min; 52160484Sobrien 52260484Sobrien /* Only use this entry if the default section alignment for this 52360484Sobrien target is no greater than this (as a power of two). If this 52460484Sobrien field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ 52560484Sobrien unsigned int default_alignment_max; 52660484Sobrien 52760484Sobrien#define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1) 52860484Sobrien 52960484Sobrien /* The desired alignment for this section (as a power of two). */ 53060484Sobrien unsigned int alignment_power; 53160484Sobrien}; 53260484Sobrien 53333965Sjdpextern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc 53433965Sjdp PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 53533965Sjdpextern boolean _bfd_coff_link_hash_table_init 53633965Sjdp PARAMS ((struct coff_link_hash_table *, bfd *, 53733965Sjdp struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 53833965Sjdp struct bfd_hash_table *, 53933965Sjdp const char *))); 54033965Sjdpextern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create 54133965Sjdp PARAMS ((bfd *)); 54233965Sjdpextern const char *_bfd_coff_internal_syment_name 54333965Sjdp PARAMS ((bfd *, const struct internal_syment *, char *)); 54433965Sjdpextern boolean _bfd_coff_link_add_symbols 54533965Sjdp PARAMS ((bfd *, struct bfd_link_info *)); 54633965Sjdpextern boolean _bfd_coff_final_link 54733965Sjdp PARAMS ((bfd *, struct bfd_link_info *)); 54833965Sjdpextern struct internal_reloc *_bfd_coff_read_internal_relocs 54933965Sjdp PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean, 55033965Sjdp struct internal_reloc *)); 55133965Sjdpextern boolean _bfd_coff_generic_relocate_section 55233965Sjdp PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 55333965Sjdp struct internal_reloc *, struct internal_syment *, asection **)); 55433965Sjdp 55533965Sjdpextern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc 55633965Sjdp PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 55733965Sjdpextern boolean _bfd_coff_write_global_sym 55833965Sjdp PARAMS ((struct coff_link_hash_entry *, PTR)); 55938889Sjdpextern boolean _bfd_coff_write_task_globals 56038889Sjdp PARAMS ((struct coff_link_hash_entry *, PTR)); 56133965Sjdpextern boolean _bfd_coff_link_input_bfd 56233965Sjdp PARAMS ((struct coff_final_link_info *, bfd *)); 56333965Sjdpextern boolean _bfd_coff_reloc_link_order 56433965Sjdp PARAMS ((bfd *, struct coff_final_link_info *, asection *, 56533965Sjdp struct bfd_link_order *)); 56633965Sjdp 56733965Sjdp 56833965Sjdp#define coff_get_section_contents_in_window \ 56933965Sjdp _bfd_generic_get_section_contents_in_window 57033965Sjdp 57133965Sjdp/* Functions in xcofflink.c. */ 57233965Sjdp 57389857Sobrienextern long _bfd_xcoff_get_dynamic_symtab_upper_bound 57489857Sobrien PARAMS ((bfd *)); 57533965Sjdpextern long _bfd_xcoff_canonicalize_dynamic_symtab 57633965Sjdp PARAMS ((bfd *, asymbol **)); 57789857Sobrienextern long _bfd_xcoff_get_dynamic_reloc_upper_bound 57889857Sobrien PARAMS ((bfd *)); 57933965Sjdpextern long _bfd_xcoff_canonicalize_dynamic_reloc 58033965Sjdp PARAMS ((bfd *, arelent **, asymbol **)); 58133965Sjdpextern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create 58233965Sjdp PARAMS ((bfd *)); 583104834Sobrienextern void _bfd_xcoff_bfd_link_hash_table_free 584104834Sobrien PARAMS ((struct bfd_link_hash_table *)); 58533965Sjdpextern boolean _bfd_xcoff_bfd_link_add_symbols 58633965Sjdp PARAMS ((bfd *, struct bfd_link_info *)); 58733965Sjdpextern boolean _bfd_xcoff_bfd_final_link 58833965Sjdp PARAMS ((bfd *, struct bfd_link_info *)); 58933965Sjdpextern boolean _bfd_ppc_xcoff_relocate_section 59033965Sjdp PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 59133965Sjdp struct internal_reloc *, struct internal_syment *, asection **)); 59233965Sjdp 59333965Sjdp/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the 59433965Sjdp linker, and so should start with bfd and be declared in bfd.h. */ 59533965Sjdp 59689857Sobrienextern boolean ppc_allocate_toc_section 59789857Sobrien PARAMS ((struct bfd_link_info *)); 59833965Sjdpextern boolean ppc_process_before_allocation 59933965Sjdp PARAMS ((bfd *, struct bfd_link_info *)); 60033965Sjdp 601