1*d2201f2fSdrahn /* BFD XCOFF object file private structure. 2*d2201f2fSdrahn Copyright 2001, 2002 Free Software Foundation, Inc. 3*d2201f2fSdrahn Written by Tom Rix, Redhat. 4*d2201f2fSdrahn 5*d2201f2fSdrahn This file is part of BFD, the Binary File Descriptor library. 6*d2201f2fSdrahn 7*d2201f2fSdrahn This program is free software; you can redistribute it and/or modify 8*d2201f2fSdrahn it under the terms of the GNU General Public License as published by 9*d2201f2fSdrahn the Free Software Foundation; either version 2 of the License, or 10*d2201f2fSdrahn (at your option) any later version. 11*d2201f2fSdrahn 12*d2201f2fSdrahn This program is distributed in the hope that it will be useful, 13*d2201f2fSdrahn but WITHOUT ANY WARRANTY; without even the implied warranty of 14*d2201f2fSdrahn MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*d2201f2fSdrahn GNU General Public License for more details. 16*d2201f2fSdrahn 17*d2201f2fSdrahn You should have received a copy of the GNU General Public License 18*d2201f2fSdrahn along with this program; if not, write to the Free Software 19*d2201f2fSdrahn Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20*d2201f2fSdrahn 21*d2201f2fSdrahn #ifndef LIBXCOFF_H 22*d2201f2fSdrahn #define LIBXCOFF_H 23*d2201f2fSdrahn 24*d2201f2fSdrahn /* This is the backend information kept for XCOFF files. This 25*d2201f2fSdrahn structure is constant for a particular backend. The first element 26*d2201f2fSdrahn is the COFF backend data structure, so that XCOFF targets can use 27*d2201f2fSdrahn the generic COFF code. */ 28*d2201f2fSdrahn 29*d2201f2fSdrahn struct xcoff_backend_data_rec 30*d2201f2fSdrahn { 31*d2201f2fSdrahn /* COFF backend information. */ 32*d2201f2fSdrahn bfd_coff_backend_data coff; 33*d2201f2fSdrahn 34*d2201f2fSdrahn /* Magic number. */ 35*d2201f2fSdrahn unsigned short _xcoff_magic_number; 36*d2201f2fSdrahn 37*d2201f2fSdrahn /* Architecture and machine for coff_set_arch_mach_hook. */ 38*d2201f2fSdrahn enum bfd_architecture _xcoff_architecture; 39*d2201f2fSdrahn long _xcoff_machine; 40*d2201f2fSdrahn 41*d2201f2fSdrahn /* Function pointers to xcoff specific swap routines. */ 42*d2201f2fSdrahn void (* _xcoff_swap_ldhdr_in) 43*d2201f2fSdrahn PARAMS ((bfd *, const PTR, struct internal_ldhdr *)); 44*d2201f2fSdrahn void (* _xcoff_swap_ldhdr_out) 45*d2201f2fSdrahn PARAMS ((bfd *, const struct internal_ldhdr *, PTR)); 46*d2201f2fSdrahn void (* _xcoff_swap_ldsym_in) 47*d2201f2fSdrahn PARAMS ((bfd *, const PTR, struct internal_ldsym *)); 48*d2201f2fSdrahn void (* _xcoff_swap_ldsym_out) 49*d2201f2fSdrahn PARAMS ((bfd *, const struct internal_ldsym *, PTR)); 50*d2201f2fSdrahn void (* _xcoff_swap_ldrel_in) 51*d2201f2fSdrahn PARAMS ((bfd *, const PTR, struct internal_ldrel *)); 52*d2201f2fSdrahn void (* _xcoff_swap_ldrel_out) 53*d2201f2fSdrahn PARAMS ((bfd *, const struct internal_ldrel *, PTR)); 54*d2201f2fSdrahn 55*d2201f2fSdrahn /* Size of the external struct. */ 56*d2201f2fSdrahn unsigned int _xcoff_ldhdrsz; 57*d2201f2fSdrahn unsigned int _xcoff_ldsymsz; 58*d2201f2fSdrahn unsigned int _xcoff_ldrelsz; 59*d2201f2fSdrahn 60*d2201f2fSdrahn /* Size an entry in a descriptor section. */ 61*d2201f2fSdrahn unsigned int _xcoff_function_descriptor_size; 62*d2201f2fSdrahn 63*d2201f2fSdrahn /* Size of the small aout file header. */ 64*d2201f2fSdrahn unsigned int _xcoff_small_aout_header_size; 65*d2201f2fSdrahn 66*d2201f2fSdrahn /* Loader version 67*d2201f2fSdrahn 1 : XCOFF32 68*d2201f2fSdrahn 2 : XCOFF64. */ 69*d2201f2fSdrahn unsigned long _xcoff_ldhdr_version; 70*d2201f2fSdrahn 71*d2201f2fSdrahn bfd_boolean (* _xcoff_put_symbol_name) 72*d2201f2fSdrahn PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *, 73*d2201f2fSdrahn const char *)); 74*d2201f2fSdrahn 75*d2201f2fSdrahn bfd_boolean (* _xcoff_put_ldsymbol_name) 76*d2201f2fSdrahn PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *, 77*d2201f2fSdrahn const char *)); 78*d2201f2fSdrahn 79*d2201f2fSdrahn reloc_howto_type *_xcoff_dynamic_reloc; 80*d2201f2fSdrahn 81*d2201f2fSdrahn asection * (* _xcoff_create_csect_from_smclas) 82*d2201f2fSdrahn PARAMS ((bfd *, union internal_auxent *, const char *)); 83*d2201f2fSdrahn 84*d2201f2fSdrahn /* Line number and relocation overflow. 85*d2201f2fSdrahn XCOFF32 overflows to another section when the line number or the 86*d2201f2fSdrahn relocation count exceeds 0xffff. XCOFF64 does not overflow. */ 87*d2201f2fSdrahn bfd_boolean (*_xcoff_is_lineno_count_overflow) 88*d2201f2fSdrahn PARAMS ((bfd *, bfd_vma)); 89*d2201f2fSdrahn bfd_boolean (*_xcoff_is_reloc_count_overflow) 90*d2201f2fSdrahn PARAMS ((bfd *, bfd_vma)); 91*d2201f2fSdrahn 92*d2201f2fSdrahn /* Loader section symbol and relocation table offset 93*d2201f2fSdrahn XCOFF32 is after the .loader header 94*d2201f2fSdrahn XCOFF64 is offset in .loader header. */ 95*d2201f2fSdrahn bfd_vma (*_xcoff_loader_symbol_offset) 96*d2201f2fSdrahn PARAMS ((bfd *, struct internal_ldhdr *)); 97*d2201f2fSdrahn bfd_vma (*_xcoff_loader_reloc_offset) 98*d2201f2fSdrahn PARAMS ((bfd *, struct internal_ldhdr *)); 99*d2201f2fSdrahn 100*d2201f2fSdrahn /* Global linkage. The first word of global linkage code must be be 101*d2201f2fSdrahn modified by filling in the correct TOC offset. */ 102*d2201f2fSdrahn unsigned long *_xcoff_glink_code; 103*d2201f2fSdrahn 104*d2201f2fSdrahn /* Size of the global link code in bytes of the xcoff_glink_code table. */ 105*d2201f2fSdrahn unsigned long _xcoff_glink_size; 106*d2201f2fSdrahn 107*d2201f2fSdrahn /* rtinit. */ 108*d2201f2fSdrahn unsigned int _xcoff_rtinit_size; 109*d2201f2fSdrahn bfd_boolean (*_xcoff_generate_rtinit) 110*d2201f2fSdrahn PARAMS ((bfd *, const char *, const char *, bfd_boolean)); 111*d2201f2fSdrahn }; 112*d2201f2fSdrahn 113*d2201f2fSdrahn /* Look up an entry in an XCOFF link hash table. */ 114*d2201f2fSdrahn #define xcoff_link_hash_lookup(table, string, create, copy, follow) \ 115*d2201f2fSdrahn ((struct xcoff_link_hash_entry *) \ 116*d2201f2fSdrahn bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\ 117*d2201f2fSdrahn (follow))) 118*d2201f2fSdrahn 119*d2201f2fSdrahn /* Traverse an XCOFF link hash table. */ 120*d2201f2fSdrahn #define xcoff_link_hash_traverse(table, func, info) \ 121*d2201f2fSdrahn (bfd_link_hash_traverse \ 122*d2201f2fSdrahn (&(table)->root, \ 123*d2201f2fSdrahn (bfd_boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ 124*d2201f2fSdrahn (info))) 125*d2201f2fSdrahn 126*d2201f2fSdrahn /* Get the XCOFF link hash table from the info structure. This is 127*d2201f2fSdrahn just a cast. */ 128*d2201f2fSdrahn #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash)) 129*d2201f2fSdrahn 130*d2201f2fSdrahn 131*d2201f2fSdrahn #define xcoff_backend(abfd) \ 132*d2201f2fSdrahn ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data) 133*d2201f2fSdrahn 134*d2201f2fSdrahn #define bfd_xcoff_magic_number(a) ((xcoff_backend(a)->_xcoff_magic_number)) 135*d2201f2fSdrahn #define bfd_xcoff_architecture(a) ((xcoff_backend(a)->_xcoff_architecture)) 136*d2201f2fSdrahn #define bfd_xcoff_machine(a) ((xcoff_backend(a)->_xcoff_machine)) 137*d2201f2fSdrahn 138*d2201f2fSdrahn #define bfd_xcoff_swap_ldhdr_in(a, b, c) \ 139*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_swap_ldhdr_in) ((a), (b), (c))) 140*d2201f2fSdrahn 141*d2201f2fSdrahn #define bfd_xcoff_swap_ldhdr_out(a, b, c) \ 142*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_swap_ldhdr_out) ((a), (b), (c))) 143*d2201f2fSdrahn 144*d2201f2fSdrahn #define bfd_xcoff_swap_ldsym_in(a, b, c) \ 145*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_swap_ldsym_in) ((a), (b), (c))) 146*d2201f2fSdrahn 147*d2201f2fSdrahn #define bfd_xcoff_swap_ldsym_out(a, b, c) \ 148*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_swap_ldsym_out) ((a), (b), (c))) 149*d2201f2fSdrahn 150*d2201f2fSdrahn #define bfd_xcoff_swap_ldrel_in(a, b, c) \ 151*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_swap_ldrel_in) ((a), (b), (c))) 152*d2201f2fSdrahn 153*d2201f2fSdrahn #define bfd_xcoff_swap_ldrel_out(a, b, c) \ 154*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_swap_ldrel_out) ((a), (b), (c))) 155*d2201f2fSdrahn 156*d2201f2fSdrahn #define bfd_xcoff_ldhdrsz(a) ((xcoff_backend(a)->_xcoff_ldhdrsz)) 157*d2201f2fSdrahn #define bfd_xcoff_ldsymsz(a) ((xcoff_backend(a)->_xcoff_ldsymsz)) 158*d2201f2fSdrahn #define bfd_xcoff_ldrelsz(a) ((xcoff_backend(a)->_xcoff_ldrelsz)) 159*d2201f2fSdrahn #define bfd_xcoff_function_descriptor_size(a) \ 160*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_function_descriptor_size)) 161*d2201f2fSdrahn #define bfd_xcoff_small_aout_header_size(a) \ 162*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_small_aout_header_size)) 163*d2201f2fSdrahn 164*d2201f2fSdrahn #define bfd_xcoff_ldhdr_version(a) ((xcoff_backend(a)->_xcoff_ldhdr_version)) 165*d2201f2fSdrahn 166*d2201f2fSdrahn #define bfd_xcoff_put_symbol_name(a, b, c, d) \ 167*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_put_symbol_name) ((a), (b), (c), (d))) 168*d2201f2fSdrahn 169*d2201f2fSdrahn #define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \ 170*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d))) 171*d2201f2fSdrahn 172*d2201f2fSdrahn /* Get the XCOFF hash table entries for a BFD. */ 173*d2201f2fSdrahn #define obj_xcoff_sym_hashes(bfd) \ 174*d2201f2fSdrahn ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd)) 175*d2201f2fSdrahn 176*d2201f2fSdrahn #define bfd_xcoff_dynamic_reloc_howto(a) \ 177*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_dynamic_reloc)) 178*d2201f2fSdrahn 179*d2201f2fSdrahn #define bfd_xcoff_create_csect_from_smclas(a, b, c) \ 180*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_create_csect_from_smclas((a), (b), (c)))) 181*d2201f2fSdrahn 182*d2201f2fSdrahn #define bfd_xcoff_is_lineno_count_overflow(a, b) \ 183*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_is_lineno_count_overflow((a), (b)))) 184*d2201f2fSdrahn 185*d2201f2fSdrahn #define bfd_xcoff_is_reloc_count_overflow(a, b) \ 186*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_is_reloc_count_overflow((a), (b)))) 187*d2201f2fSdrahn 188*d2201f2fSdrahn #define bfd_xcoff_loader_symbol_offset(a, b) \ 189*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_loader_symbol_offset((a), (b)))) 190*d2201f2fSdrahn 191*d2201f2fSdrahn #define bfd_xcoff_loader_reloc_offset(a, b) \ 192*d2201f2fSdrahn ((xcoff_backend(a)->_xcoff_loader_reloc_offset((a), (b)))) 193*d2201f2fSdrahn 194*d2201f2fSdrahn #define bfd_xcoff_glink_code(a, b) ((xcoff_backend(a)->_xcoff_glink_code[(b)])) 195*d2201f2fSdrahn #define bfd_xcoff_glink_code_size(a) ((xcoff_backend(a)->_xcoff_glink_size)) 196*d2201f2fSdrahn 197*d2201f2fSdrahn /* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit 198*d2201f2fSdrahn targets. */ 199*d2201f2fSdrahn #define bfd_xcoff_is_xcoff64(a) \ 200*d2201f2fSdrahn ( (0x01EF == (bfd_xcoff_magic_number(a))) \ 201*d2201f2fSdrahn || (0x01F7 == (bfd_xcoff_magic_number(a)))) 202*d2201f2fSdrahn 203*d2201f2fSdrahn /* Check for the magic number U802TOMAGIC for 32 bit targets. */ 204*d2201f2fSdrahn #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number(a))) 205*d2201f2fSdrahn 206*d2201f2fSdrahn #define bfd_xcoff_rtinit_size(a) ((xcoff_backend(a)->_xcoff_rtinit_size)) 207*d2201f2fSdrahn #define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend(a)->_xcoff_generate_rtinit ((a), (b), (c), (d)))) 208*d2201f2fSdrahn 209*d2201f2fSdrahn /* Accessor macros for tdata. */ 210*d2201f2fSdrahn #define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power)) 211*d2201f2fSdrahn #define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power)) 212*d2201f2fSdrahn 213*d2201f2fSdrahn /* xcoff*_ppc_relocate_section macros */ 214*d2201f2fSdrahn #define XCOFF_MAX_CALCULATE_RELOCATION (0x1c) 215*d2201f2fSdrahn #define XCOFF_MAX_COMPLAIN_OVERFLOW (4) 216*d2201f2fSdrahn /* N_ONES produces N one bits, without overflowing machine arithmetic. */ 217*d2201f2fSdrahn #ifdef N_ONES 218*d2201f2fSdrahn #undef N_ONES 219*d2201f2fSdrahn #endif 220*d2201f2fSdrahn #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1) 221*d2201f2fSdrahn 222*d2201f2fSdrahn #define XCOFF_RELOC_FUNCTION_ARGS \ 223*d2201f2fSdrahn bfd *, asection *, bfd *, struct internal_reloc *, \ 224*d2201f2fSdrahn struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \ 225*d2201f2fSdrahn bfd_vma *relocation, bfd_byte *contents 226*d2201f2fSdrahn 227*d2201f2fSdrahn #define XCOFF_COMPLAIN_FUNCTION_ARGS \ 228*d2201f2fSdrahn bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto 229*d2201f2fSdrahn 230*d2201f2fSdrahn extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION]) 231*d2201f2fSdrahn PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 232*d2201f2fSdrahn extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW]) 233*d2201f2fSdrahn PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)); 234*d2201f2fSdrahn 235*d2201f2fSdrahn /* Relocation functions */ 236*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_noop PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 237*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_fail PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 238*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_pos PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 239*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_neg PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 240*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_rel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 241*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_toc PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 242*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_ba PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 243*d2201f2fSdrahn bfd_boolean xcoff_reloc_type_crel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); 244*d2201f2fSdrahn 245*d2201f2fSdrahn #endif /* LIBXCOFF_H */ 246