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 / gdb / mipsread.c < prev    next >
C/C++ Source or Header  |  1994-02-03  |  5KB  |  161 lines

  1. /* Read a symbol table in MIPS' format (Third-Eye).
  2.    Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993 Free Software
  3.    Foundation, Inc.
  4.    Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU.  Major work
  5.    by Per Bothner, John Gilmore and Ian Lance Taylor at Cygnus Support.
  6.  
  7. This file is part of GDB.
  8.  
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  22.  
  23. /* Read symbols from an ECOFF file.  Most of the work is done in
  24.    mdebugread.c.  */
  25.  
  26. #include "defs.h"
  27. #include "bfd.h"
  28. #include "symtab.h"
  29. #include "symfile.h"
  30. #include "objfiles.h"
  31. #include "buildsym.h"
  32. #include "stabsread.h"
  33. #include "gdb-stabs.h"
  34.  
  35. #include "coff/sym.h"
  36. #include "coff/internal.h"
  37. #include "coff/ecoff.h"
  38. #include "libcoff.h"        /* Private BFD COFF information.  */
  39. #include "libecoff.h"        /* Private BFD ECOFF information.  */
  40.  
  41. static void
  42. mipscoff_new_init PARAMS ((struct objfile *));
  43.  
  44. static void
  45. mipscoff_symfile_init PARAMS ((struct objfile *));
  46.  
  47. static void
  48. mipscoff_symfile_read PARAMS ((struct objfile *, struct section_offsets *,
  49.                    int));
  50.  
  51. static void
  52. mipscoff_symfile_finish PARAMS ((struct objfile *));
  53.  
  54. static struct section_offsets *
  55. mipscoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
  56.  
  57. /* Initialize anything that needs initializing when a completely new
  58.    symbol file is specified (not just adding some symbols from another
  59.    file, e.g. a shared library).  */
  60.  
  61. extern CORE_ADDR sigtramp_address;
  62.  
  63. static void
  64. mipscoff_new_init (ignore)
  65.      struct objfile *ignore;
  66. {
  67.   sigtramp_address = 0;
  68.   stabsread_new_init ();
  69.   buildsym_new_init ();
  70. }
  71.  
  72. /* Initialize to read a symbol file (nothing to do).  */
  73.  
  74. static void
  75. mipscoff_symfile_init (objfile)
  76.      struct objfile *objfile;
  77. {
  78. }
  79.  
  80. /* Read a symbol file from a file.  */
  81.  
  82. static void
  83. mipscoff_symfile_read (objfile, section_offsets, mainline)
  84.      struct objfile *objfile;
  85.      struct section_offsets *section_offsets;
  86.      int mainline;
  87. {
  88.   bfd *abfd = objfile->obfd;
  89.   struct cleanup * back_to;
  90.  
  91.   init_minimal_symbol_collection ();
  92.   back_to = make_cleanup (discard_minimal_symbols, 0);
  93.  
  94.   /* Now that the executable file is positioned at symbol table,
  95.      process it and define symbols accordingly.  */
  96.  
  97.   if (ecoff_slurp_symbolic_info (abfd) == false)
  98.     error ("Error reading symbol table: %s", bfd_errmsg (bfd_error));
  99.  
  100.   mdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap,
  101.              &ecoff_data (abfd)->debug_info, section_offsets);
  102.  
  103.   /* Install any minimal symbols that have been collected as the current
  104.      minimal symbols for this objfile. */
  105.  
  106.   install_minimal_symbols (objfile);
  107.  
  108.   do_cleanups (back_to);
  109. }
  110.  
  111. /* Perform any local cleanups required when we are done with a
  112.    particular objfile.  */
  113.  
  114. static void
  115. mipscoff_symfile_finish (objfile)
  116.      struct objfile *objfile;
  117. {
  118. }
  119.  
  120. /* Fake up identical offsets for all sections.  */
  121.  
  122. static struct section_offsets *
  123. mipscoff_symfile_offsets (objfile, addr)
  124.      struct objfile *objfile;
  125.      CORE_ADDR addr;
  126. {
  127.   struct section_offsets *section_offsets;
  128.   int i;
  129.  
  130.   objfile->num_sections = SECT_OFF_MAX;
  131.   section_offsets = ((struct section_offsets *)
  132.              obstack_alloc (&objfile->psymbol_obstack,
  133.                     (sizeof (struct section_offsets)
  134.                      + (sizeof (section_offsets->offsets)
  135.                     * (SECT_OFF_MAX - 1)))));
  136.  
  137.   for (i = 0; i < SECT_OFF_MAX; i++)
  138.     ANOFFSET (section_offsets, i) = addr;
  139.  
  140.   return section_offsets;
  141. }
  142.  
  143. /* Initialization */
  144.  
  145. static struct sym_fns ecoff_sym_fns =
  146. {
  147.   bfd_target_ecoff_flavour,
  148.   mipscoff_new_init,        /* sym_new_init: init anything gbl to entire symtab */
  149.   mipscoff_symfile_init,    /* sym_init: read initial info, setup for sym_read() */
  150.   mipscoff_symfile_read,    /* sym_read: read a symbol file into symtab */
  151.   mipscoff_symfile_finish,    /* sym_finish: finished with file, cleanup */
  152.   mipscoff_symfile_offsets,    /* sym_offsets: dummy FIXME til implem sym reloc */
  153.   NULL                /* next: pointer to next struct sym_fns */
  154. };
  155.  
  156. void
  157. _initialize_mipsread ()
  158. {
  159.   add_symtab_fns (&ecoff_sym_fns);
  160. }
  161.