Back to index

cell-binutils  2.17cvs20070401
libxcoff.h
Go to the documentation of this file.
00001 /* BFD XCOFF object file private structure.
00002    Copyright 2001, 2002, 2005 Free Software Foundation, Inc.
00003    Written by Tom Rix, Redhat.
00004 
00005    This file is part of BFD, the Binary File Descriptor library.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 #ifndef LIBXCOFF_H
00022 #define LIBXCOFF_H
00023 
00024 /* This is the backend information kept for XCOFF files.  This
00025    structure is constant for a particular backend.  The first element
00026    is the COFF backend data structure, so that XCOFF targets can use
00027    the generic COFF code.  */
00028 
00029 struct xcoff_backend_data_rec
00030 {
00031   /* COFF backend information.  */
00032   bfd_coff_backend_data coff;
00033 
00034   /* Magic number.  */
00035   unsigned short _xcoff_magic_number;
00036 
00037   /* Architecture and machine for coff_set_arch_mach_hook.  */
00038   enum bfd_architecture _xcoff_architecture;
00039   long _xcoff_machine;
00040 
00041   /* Function pointers to xcoff specific swap routines.  */
00042   void (* _xcoff_swap_ldhdr_in) (bfd *, const void *, struct internal_ldhdr *);
00043   void (* _xcoff_swap_ldhdr_out)(bfd *, const struct internal_ldhdr *, void *);
00044   void (* _xcoff_swap_ldsym_in) (bfd *, const void *, struct internal_ldsym *);
00045   void (* _xcoff_swap_ldsym_out)(bfd *, const struct internal_ldsym *, void *);
00046   void (* _xcoff_swap_ldrel_in) (bfd *, const void *, struct internal_ldrel *);
00047   void (* _xcoff_swap_ldrel_out)(bfd *, const struct internal_ldrel *, void *);
00048 
00049   /* Size of the external struct.  */
00050   unsigned int _xcoff_ldhdrsz;
00051   unsigned int _xcoff_ldsymsz;
00052   unsigned int _xcoff_ldrelsz;
00053 
00054   /* Size an entry in a descriptor section.  */
00055   unsigned int _xcoff_function_descriptor_size;
00056 
00057   /* Size of the small aout file header.  */
00058   unsigned int _xcoff_small_aout_header_size;
00059 
00060   /* Loader version
00061      1 : XCOFF32
00062      2 : XCOFF64.  */
00063   unsigned long _xcoff_ldhdr_version;
00064 
00065   bfd_boolean (* _xcoff_put_symbol_name)
00066     (bfd *, struct bfd_strtab_hash *, struct internal_syment *,
00067      const char *);
00068 
00069   bfd_boolean (* _xcoff_put_ldsymbol_name)
00070     (bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
00071      const char *);
00072 
00073   reloc_howto_type *_xcoff_dynamic_reloc;
00074 
00075   asection * (* _xcoff_create_csect_from_smclas)
00076     (bfd *, union internal_auxent *, const char *);
00077 
00078   /* Line number and relocation overflow.
00079      XCOFF32 overflows to another section when the line number or the 
00080      relocation count exceeds 0xffff.  XCOFF64 does not overflow.  */
00081   bfd_boolean (*_xcoff_is_lineno_count_overflow) (bfd *, bfd_vma);
00082   bfd_boolean (*_xcoff_is_reloc_count_overflow)  (bfd *, bfd_vma);
00083 
00084   /* Loader section symbol and relocation table offset
00085      XCOFF32 is after the .loader header
00086      XCOFF64 is offset in .loader header.  */
00087   bfd_vma (*_xcoff_loader_symbol_offset) (bfd *, struct internal_ldhdr *);
00088   bfd_vma (*_xcoff_loader_reloc_offset)  (bfd *, struct internal_ldhdr *);
00089   
00090   /* Global linkage.  The first word of global linkage code must be be 
00091      modified by filling in the correct TOC offset.  */
00092   unsigned long *_xcoff_glink_code;
00093   
00094   /* Size of the global link code in bytes of the xcoff_glink_code table.  */
00095   unsigned long _xcoff_glink_size;
00096 
00097   /* rtinit.  */
00098   unsigned int _xcoff_rtinit_size;
00099   bfd_boolean (*_xcoff_generate_rtinit)
00100     (bfd *, const char *, const char *, bfd_boolean);
00101 };
00102 
00103 /* Look up an entry in an XCOFF link hash table.  */
00104 #define xcoff_link_hash_lookup(table, string, create, copy, follow) \
00105   ((struct xcoff_link_hash_entry *) \
00106    bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
00107                       (follow)))
00108 
00109 /* Traverse an XCOFF link hash table.  */
00110 #define xcoff_link_hash_traverse(table, func, info)                   \
00111   (bfd_link_hash_traverse                                      \
00112    (&(table)->root,                                            \
00113     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),  \
00114     (info)))
00115 
00116 /* Get the XCOFF link hash table from the info structure.  This is
00117    just a cast.  */
00118 #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
00119 
00120 
00121 #define xcoff_backend(abfd) \
00122   ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data)
00123 
00124 #define bfd_xcoff_magic_number(a) ((xcoff_backend (a)->_xcoff_magic_number))
00125 #define bfd_xcoff_architecture(a) ((xcoff_backend (a)->_xcoff_architecture))
00126 #define bfd_xcoff_machine(a)      ((xcoff_backend (a)->_xcoff_machine))
00127 
00128 #define bfd_xcoff_swap_ldhdr_in(a, b, c) \
00129   ((xcoff_backend (a)->_xcoff_swap_ldhdr_in) ((a), (b), (c)))
00130 
00131 #define bfd_xcoff_swap_ldhdr_out(a, b, c) \
00132   ((xcoff_backend (a)->_xcoff_swap_ldhdr_out) ((a), (b), (c)))
00133 
00134 #define bfd_xcoff_swap_ldsym_in(a, b, c) \
00135   ((xcoff_backend (a)->_xcoff_swap_ldsym_in) ((a), (b), (c)))
00136 
00137 #define bfd_xcoff_swap_ldsym_out(a, b, c) \
00138   ((xcoff_backend (a)->_xcoff_swap_ldsym_out) ((a), (b), (c)))
00139 
00140 #define bfd_xcoff_swap_ldrel_in(a, b, c) \
00141   ((xcoff_backend (a)->_xcoff_swap_ldrel_in) ((a), (b), (c)))
00142 
00143 #define bfd_xcoff_swap_ldrel_out(a, b, c) \
00144   ((xcoff_backend (a)->_xcoff_swap_ldrel_out) ((a), (b), (c)))
00145 
00146 #define bfd_xcoff_ldhdrsz(a) ((xcoff_backend (a)->_xcoff_ldhdrsz))
00147 #define bfd_xcoff_ldsymsz(a) ((xcoff_backend (a)->_xcoff_ldsymsz))
00148 #define bfd_xcoff_ldrelsz(a) ((xcoff_backend (a)->_xcoff_ldrelsz))
00149 #define bfd_xcoff_function_descriptor_size(a) \
00150   ((xcoff_backend (a)->_xcoff_function_descriptor_size))
00151 #define bfd_xcoff_small_aout_header_size(a) \
00152   ((xcoff_backend (a)->_xcoff_small_aout_header_size))
00153 
00154 #define bfd_xcoff_ldhdr_version(a) ((xcoff_backend (a)->_xcoff_ldhdr_version))
00155 
00156 #define bfd_xcoff_put_symbol_name(a, b, c, d) \
00157   ((xcoff_backend (a)->_xcoff_put_symbol_name) ((a), (b), (c), (d)))
00158 
00159 #define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \
00160   ((xcoff_backend (a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d)))
00161 
00162 /* Get the XCOFF hash table entries for a BFD.  */
00163 #define obj_xcoff_sym_hashes(bfd) \
00164   ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
00165 
00166 #define bfd_xcoff_dynamic_reloc_howto(a) \
00167    ((xcoff_backend (a)->_xcoff_dynamic_reloc))
00168 
00169 #define bfd_xcoff_create_csect_from_smclas(a, b, c) \
00170    ((xcoff_backend (a)->_xcoff_create_csect_from_smclas((a), (b), (c))))
00171 
00172 #define bfd_xcoff_is_lineno_count_overflow(a, b) \
00173    ((xcoff_backend (a)->_xcoff_is_lineno_count_overflow((a), (b))))
00174 
00175 #define bfd_xcoff_is_reloc_count_overflow(a, b) \
00176    ((xcoff_backend (a)->_xcoff_is_reloc_count_overflow((a), (b))))
00177 
00178 #define bfd_xcoff_loader_symbol_offset(a, b) \
00179  ((xcoff_backend (a)->_xcoff_loader_symbol_offset((a), (b))))
00180 
00181 #define bfd_xcoff_loader_reloc_offset(a, b) \
00182  ((xcoff_backend (a)->_xcoff_loader_reloc_offset((a), (b))))
00183 
00184 #define bfd_xcoff_glink_code(a, b)   ((xcoff_backend (a)->_xcoff_glink_code[(b)]))
00185 #define bfd_xcoff_glink_code_size(a) ((xcoff_backend (a)->_xcoff_glink_size))
00186 
00187 /* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit 
00188    targets.  */
00189 #define bfd_xcoff_is_xcoff64(a) \
00190   (   (0x01EF == (bfd_xcoff_magic_number (a))) \
00191    || (0x01F7 == (bfd_xcoff_magic_number (a))))
00192 
00193 /* Check for the magic number U802TOMAGIC for 32 bit targets.  */
00194 #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number (a)))
00195 
00196 #define bfd_xcoff_rtinit_size(a)              ((xcoff_backend (a)->_xcoff_rtinit_size))
00197 #define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend (a)->_xcoff_generate_rtinit ((a), (b), (c), (d))))
00198 
00199 /* Accessor macros for tdata.  */
00200 #define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power))
00201 #define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power))
00202 
00203 /* xcoff*_ppc_relocate_section macros  */
00204 #define XCOFF_MAX_CALCULATE_RELOCATION (0x1c)
00205 #define XCOFF_MAX_COMPLAIN_OVERFLOW (4)
00206 /* N_ONES produces N one bits, without overflowing machine arithmetic.  */
00207 #ifdef N_ONES
00208 #undef N_ONES
00209 #endif
00210 #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
00211 
00212 #define XCOFF_RELOC_FUNCTION_ARGS \
00213   bfd *, asection *, bfd *, struct internal_reloc *, \
00214   struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \
00215   bfd_vma *relocation, bfd_byte *contents
00216 
00217 #define XCOFF_COMPLAIN_FUNCTION_ARGS \
00218   bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto
00219 
00220 extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
00221   (XCOFF_RELOC_FUNCTION_ARGS);
00222 extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
00223   (XCOFF_COMPLAIN_FUNCTION_ARGS);
00224 
00225 /* Relocation functions */
00226 bfd_boolean xcoff_reloc_type_noop (XCOFF_RELOC_FUNCTION_ARGS);
00227 bfd_boolean xcoff_reloc_type_fail (XCOFF_RELOC_FUNCTION_ARGS);
00228 bfd_boolean xcoff_reloc_type_pos  (XCOFF_RELOC_FUNCTION_ARGS);
00229 bfd_boolean xcoff_reloc_type_neg  (XCOFF_RELOC_FUNCTION_ARGS);
00230 bfd_boolean xcoff_reloc_type_rel  (XCOFF_RELOC_FUNCTION_ARGS);
00231 bfd_boolean xcoff_reloc_type_toc  (XCOFF_RELOC_FUNCTION_ARGS);
00232 bfd_boolean xcoff_reloc_type_ba   (XCOFF_RELOC_FUNCTION_ARGS);
00233 bfd_boolean xcoff_reloc_type_crel (XCOFF_RELOC_FUNCTION_ARGS);
00234 
00235 #endif /* LIBXCOFF_H */