Back to index

cell-binutils  2.17cvs20070401
libecoff.h
Go to the documentation of this file.
00001 /* BFD ECOFF object file private structure.
00002    Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002, 2003, 2004,
00003    2005, 2006 Free Software Foundation, Inc.
00004    Written by Ian Lance Taylor, Cygnus Support.
00005 
00006    This file is part of BFD, the Binary File Descriptor library.
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00021 
00022 #include "bfdlink.h"
00023 
00024 #ifndef ECOFF_H
00025 #include "coff/ecoff.h"
00026 #endif
00027 
00028 /* This is the backend information kept for ECOFF files.  This
00029    structure is constant for a particular backend.  The first element
00030    is the COFF backend data structure, so that ECOFF targets can use
00031    the generic COFF code.  */
00032 
00033 #define ecoff_backend(abfd) \
00034   ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
00035 
00036 struct ecoff_backend_data
00037 {
00038   /* COFF backend information.  This must be the first field.  */
00039   bfd_coff_backend_data coff;
00040   /* Supported architecture.  */
00041   enum bfd_architecture arch;
00042   /* Initial portion of armap string.  */
00043   const char *armap_start;
00044   /* The page boundary used to align sections in a demand-paged
00045      executable file.  E.g., 0x1000.  */
00046   bfd_vma round;
00047   /* TRUE if the .rdata section is part of the text segment, as on the
00048      Alpha.  FALSE if .rdata is part of the data segment, as on the
00049      MIPS.  */
00050   bfd_boolean rdata_in_text;
00051   /* Bitsize of constructor entries.  */
00052   unsigned int constructor_bitsize;
00053   /* Reloc to use for constructor entries.  */
00054   reloc_howto_type *constructor_reloc;
00055   /* How to swap debugging information.  */
00056   struct ecoff_debug_swap debug_swap;
00057   /* External reloc size.  */
00058   bfd_size_type external_reloc_size;
00059   /* Reloc swapping functions.  */
00060   void (*swap_reloc_in) (bfd *, void *, struct internal_reloc *);
00061   void (*swap_reloc_out) (bfd *, const struct internal_reloc *, void *);
00062   /* Backend reloc tweaking.  */
00063   void (*adjust_reloc_in)
00064     (bfd *, const struct internal_reloc *, arelent *);
00065   void (*adjust_reloc_out)
00066     (bfd *, const arelent *, struct internal_reloc *);
00067   /* Relocate section contents while linking.  */
00068   bfd_boolean (*relocate_section)
00069     (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, void *);
00070   /* Do final adjustments to filehdr and aouthdr.  */
00071   bfd_boolean (*adjust_headers)
00072     (bfd *, struct internal_filehdr *, struct internal_aouthdr *);
00073   /* Read an element from an archive at a given file position.  This
00074      is needed because OSF/1 3.2 uses a weird archive format.  */
00075   bfd *(*get_elt_at_filepos) (bfd *, file_ptr);
00076 };
00077 
00078 /* This is the target specific information kept for ECOFF files.  */
00079 
00080 #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
00081 
00082 typedef struct ecoff_tdata
00083 {
00084   /* The reloc file position, set by
00085      ecoff_compute_section_file_positions.  */
00086   file_ptr reloc_filepos;
00087 
00088   /* The symbol table file position, set by _bfd_ecoff_mkobject_hook.  */
00089   file_ptr sym_filepos;
00090 
00091   /* The start and end of the text segment.  Only valid for an
00092      existing file, not for one we are creating.  */
00093   unsigned long text_start;
00094   unsigned long text_end;
00095 
00096   /* The cached gp value.  This is used when relocating.  */
00097   bfd_vma gp;
00098 
00099   /* The maximum size of objects to optimize using gp.  This is
00100      typically set by the -G option to the compiler, assembler or
00101      linker.  */
00102   unsigned int gp_size;
00103 
00104   /* The register masks.  When linking, all the masks found in the
00105      input files are combined into the masks of the output file.
00106      These are not all used for all targets, but that's OK, because
00107      the relevant ones are the only ones swapped in and out.  */
00108   unsigned long gprmask;
00109   unsigned long fprmask;
00110   unsigned long cprmask[4];
00111 
00112   /* The ECOFF symbolic debugging information.  */
00113   struct ecoff_debug_info debug_info;
00114 
00115   /* The unswapped ECOFF symbolic information.  */
00116   void * raw_syments;
00117 
00118   /* The canonical BFD symbols.  */
00119   struct ecoff_symbol_struct *canonical_symbols;
00120 
00121   /* A mapping from external symbol numbers to entries in the linker
00122      hash table, used when linking.  */
00123   struct ecoff_link_hash_entry **sym_hashes;
00124 
00125   /* A mapping from reloc symbol indices to sections, used when
00126      linking.  */
00127   asection **symndx_to_section;
00128 
00129   /* TRUE if this BFD was written by the backend linker.  */
00130   bfd_boolean linker;
00131 
00132   /* TRUE if a warning that multiple global pointer values are
00133      needed in the output binary was issued already.  */
00134   bfd_boolean issued_multiple_gp_warning;
00135 
00136   /* Used by find_nearest_line entry point.  The structure could be
00137      included directly in this one, but there's no point to wasting
00138      the memory just for the infrequently called find_nearest_line.  */
00139   struct ecoff_find_line *find_line_info;
00140 
00141   /* Whether the .rdata section is in the text segment for this
00142      particular ECOFF file.  This is not valid until
00143      ecoff_compute_section_file_positions is called.  */
00144   bfd_boolean rdata_in_text;
00145 
00146 } ecoff_data_type;
00147 
00148 /* Each canonical asymbol really looks like this.  */
00149 
00150 typedef struct ecoff_symbol_struct
00151 {
00152   /* The actual symbol which the rest of BFD works with */
00153   asymbol symbol;
00154 
00155   /* The fdr for this symbol.  */
00156   FDR *fdr;
00157 
00158   /* TRUE if this is a local symbol rather than an external one.  */
00159   bfd_boolean local;
00160 
00161   /* A pointer to the unswapped hidden information for this symbol.
00162      This is either a struct sym_ext or a struct ext_ext, depending on
00163      the value of the local field above.  */
00164   void * native;
00165 } ecoff_symbol_type;
00166 
00167 /* We take the address of the first element of an asymbol to ensure that the
00168    macro is only ever applied to an asymbol.  */
00169 #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
00170 
00171 /* We need to save the index of an external symbol when we write it
00172    out so that can set the symbol index correctly when we write out
00173    the relocs.  */
00174 #define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
00175 #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
00176 
00177 /* A pointer to this structure is put in the used_by_bfd pointer of
00178    a section to keep track of any per-section data.
00179    The user_by_bfd pointer will be NULL if the information was not
00180    needed.  */
00181 
00182 struct ecoff_section_tdata
00183 {
00184   /* When producing an executable (i.e., final, non-relocatable link)
00185      on the Alpha, we may need to use multiple global pointer values
00186      to span the entire .lita section.  In essence, we allow each
00187      input .lita section to have its own gp value.  To support this,
00188      we need to keep track of the gp values that we picked for each
00189      input .lita section . */
00190   bfd_vma gp;
00191 };
00192 
00193 /* An accessor macro for the ecoff_section_tdata structure.  */
00194 #define ecoff_section_data(abfd, sec) \
00195   ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
00196 
00197 /* ECOFF linker hash table entries.  */
00198 
00199 struct ecoff_link_hash_entry
00200 {
00201   struct bfd_link_hash_entry root;
00202   /* Symbol index in output file.  */
00203   long indx;
00204   /* BFD that ext field value came from.  */
00205   bfd *abfd;
00206   /* ECOFF external symbol information.  */
00207   EXTR esym;
00208   /* Nonzero if this symbol has been written out.  */
00209   char written;
00210   /* Nonzero if this symbol was referred to as small undefined.  */
00211   char small;
00212 };
00213 
00214 /* ECOFF linker hash table.  */
00215 
00216 struct ecoff_link_hash_table
00217 {
00218   struct bfd_link_hash_table root;
00219 };
00220 
00221 /* Make an ECOFF object.  */
00222 extern bfd_boolean _bfd_ecoff_mkobject (bfd *);
00223 
00224 /* Read in the ECOFF symbolic debugging information.  */
00225 extern bfd_boolean _bfd_ecoff_slurp_symbolic_info
00226   (bfd *, asection *, struct ecoff_debug_info *);
00227 
00228 /* Generic ECOFF BFD backend vectors.  */
00229 
00230 extern bfd_boolean _bfd_ecoff_write_object_contents (bfd *);
00231 extern const bfd_target *_bfd_ecoff_archive_p (bfd *);
00232 
00233 #define       _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
00234 #define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
00235 extern bfd_boolean _bfd_ecoff_new_section_hook
00236   (bfd *, asection *);
00237 extern bfd_boolean _bfd_ecoff_get_section_contents
00238   (bfd *, asection *, void * location, file_ptr, bfd_size_type);
00239 
00240 #define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
00241 
00242 extern bfd_boolean _bfd_ecoff_bfd_copy_private_bfd_data
00243   (bfd *, bfd *);
00244 #define _bfd_ecoff_bfd_copy_private_section_data \
00245   _bfd_generic_bfd_copy_private_section_data
00246 
00247 #define _bfd_ecoff_bfd_copy_private_symbol_data \
00248   _bfd_generic_bfd_copy_private_symbol_data
00249 
00250 #define _bfd_ecoff_bfd_copy_private_header_data \
00251   _bfd_generic_bfd_copy_private_header_data
00252 
00253 #define _bfd_ecoff_bfd_print_private_bfd_data \
00254   _bfd_generic_bfd_print_private_bfd_data
00255 
00256 #define _bfd_ecoff_bfd_merge_private_bfd_data \
00257   _bfd_generic_bfd_merge_private_bfd_data
00258 
00259 #define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
00260 extern bfd_boolean _bfd_ecoff_slurp_armap (bfd *);
00261 #define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
00262 #define _bfd_ecoff_construct_extended_name_table \
00263   _bfd_archive_bsd_construct_extended_name_table
00264 #define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
00265 extern bfd_boolean _bfd_ecoff_write_armap
00266   (bfd *, unsigned int, struct orl *, unsigned int, int);
00267 #define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
00268 #define _bfd_ecoff_openr_next_archived_file \
00269   bfd_generic_openr_next_archived_file
00270 #define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
00271 #define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
00272 #define _bfd_ecoff_update_armap_timestamp bfd_true
00273 #define _bfd_ecoff_bfd_is_target_special_symbol  \
00274   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
00275 
00276 extern long _bfd_ecoff_get_symtab_upper_bound (bfd *);
00277 extern long _bfd_ecoff_canonicalize_symtab (bfd *, asymbol **);
00278 extern asymbol *_bfd_ecoff_make_empty_symbol (bfd *);
00279 extern void _bfd_ecoff_print_symbol
00280   (bfd *, void *, asymbol *, bfd_print_symbol_type);
00281 extern void _bfd_ecoff_get_symbol_info
00282   (bfd *, asymbol *, symbol_info *);
00283 extern bfd_boolean _bfd_ecoff_bfd_is_local_label_name
00284   (bfd *, const char *);
00285 #define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
00286 extern bfd_boolean _bfd_ecoff_find_nearest_line
00287   (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **,
00288    unsigned int *);
00289 #define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
00290 #define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
00291 #define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
00292 #define _bfd_ecoff_find_inliner_info _bfd_nosymbols_find_inliner_info
00293 
00294 #define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
00295 extern long _bfd_ecoff_canonicalize_reloc
00296   (bfd *, asection *, arelent **, asymbol **symbols);
00297 /* ecoff_bfd_reloc_type_lookup defined by backend. */
00298 
00299 extern bfd_boolean _bfd_ecoff_set_arch_mach
00300   (bfd *, enum bfd_architecture, unsigned long);
00301 extern bfd_boolean _bfd_ecoff_set_section_contents
00302   (bfd *, asection *, const void * location, file_ptr, bfd_size_type);
00303 
00304 extern int _bfd_ecoff_sizeof_headers (bfd *, struct bfd_link_info *);
00305 /* ecoff_bfd_get_relocated_section_contents defined by backend.  */
00306 /* ecoff_bfd_relax_section defined by backend.  */
00307 extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
00308   (bfd *);
00309 #define _bfd_ecoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
00310 extern bfd_boolean _bfd_ecoff_bfd_link_add_symbols
00311   (bfd *, struct bfd_link_info *);
00312 #define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms
00313 extern bfd_boolean _bfd_ecoff_bfd_final_link
00314   (bfd *, struct bfd_link_info *);
00315 
00316 /* Hook functions for the generic COFF section reading code.  */
00317 
00318 extern void * _bfd_ecoff_mkobject_hook (bfd *, void *, void *);
00319 #define _bfd_ecoff_set_alignment_hook \
00320   ((void (*) (bfd *, asection *, void *)) bfd_void)
00321 extern bfd_boolean _bfd_ecoff_set_arch_mach_hook
00322   (bfd *, void *);
00323 extern bfd_boolean _bfd_ecoff_styp_to_sec_flags
00324   (bfd *, void *, const char *, asection *, flagword *);
00325 extern bfd_boolean _bfd_ecoff_slurp_symbol_table (bfd *);
00326 
00327 /* ECOFF auxiliary information swapping routines.  These are the same
00328    for all ECOFF targets, so they are defined in ecofflink.c.  */
00329 
00330 extern void _bfd_ecoff_swap_tir_in
00331   (int, const struct tir_ext *, TIR *);
00332 extern void _bfd_ecoff_swap_tir_out
00333   (int, const TIR *, struct tir_ext *);
00334 extern void _bfd_ecoff_swap_rndx_in
00335   (int, const struct rndx_ext *, RNDXR *);
00336 extern void _bfd_ecoff_swap_rndx_out
00337   (int, const RNDXR *, struct rndx_ext *);