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