home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gdb-4.12.tar.gz / gdb-4.12.tar / gdb-4.12 / bfd / libecoff.h < prev    next >
C/C++ Source or Header  |  1994-02-03  |  10KB  |  257 lines

  1. /* BFD ECOFF object file private structure.
  2.    Copyright (C) 1993 Free Software Foundation, Inc.
  3.    Written by Ian Lance Taylor, Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "bfdlink.h"
  22.  
  23. #ifndef ECOFF_H
  24. #include "coff/ecoff.h"
  25. #endif
  26.  
  27. /* This is the backend information kept for ECOFF files.  This
  28.    structure is constant for a particular backend.  The first element
  29.    is the COFF backend data structure, so that ECOFF targets can use
  30.    the generic COFF code.  */
  31.  
  32. #define ecoff_backend(abfd) \
  33.   ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
  34.  
  35. struct ecoff_backend_data
  36. {
  37.   /* COFF backend information.  This must be the first field.  */
  38.   bfd_coff_backend_data coff;
  39.   /* Supported architecture.  */
  40.   enum bfd_architecture arch;
  41.   /* Initial portion of armap string.  */
  42.   const char *armap_start;
  43.   /* The page boundary used to align sections in a demand-paged
  44.      executable file.  E.g., 0x1000.  */
  45.   bfd_vma round;
  46.   /* True if the .rdata section is part of the text segment, as on the
  47.      Alpha.  False if .rdata is part of the data segment, as on the
  48.      MIPS.  */
  49.   boolean rdata_in_text;
  50.   /* Bitsize of constructor entries.  */
  51.   unsigned int constructor_bitsize;
  52.   /* Reloc to use for constructor entries.  */
  53.   CONST struct reloc_howto_struct *constructor_reloc;
  54.   /* How to swap debugging information.  */
  55.   struct ecoff_debug_swap debug_swap;
  56.   /* External reloc size.  */
  57.   bfd_size_type external_reloc_size;
  58.   /* Reloc swapping functions.  */
  59.   void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
  60.   void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
  61.   /* Backend reloc tweaking.  */
  62.   void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
  63.                    arelent *));
  64.   void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
  65.                     struct internal_reloc *));
  66.   /* Relocate section contents while linking.  */
  67.   boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
  68.                        bfd *input_bfd, asection *input_section,
  69.                        bfd_byte *contents,
  70.                        PTR external_relocs));
  71. };
  72.  
  73. /* This is the target specific information kept for ECOFF files.  */
  74.  
  75. #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
  76.  
  77. typedef struct ecoff_tdata
  78. {
  79.   /* The reloc file position, set by
  80.      ecoff_compute_section_file_positions.  */
  81.   file_ptr reloc_filepos;
  82.  
  83.   /* The symbol table file position, set by ecoff_mkobject_hook.  */
  84.   file_ptr sym_filepos;
  85.  
  86.   /* The start and end of the text segment.  Only valid for an
  87.      existing file, not for one we are creating.  */
  88.   unsigned long text_start;
  89.   unsigned long text_end;
  90.  
  91.   /* The cached gp value.  This is used when relocating.  */
  92.   bfd_vma gp;
  93.  
  94.   /* The maximum size of objects to optimize using gp.  This is
  95.      typically set by the -G option to the compiler, assembler or
  96.      linker.  */
  97.   int gp_size;
  98.  
  99.   /* The register masks.  When linking, all the masks found in the
  100.      input files are combined into the masks of the output file.
  101.      These are not all used for all targets, but that's OK, because
  102.      the relevant ones are the only ones swapped in and out.  */
  103.   unsigned long gprmask;
  104.   unsigned long fprmask;
  105.   unsigned long cprmask[4];
  106.  
  107.   /* The ECOFF symbolic debugging information.  */
  108.   struct ecoff_debug_info debug_info;
  109.  
  110.   /* The unswapped ECOFF symbolic information.  */
  111.   PTR raw_syments;
  112.  
  113.   /* The canonical BFD symbols.  */
  114.   struct ecoff_symbol_struct *canonical_symbols;
  115.  
  116.   /* A mapping from external symbol numbers to entries in the linker
  117.      hash table, used when linking.  */
  118.   struct ecoff_link_hash_entry **sym_hashes;
  119.  
  120.   /* A mapping from reloc symbol indices to sections, used when
  121.      linking.  */
  122.   asection **symndx_to_section;
  123.  
  124. } ecoff_data_type;
  125.  
  126. /* Each canonical asymbol really looks like this.  */
  127.  
  128. typedef struct ecoff_symbol_struct
  129. {
  130.   /* The actual symbol which the rest of BFD works with */
  131.   asymbol symbol;
  132.  
  133.   /* The fdr for this symbol.  */
  134.   FDR *fdr;
  135.  
  136.   /* true if this is a local symbol rather than an external one.  */
  137.   boolean local;
  138.  
  139.   /* A pointer to the unswapped hidden information for this symbol.
  140.      This is either a struct sym_ext or a struct ext_ext, depending on
  141.      the value of the local field above.  */
  142.   PTR native;
  143. } ecoff_symbol_type;
  144.  
  145. /* We take the address of the first element of a asymbol to ensure that the
  146.    macro is only ever applied to an asymbol.  */
  147. #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
  148.  
  149. /* This is a hack borrowed from coffcode.h; we need to save the index
  150.    of an external symbol when we write it out so that can set the
  151.    symbol index correctly when we write out the relocs.  */
  152. #define ecoff_get_sym_index(symbol) ((unsigned long) (symbol)->udata)
  153. #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
  154.  
  155. /* ECOFF linker hash table entries.  */
  156.  
  157. struct ecoff_link_hash_entry
  158. {
  159.   struct bfd_link_hash_entry root;
  160.   /* Symbol index in output file.  */
  161.   long indx;
  162.   /* BFD that ext field value came from.  */
  163.   bfd *abfd;
  164.   /* ECOFF external symbol information.  */
  165.   EXTR esym;
  166. };
  167.  
  168. /* ECOFF linker hash table.  */
  169.  
  170. struct ecoff_link_hash_table
  171. {
  172.   struct bfd_link_hash_table root;
  173. };
  174.  
  175. /* Make an ECOFF object.  */
  176. extern boolean ecoff_mkobject PARAMS ((bfd *));
  177.  
  178. /* Read in the ECOFF symbolic debugging information.  */
  179. extern boolean ecoff_slurp_symbolic_info PARAMS ((bfd *));
  180.  
  181. /* Generic ECOFF BFD backend vectors.  */
  182. extern asymbol *ecoff_make_empty_symbol PARAMS ((bfd *abfd));
  183. extern unsigned int ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
  184. extern unsigned int ecoff_get_symtab PARAMS ((bfd *abfd,
  185.                           asymbol **alocation));
  186. extern void ecoff_get_symbol_info PARAMS ((bfd *abfd,
  187.                        asymbol *symbol,
  188.                        symbol_info *ret));
  189. extern void ecoff_print_symbol PARAMS ((bfd *abfd, PTR filep,
  190.                     asymbol *symbol,
  191.                     bfd_print_symbol_type how));
  192. extern unsigned int ecoff_canonicalize_reloc PARAMS ((bfd *abfd,
  193.                               asection *section,
  194.                               arelent **relptr,
  195.                               asymbol **symbols));
  196. extern boolean ecoff_find_nearest_line PARAMS ((bfd *abfd,
  197.                         asection *section,
  198.                         asymbol **symbols,
  199.                         bfd_vma offset,
  200.                         CONST char **filename_ptr,
  201.                         CONST char **fnname_ptr,
  202.                         unsigned int *retline_ptr));
  203. extern boolean ecoff_set_arch_mach PARAMS ((bfd *abfd,
  204.                         enum bfd_architecture arch,
  205.                         unsigned long machine));
  206. extern int ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
  207. extern boolean ecoff_set_section_contents PARAMS ((bfd *abfd,
  208.                            asection *section,
  209.                            PTR location,
  210.                            file_ptr offset,
  211.                            bfd_size_type count));
  212. extern boolean ecoff_get_section_contents PARAMS ((bfd *abfd,
  213.                            asection *section,
  214.                            PTR location,
  215.                            file_ptr offset,
  216.                            bfd_size_type count));
  217. extern boolean ecoff_write_object_contents PARAMS ((bfd *abfd));
  218. extern boolean ecoff_slurp_armap PARAMS ((bfd *abfd));
  219. extern boolean ecoff_write_armap PARAMS ((bfd *abfd, unsigned int elength,
  220.                       struct orl *map,
  221.                       unsigned int orl_count,
  222.                       int stridx));
  223. #define ecoff_slurp_extended_name_table    _bfd_slurp_extended_name_table
  224. extern bfd_target *ecoff_archive_p PARAMS ((bfd *abfd));
  225. #define ecoff_get_lineno \
  226.   ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
  227. #define ecoff_truncate_arname        bfd_dont_truncate_arname
  228. #define ecoff_openr_next_archived_file    bfd_generic_openr_next_archived_file
  229. #define ecoff_generic_stat_arch_elt    bfd_generic_stat_arch_elt
  230. #define ecoff_get_reloc_upper_bound    coff_get_reloc_upper_bound
  231. #define    ecoff_close_and_cleanup        bfd_generic_close_and_cleanup
  232. #define ecoff_bfd_debug_info_start    bfd_void
  233. #define ecoff_bfd_debug_info_end    bfd_void
  234. #define ecoff_bfd_debug_info_accumulate    \
  235.   ((void (*) PARAMS ((bfd *, struct sec *))) bfd_void)
  236. #define ecoff_bfd_relax_section        bfd_generic_relax_section
  237. #define ecoff_bfd_make_debug_symbol \
  238.   ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
  239. extern struct bfd_link_hash_table *ecoff_bfd_link_hash_table_create
  240.   PARAMS ((bfd *));
  241. extern boolean ecoff_bfd_link_add_symbols
  242.   PARAMS ((bfd *, struct bfd_link_info *));
  243. extern boolean ecoff_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *));
  244.  
  245. /* Hook functions for the generic COFF section reading code.  */
  246. extern PTR ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
  247. extern asection *ecoff_make_section_hook PARAMS ((bfd *abfd, char *name));
  248. extern boolean ecoff_new_section_hook PARAMS ((bfd *abfd,
  249.                            asection *section));
  250. #define ecoff_set_alignment_hook \
  251.   ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
  252. extern boolean ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
  253. extern long ecoff_sec_to_styp_flags PARAMS ((CONST char *name,
  254.                          flagword flags));
  255. extern flagword ecoff_styp_to_sec_flags PARAMS ((bfd *abfd, PTR hdr));
  256. extern boolean ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
  257.