Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / os9kread.c
index 6577b6570a1d315a9fc09a9d260d23d06e796fde..0ca4d456cf007baebc1b514e47f7d63227536ba7 100644 (file)
@@ -1,22 +1,24 @@
 /* Read os9/os9k symbol tables and convert to internal format, for GDB.
 /* Read os9/os9k symbol tables and convert to internal format, for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    Free Software Foundation, Inc.
 
-This file is part of GDB.
+   This file is part of GDB.
 
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 /* This module provides three functions: os9k_symfile_init,
    which initializes to read a symbol file; os9k_new_init, which 
 
 /* This module provides three functions: os9k_symfile_init,
    which initializes to read a symbol file; os9k_new_init, which 
@@ -33,7 +35,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    for real.  os9k_psymtab_to_symtab() is the function that does this */
 
 #include "defs.h"
    for real.  os9k_psymtab_to_symtab() is the function that does this */
 
 #include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
+#include "gdb_assert.h"
 #include <stdio.h>
 
 #if defined(USG) || defined(__CYGNUSCLIB__)
 #include <stdio.h>
 
 #if defined(USG) || defined(__CYGNUSCLIB__)
@@ -41,20 +44,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <fcntl.h>
 #endif
 
 #include <fcntl.h>
 #endif
 
-#include <obstack.h>
-#include <sys/param.h>
-#ifndef        NO_SYS_FILE
-#include <sys/file.h>
-#endif
-#include <sys/stat.h>
+#include "obstack.h"
+#include "gdb_stat.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "breakpoint.h"
 #include "command.h"
 #include "target.h"
 #include "gdbcore.h"           /* for bfd stuff */
 #include <ctype.h>
 #include "symtab.h"
 #include "breakpoint.h"
 #include "command.h"
 #include "target.h"
 #include "gdbcore.h"           /* for bfd stuff */
-#include "libbfd.h"            /* FIXME Secret internal BFD stuff (bfd_read) */
-#include "libaout.h"           /* FIXME Secret internal BFD stuff for a.out */
+#include "libaout.h"           /* FIXME Secret internal BFD stuff for a.out */
 #include "symfile.h"
 #include "objfiles.h"
 #include "buildsym.h"
 #include "symfile.h"
 #include "objfiles.h"
 #include "buildsym.h"
@@ -65,10 +63,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "os9k.h"
 #include "stabsread.h"
 
 #include "os9k.h"
 #include "stabsread.h"
 
-#if !defined (SEEK_SET)
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#endif
+extern void _initialize_os9kread (void);
 
 /* Each partial symbol table entry contains a pointer to private data for the
    read_symtab() function to use when expanding a partial symbol table entry
 
 /* Each partial symbol table entry contains a pointer to private data for the
    read_symtab() function to use when expanding a partial symbol table entry
@@ -86,10 +81,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
 #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum)
 
 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
 #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum)
 
-struct symloc {
-  int ldsymoff;
-  int ldsymnum;
-};
+struct symloc
+  {
+    int ldsymoff;
+    int ldsymnum;
+  };
 
 /* Remember what we deduced to be the source language of this psymtab. */
 static enum language psymtab_language = language_unknown;
 
 /* Remember what we deduced to be the source language of this psymtab. */
 static enum language psymtab_language = language_unknown;
@@ -105,9 +101,6 @@ extern int info_verbose;
 
 extern int previous_stab_code;
 
 
 extern int previous_stab_code;
 
-/* The BFD for this file -- implicit parameter to next_symbol_text.  */
-static bfd *symfile_bfd;
-
 /* Name of last function encountered.  Used in Solaris to approximate
    object file boundaries.  */
 static char *last_function_name;
 /* Name of last function encountered.  Used in Solaris to approximate
    object file boundaries.  */
 static char *last_function_name;
@@ -125,63 +118,51 @@ extern struct complaint repeated_header_complaint;
 
 extern struct complaint repeated_header_name_complaint;
 
 
 extern struct complaint repeated_header_name_complaint;
 
+#if 0
 static struct complaint lbrac_unmatched_complaint =
 static struct complaint lbrac_unmatched_complaint =
-  {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
+{"unmatched Increment Block Entry before symtab pos %d", 0, 0};
 
 static struct complaint lbrac_mismatch_complaint =
 
 static struct complaint lbrac_mismatch_complaint =
-  {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
-
+{"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
+#endif
 \f
 /* Local function prototypes */
 \f
 /* Local function prototypes */
-static void
-os9k_read_ofile_symtab PARAMS ((struct partial_symtab *));
 
 
-static void
-os9k_psymtab_to_symtab PARAMS ((struct partial_symtab *));
+static void read_minimal_symbols (struct objfile *);
 
 
-static void
-os9k_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *));
+static void os9k_read_ofile_symtab (struct partial_symtab *);
 
 
-static void
-read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *,
-                         CORE_ADDR, int));
+static void os9k_psymtab_to_symtab (struct partial_symtab *);
 
 
-static void
-init_psymbol_list PARAMS ((struct objfile *));
+static void os9k_psymtab_to_symtab_1 (struct partial_symtab *);
 
 
-static char *
-os9k_next_symbol_text PARAMS ((void));
+static void read_os9k_psymtab (struct objfile *, CORE_ADDR, int);
 
 
-static int
-fill_sym PARAMS ((FILE *, bfd *));
+static int fill_sym (FILE *, bfd *);
 
 
-static void
-os9k_symfile_init PARAMS ((struct objfile *));
+static void os9k_symfile_init (struct objfile *);
 
 
-static void
-os9k_new_init PARAMS ((struct objfile *));
+static void os9k_new_init (struct objfile *);
 
 
-static void
-os9k_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));
+static void os9k_symfile_read (struct objfile *, int);
 
 
-static void
-os9k_symfile_finish PARAMS ((struct objfile *));
+static void os9k_symfile_finish (struct objfile *);
 
 static void
 
 static void
-os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *, 
-     struct section_offsets *, struct objfile *));
+os9k_process_one_symbol (int, int, CORE_ADDR, char *,
+                        struct section_offsets *, struct objfile *);
 
 
-static struct partial_symtab *
-os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *,
-                       CORE_ADDR, int, int, struct partial_symbol *,
-                       struct partial_symbol *));
+static struct partial_symtab *os9k_start_psymtab (struct objfile *, char *,
+                                                 CORE_ADDR, int, int,
+                                                 struct partial_symbol **,
+                                                 struct partial_symbol **);
 
 
-static struct partial_symtab *
-os9k_end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR,
-                     struct partial_symtab **, int));
+static struct partial_symtab *os9k_end_psymtab (struct partial_symtab *,
+                                               char **, int, int, CORE_ADDR,
+                                               struct partial_symtab **,
+                                               int);
 
 
-static void
-record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
+static void record_minimal_symbol (char *, CORE_ADDR, int, struct objfile *);
 \f
 #define HANDLE_RBRAC(val) \
   if ((val) > pst->texthigh) pst->texthigh = (val);
 \f
 #define HANDLE_RBRAC(val) \
   if ((val) > pst->texthigh) pst->texthigh = (val);
@@ -207,103 +188,121 @@ record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
 #define N_ABS 6
 
 static void
 #define N_ABS 6
 
 static void
-record_minimal_symbol (name, address, type, objfile)
-     char *name;
-     CORE_ADDR address;
-     int type;
-     struct objfile *objfile;
+record_minimal_symbol (char *name, CORE_ADDR address, int type,
+                      struct objfile *objfile)
 {
   enum minimal_symbol_type ms_type;
 
   switch (type)
     {
 {
   enum minimal_symbol_type ms_type;
 
   switch (type)
     {
-    case N_TEXT:  ms_type = mst_text; break;
-    case N_DATA:  ms_type = mst_data; break;
-    case N_BSS:   ms_type = mst_bss;  break;
-    case N_RDATA: ms_type = mst_bss; break;
-    case N_IDATA: ms_type = mst_data; break;
-    case N_ABS:   ms_type = mst_abs;  break;
-    default:      ms_type = mst_unknown; break;
-  }
+    case N_TEXT:
+      ms_type = mst_text;
+      address += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+      break;
+    case N_DATA:
+      ms_type = mst_data;
+      break;
+    case N_BSS:
+      ms_type = mst_bss;
+      break;
+    case N_RDATA:
+      ms_type = mst_bss;
+      break;
+    case N_IDATA:
+      ms_type = mst_data;
+      break;
+    case N_ABS:
+      ms_type = mst_abs;
+      break;
+    default:
+      ms_type = mst_unknown;
+      break;
+    }
 
 
-  prim_record_minimal_symbol
-    (obsavestring (name, strlen(name), &objfile->symbol_obstack),
-     address, ms_type, objfile);
+  prim_record_minimal_symbol (name, address, ms_type, objfile);
 }
 
 /* read and process .stb file and store in minimal symbol table */
 typedef char mhhdr[80];
 }
 
 /* read and process .stb file and store in minimal symbol table */
 typedef char mhhdr[80];
-struct stbhdr {
-       mhhdr comhdr;
-       char * name;
-       short fmtno;
-       int crc;
-       int offset;
-       int nsym;
-       char *pad;
-};
-struct stbsymbol {
-       int value;
-       short type;
-       int stroff;
-};
+struct stbhdr
+  {
+    mhhdr comhdr;
+    char *name;
+    short fmtno;
+    int crc;
+    int offset;
+    int nsym;
+    char *pad;
+  };
+struct stbsymbol
+  {
+    int value;
+    short type;
+    int stroff;
+  };
 #define STBSYMSIZE 10
 
 #define STBSYMSIZE 10
 
-static int 
-read_minimal_symbols(objfile)
-     struct objfile *objfile;
+static void
+read_minimal_symbols (struct objfile *objfile)
 {
 {
-FILE *fp;
-bfd *abfd;
-struct stbhdr hdr;
-struct stbsymbol sym;
-int ch, i, j, off;
-char buf[64], buf1[128];
-               
+  FILE *fp;
+  bfd *abfd;
+  struct stbhdr hdr;
+  struct stbsymbol sym;
+  int ch, i, j, off;
+  char buf[64], buf1[128];
+
   fp = objfile->auxf1;
   fp = objfile->auxf1;
-  if (fp == NULL) return;
+  if (fp == NULL)
+    return;
   abfd = objfile->obfd;
   abfd = objfile->obfd;
-  fread(&hdr.comhdr[0], sizeof(mhhdr), 1, fp);
+  fread (&hdr.comhdr[0], sizeof (mhhdr), 1, fp);
   i = 0;
   i = 0;
-  ch = getc(fp);
-  while (ch != -1) {
-    buf[i] = (char)ch;
-    i++;
-    if (ch == 0) break;
-    ch = getc(fp);
-  };
-  if (i%2) ch=getc(fp);
+  ch = getc (fp);
+  while (ch != -1)
+    {
+      buf[i] = (char) ch;
+      i++;
+      if (ch == 0)
+       break;
+      ch = getc (fp);
+    };
+  if (i % 2)
+    ch = getc (fp);
   hdr.name = &buf[0];
 
   hdr.name = &buf[0];
 
-  fread(&hdr.fmtno, sizeof(hdr.fmtno), 1, fp);
-  fread(&hdr.crc, sizeof(hdr.crc), 1, fp);
-  fread(&hdr.offset, sizeof(hdr.offset), 1, fp);
-  fread(&hdr.nsym, sizeof(hdr.nsym), 1, fp);
-  SWAP_STBHDR(&hdr, abfd);      
-       
+  fread (&hdr.fmtno, sizeof (hdr.fmtno), 1, fp);
+  fread (&hdr.crc, sizeof (hdr.crc), 1, fp);
+  fread (&hdr.offset, sizeof (hdr.offset), 1, fp);
+  fread (&hdr.nsym, sizeof (hdr.nsym), 1, fp);
+  SWAP_STBHDR (&hdr, abfd);
+
   /* read symbols */
   /* read symbols */
-  init_minimal_symbol_collection();
+  init_minimal_symbol_collection ();
   off = hdr.offset;
   off = hdr.offset;
-  for (i = hdr.nsym; i > 0; i--) {
-    fseek(fp, (long)off, 0);
-    fread(&sym.value, sizeof(sym.value), 1, fp);
-    fread(&sym.type, sizeof(sym.type), 1, fp);
-    fread(&sym.stroff, sizeof(sym.stroff), 1, fp);
-    SWAP_STBSYM (&sym, abfd);
-    fseek(fp, (long)sym.stroff, 0);
-    j = 0;
-    ch = getc(fp);
-    while (ch != -1) {
-       buf1[j] = (char)ch;
-       j++;
-       if (ch == 0) break;
-       ch = getc(fp);
+  for (i = hdr.nsym; i > 0; i--)
+    {
+      fseek (fp, (long) off, 0);
+      fread (&sym.value, sizeof (sym.value), 1, fp);
+      fread (&sym.type, sizeof (sym.type), 1, fp);
+      fread (&sym.stroff, sizeof (sym.stroff), 1, fp);
+      SWAP_STBSYM (&sym, abfd);
+      fseek (fp, (long) sym.stroff, 0);
+      j = 0;
+      ch = getc (fp);
+      while (ch != -1)
+       {
+         buf1[j] = (char) ch;
+         j++;
+         if (ch == 0)
+           break;
+         ch = getc (fp);
+       };
+      record_minimal_symbol (buf1, sym.value, sym.type & 7, objfile);
+      off += STBSYMSIZE;
     };
     };
-    record_minimal_symbol(buf1, sym.value, sym.type&7, objfile);
-    off += STBSYMSIZE;
-  };
   install_minimal_symbols (objfile);
   install_minimal_symbols (objfile);
-  return 1;
+  return;
 }
 \f
 /* Scan and build partial symbols for a symbol file.
 }
 \f
 /* Scan and build partial symbols for a symbol file.
@@ -311,45 +310,32 @@ char buf[64], buf1[128];
    put all the relevant info into a "struct os9k_symfile_info",
    hung off the objfile structure.
 
    put all the relevant info into a "struct os9k_symfile_info",
    hung off the objfile structure.
 
-   SECTION_OFFSETS contains offsets relative to which the symbols in the
-   various sections are (depending where the sections were actually loaded).
    MAINLINE is true if we are reading the main symbol
    table (as opposed to a shared lib or dynamically loaded file).  */
 
 static void
    MAINLINE is true if we are reading the main symbol
    table (as opposed to a shared lib or dynamically loaded file).  */
 
 static void
-os9k_symfile_read (objfile, section_offsets, mainline)
-     struct objfile *objfile;
-     struct section_offsets *section_offsets;
-     int mainline;     /* FIXME comments above */
+os9k_symfile_read (struct objfile *objfile, int mainline)
 {
   bfd *sym_bfd;
 {
   bfd *sym_bfd;
-  int val;
-  int stb_exist;
   struct cleanup *back_to;
 
   sym_bfd = objfile->obfd;
   /* If we are reinitializing, or if we have never loaded syms yet, init */
   struct cleanup *back_to;
 
   sym_bfd = objfile->obfd;
   /* If we are reinitializing, or if we have never loaded syms yet, init */
-  if (mainline || objfile->global_psymbols.size == 0 || 
-    objfile->static_psymbols.size == 0)
-    init_psymbol_list (objfile);
+  if (mainline || objfile->global_psymbols.size == 0 ||
+      objfile->static_psymbols.size == 0)
+    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
 
 
-  pending_blocks = 0;
+  free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
   back_to = make_cleanup (really_free_pendings, 0);
 
-  make_cleanup (discard_minimal_symbols, 0);
+  make_cleanup_discard_minimal_symbols ();
   read_minimal_symbols (objfile);
 
   /* Now that the symbol table data of the executable file are all in core,
      process them and define symbols accordingly.  */
   read_minimal_symbols (objfile);
 
   /* Now that the symbol table data of the executable file are all in core,
      process them and define symbols accordingly.  */
-  read_os9k_psymtab (section_offsets, objfile,
-                  bfd_section_vma  (sym_bfd, DBX_TEXT_SECT (objfile)),
-                  bfd_section_size (sym_bfd, DBX_TEXT_SECT (objfile)));
-
-  if (!have_partial_symbols ()) {
-    wrap_here ("");
-    printf_filtered ("(no debugging symbols found)...");
-    wrap_here ("");
-  }
+  read_os9k_psymtab (objfile,
+                    DBX_TEXT_ADDR (objfile),
+                    DBX_TEXT_SIZE (objfile));
 
   do_cleanups (back_to);
 }
 
   do_cleanups (back_to);
 }
@@ -359,15 +345,14 @@ os9k_symfile_read (objfile, section_offsets, mainline)
    file, e.g. a shared library).  */
 
 static void
    file, e.g. a shared library).  */
 
 static void
-os9k_new_init (ignore)
-     struct objfile *ignore;
+os9k_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
   buildsym_new_init ();
   psymfile_depth = 0;
 /*
 {
   stabsread_new_init ();
   buildsym_new_init ();
   psymfile_depth = 0;
 /*
-  init_header_files ();
-*/
+   init_header_files ();
+ */
 }
 
 /* os9k_symfile_init ()
 }
 
 /* os9k_symfile_init ()
@@ -381,44 +366,46 @@ os9k_new_init (ignore)
    FIXME, there should be a cleaner peephole into the BFD environment here.  */
 
 static void
    FIXME, there should be a cleaner peephole into the BFD environment here.  */
 
 static void
-os9k_symfile_init (objfile)
-     struct objfile *objfile;
+os9k_symfile_init (struct objfile *objfile)
 {
 {
-  int val;
   bfd *sym_bfd = objfile->obfd;
   char *name = bfd_get_filename (sym_bfd);
   bfd *sym_bfd = objfile->obfd;
   char *name = bfd_get_filename (sym_bfd);
-  char dbgname[64], stbname[64];
+  char dbgname[512], stbname[512];
   FILE *symfile = 0;
   FILE *minfile = 0;
   FILE *symfile = 0;
   FILE *minfile = 0;
+  asection *text_sect;
 
 
+  strcpy (dbgname, name);
+  strcat (dbgname, ".dbg");
+  strcpy (stbname, name);
+  strcat (stbname, ".stb");
 
 
-  strcpy(dbgname, name);
-  strcat(dbgname, ".dbg");
-  strcpy(stbname, name);
-  strcat(stbname, ".stb");
-
-  if ((symfile = fopen(dbgname, "r")) == NULL) {
-    warning("Symbol file %s not found", dbgname);
-  }
+  if ((symfile = fopen (dbgname, "r")) == NULL)
+    {
+      warning ("Symbol file %s not found", dbgname);
+    }
   objfile->auxf2 = symfile;
 
   objfile->auxf2 = symfile;
 
-  if ((minfile = fopen(stbname, "r")) == NULL) {
-    warning("Symbol file %s not found", stbname);
-  }
+  if ((minfile = fopen (stbname, "r")) == NULL)
+    {
+      warning ("Symbol file %s not found", stbname);
+    }
   objfile->auxf1 = minfile;
 
   /* Allocate struct to keep track of the symfile */
   objfile->auxf1 = minfile;
 
   /* Allocate struct to keep track of the symfile */
-  objfile->sym_stab_info = (PTR)
-    xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
+  objfile->sym_stab_info = (struct dbx_symfile_info *)
+    xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
   DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
 
   DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
 
-  DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
-  if (!DBX_TEXT_SECT (objfile))
+  text_sect = bfd_get_section_by_name (sym_bfd, ".text");
+  if (!text_sect)
     error ("Can't find .text section in file");
     error ("Can't find .text section in file");
+  DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect);
+  DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect);
 
 
-  DBX_SYMBOL_SIZE (objfile) = 0;     /* variable size symbol */
-  DBX_SYMCOUNT (objfile) =  0;  /* used to be bfd_get_symcount(sym_bfd) */
-  DBX_SYMTAB_OFFSET (objfile) = 0;  /* used to be SYMBOL_TABLE_OFFSET */
+  DBX_SYMBOL_SIZE (objfile) = 0;       /* variable size symbol */
+  DBX_SYMCOUNT (objfile) = 0;  /* used to be bfd_get_symcount(sym_bfd) */
+  DBX_SYMTAB_OFFSET (objfile) = 0;     /* used to be SYMBOL_TABLE_OFFSET */
 }
 
 /* Perform any local cleanups required when we are done with a particular
 }
 
 /* Perform any local cleanups required when we are done with a particular
@@ -427,20 +414,20 @@ os9k_symfile_init (objfile)
    objfile struct from the global list of known objfiles. */
 
 static void
    objfile struct from the global list of known objfiles. */
 
 static void
-os9k_symfile_finish (objfile)
-     struct objfile *objfile;
+os9k_symfile_finish (struct objfile *objfile)
 {
   if (objfile->sym_stab_info != NULL)
     {
 {
   if (objfile->sym_stab_info != NULL)
     {
-      mfree (objfile -> md, objfile->sym_stab_info);
+      mfree (objfile->md, objfile->sym_stab_info);
     }
 /*
     }
 /*
-  free_header_files ();
-*/
+   free_header_files ();
+ */
 }
 }
-
 \f
 \f
-struct st_dbghdr {
+
+struct st_dbghdr
+{
   int sync;
   short rev;
   int crc;
   int sync;
   short rev;
   int crc;
@@ -465,12 +452,13 @@ struct st_dbghdr {
 #define N_SYM_RBRAC     4
 #define N_SYM_SE        5
 
 #define N_SYM_RBRAC     4
 #define N_SYM_SE        5
 
-struct internal_symstruct {
-  short n_type;
-  short n_desc;
-  long n_value;
-  char * n_strx;
-};
+struct internal_symstruct
+  {
+    short n_type;
+    short n_desc;
+    long n_value;
+    char *n_strx;
+  };
 static struct internal_symstruct symbol;
 static struct internal_symstruct *symbuf = &symbol;
 static char strbuf[4096];
 static struct internal_symstruct symbol;
 static struct internal_symstruct *symbuf = &symbol;
 static char strbuf[4096];
@@ -481,17 +469,14 @@ static short cmplrid;
 #define VER_ULTRAC     ((short)5)
 
 static int
 #define VER_ULTRAC     ((short)5)
 
 static int
-fill_sym (dbg_file, abfd)
-     FILE *dbg_file;
-     bfd *abfd;
+fill_sym (FILE *dbg_file, bfd *abfd)
 {
 {
-short id;
-short si, nmask;
-long li;
-int ii;
-char *p;
+  short si, nmask;
+  long li;
+  int ii;
+  char *p;
 
 
-  int nbytes = fread(&si, sizeof(si), 1, dbg_file);
+  int nbytes = fread (&si, sizeof (si), 1, dbg_file);
   if (nbytes == 0)
     return 0;
   if (nbytes < 0)
   if (nbytes == 0)
     return 0;
   if (nbytes < 0)
@@ -499,100 +484,74 @@ char *p;
   symbuf->n_desc = 0;
   symbuf->n_value = 0;
   symbuf->n_strx = NULL;
   symbuf->n_desc = 0;
   symbuf->n_value = 0;
   symbuf->n_strx = NULL;
-  symbuf->n_type = bfd_get_16 (abfd, (unsigned char *)&si);
+  symbuf->n_type = bfd_get_16 (abfd, (unsigned char *) &si);
   symbuf->n_type = 0xf & symbuf->n_type;
   switch (symbuf->n_type)
     {
     case N_SYM_CMPLR:
   symbuf->n_type = 0xf & symbuf->n_type;
   switch (symbuf->n_type)
     {
     case N_SYM_CMPLR:
-      fread(&si, sizeof(si), 1, dbg_file);
-      symbuf->n_desc = bfd_get_16(abfd, (unsigned char *)&si);
+      fread (&si, sizeof (si), 1, dbg_file);
+      symbuf->n_desc = bfd_get_16 (abfd, (unsigned char *) &si);
       cmplrid = symbuf->n_desc & 0xff;
       break;
     case N_SYM_SLINE:
       cmplrid = symbuf->n_desc & 0xff;
       break;
     case N_SYM_SLINE:
-      fread(&li, sizeof(li), 1, dbg_file);
-      symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li);
-      fread(&li, sizeof(li), 1, dbg_file);
-      li = bfd_get_32(abfd, (unsigned char *)&li);
-      symbuf->n_strx = (char *)(li >> 12);
+      fread (&li, sizeof (li), 1, dbg_file);
+      symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
+      fread (&li, sizeof (li), 1, dbg_file);
+      li = bfd_get_32 (abfd, (unsigned char *) &li);
+      symbuf->n_strx = (char *) (li >> 12);
       symbuf->n_desc = li & 0xfff;
       break;
     case N_SYM_SYM:
       symbuf->n_desc = li & 0xfff;
       break;
     case N_SYM_SYM:
-      fread(&li, sizeof(li), 1, dbg_file);
-      symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li);
+      fread (&li, sizeof (li), 1, dbg_file);
+      symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
       si = 0;
       si = 0;
-      do {
-       ii = getc(dbg_file);
-       strbuf[si++] = (char) ii;
-      } while (ii != 0 || si % 2 != 0);
+      do
+       {
+         ii = getc (dbg_file);
+         strbuf[si++] = (char) ii;
+       }
+      while (ii != 0 || si % 2 != 0);
       symbuf->n_strx = strbuf;
       p = (char *) strchr (strbuf, ':');
       symbuf->n_strx = strbuf;
       p = (char *) strchr (strbuf, ':');
-      if (!p) break;
+      if (!p)
+       break;
       if ((p[1] == 'F' || p[1] == 'f') && cmplrid == VER_PRE_ULTRAC)
        {
       if ((p[1] == 'F' || p[1] == 'f') && cmplrid == VER_PRE_ULTRAC)
        {
-         fread(&si, sizeof(si), 1, dbg_file);
-         nmask = bfd_get_16(abfd, (unsigned char *)&si);
-         for (ii=0; ii<nmask; ii++)
-           fread(&si, sizeof(si), 1, dbg_file);
+         fread (&si, sizeof (si), 1, dbg_file);
+         nmask = bfd_get_16 (abfd, (unsigned char *) &si);
+         for (ii = 0; ii < nmask; ii++)
+           fread (&si, sizeof (si), 1, dbg_file);
        }
       break;
     case N_SYM_LBRAC:
        }
       break;
     case N_SYM_LBRAC:
-      fread(&li, sizeof(li), 1, dbg_file);
-      symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li);
+      fread (&li, sizeof (li), 1, dbg_file);
+      symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
       break;
     case N_SYM_RBRAC:
       break;
     case N_SYM_RBRAC:
-      fread(&li, sizeof(li), 1, dbg_file);
-      symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li);
+      fread (&li, sizeof (li), 1, dbg_file);
+      symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
       break;
     case N_SYM_SE:
       break;
     }
       break;
     case N_SYM_SE:
       break;
     }
-    return 1;
+  return 1;
 }
 \f
 }
 \f
-/* Initializes storage for all of the partial symbols that will be
-   created by read_dbx_symtab and subsidiaries.  */
-
-static void
-init_psymbol_list (objfile)
-     struct objfile *objfile;
-{
-  /* Free any previously allocated psymbol lists.  */
-  if (objfile -> global_psymbols.list)
-    mfree (objfile -> md, (PTR)objfile -> global_psymbols.list);
-  if (objfile -> static_psymbols.list)
-    mfree (objfile -> md, (PTR)objfile -> static_psymbols.list);
-
-  /* Current best guess is that there are approximately a twentieth
-     of the total symbols (in a debugging file) are global or static
-     oriented symbols */
-  objfile -> global_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
-  objfile -> static_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
-  objfile -> global_psymbols.next = objfile -> global_psymbols.list = (struct partial_symbol *)
-    xmmalloc (objfile -> md, objfile -> global_psymbols.size * sizeof (struct partial_symbol));
-  objfile -> static_psymbols.next = objfile -> static_psymbols.list = (struct partial_symbol *)
-    xmmalloc (objfile -> md, objfile -> static_psymbols.size * sizeof (struct partial_symbol));
-}
-
 /* Given pointers to an a.out symbol table in core containing dbx
    style data, setup partial_symtab's describing each source file for
    which debugging information is available.
 /* Given pointers to an a.out symbol table in core containing dbx
    style data, setup partial_symtab's describing each source file for
    which debugging information is available.
-   SYMFILE_NAME is the name of the file we are reading from
-   and SECTION_OFFSETS is the set of offsets for the various sections
-   of the file (a set of zeros if the mainline program).  */
+   SYMFILE_NAME is the name of the file we are reading from. */
 
 static void
 
 static void
-read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
-     struct section_offsets *section_offsets;
-     struct objfile *objfile;
-     CORE_ADDR text_addr;
-     int text_size;
+read_os9k_psymtab (struct objfile *objfile, CORE_ADDR text_addr, int text_size)
 {
 {
-  register struct internal_symstruct *bufp = 0;        /* =0 avoids gcc -Wall glitch*/
+  register struct internal_symstruct *bufp = 0;                /* =0 avoids gcc -Wall glitch */
   register char *namestring;
   register char *namestring;
-  int nsl;
   int past_first_source_file = 0;
   CORE_ADDR last_o_file_start = 0;
   int past_first_source_file = 0;
   CORE_ADDR last_o_file_start = 0;
+#if 0
   struct cleanup *back_to;
   struct cleanup *back_to;
+#endif
   bfd *abfd;
   FILE *fp;
 
   bfd *abfd;
   FILE *fp;
 
@@ -627,66 +586,71 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
 #ifdef END_OF_TEXT_DEFAULT
   end_of_text_addr = END_OF_TEXT_DEFAULT;
 #else
 #ifdef END_OF_TEXT_DEFAULT
   end_of_text_addr = END_OF_TEXT_DEFAULT;
 #else
-  end_of_text_addr = text_addr + section_offsets->offsets[SECT_OFF_TEXT]
-                              + text_size;     /* Relocate */
+  end_of_text_addr = text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))
+    + text_size;               /* Relocate */
 #endif
 
   abfd = objfile->obfd;
 #endif
 
   abfd = objfile->obfd;
-  fp = objfile->auxf2; 
-               
-  fread(&dbghdr.sync, sizeof(dbghdr.sync), 1, fp);
-  fread(&dbghdr.rev, sizeof(dbghdr.rev), 1, fp);
-  fread(&dbghdr.crc, sizeof(dbghdr.crc), 1, fp);
-  fread(&dbghdr.os, sizeof(dbghdr.os), 1, fp);
-  fread(&dbghdr.cpu, sizeof(dbghdr.cpu), 1, fp);
-  SWAP_DBGHDR(&dbghdr, abfd);      
+  fp = objfile->auxf2;
+  if (!fp)
+    return;
+
+  fread (&dbghdr.sync, sizeof (dbghdr.sync), 1, fp);
+  fread (&dbghdr.rev, sizeof (dbghdr.rev), 1, fp);
+  fread (&dbghdr.crc, sizeof (dbghdr.crc), 1, fp);
+  fread (&dbghdr.os, sizeof (dbghdr.os), 1, fp);
+  fread (&dbghdr.cpu, sizeof (dbghdr.cpu), 1, fp);
+  SWAP_DBGHDR (&dbghdr, abfd);
 
   symnum = 0;
 
   symnum = 0;
-  while(1)
+  while (1)
     {
     {
-    int ret;
-    long cursymoffset;
+      int ret;
+      long cursymoffset;
 
       /* Get the symbol for this run and pull out some info */
 
       /* Get the symbol for this run and pull out some info */
-      QUIT;    /* allow this to be interruptable */
-      cursymoffset = ftell(objfile->auxf2);
-      ret = fill_sym(objfile->auxf2, abfd);
-      if (ret <= 0) break;
-      else symnum++;
+      QUIT;                    /* allow this to be interruptable */
+      cursymoffset = ftell (objfile->auxf2);
+      ret = fill_sym (objfile->auxf2, abfd);
+      if (ret <= 0)
+       break;
+      else
+       symnum++;
       bufp = symbuf;
 
       /* Special case to speed up readin. */
       bufp = symbuf;
 
       /* Special case to speed up readin. */
-      if (bufp->n_type == (short)N_SYM_SLINE) continue;
+      if (bufp->n_type == (short) N_SYM_SLINE)
+       continue;
 
 #define CUR_SYMBOL_VALUE bufp->n_value
       /* partial-stab.h */
 
       switch (bufp->n_type)
        {
 
 #define CUR_SYMBOL_VALUE bufp->n_value
       /* partial-stab.h */
 
       switch (bufp->n_type)
        {
-       char *p;
+         char *p;
 
        case N_SYM_CMPLR:
          continue;
 
        case N_SYM_SE:
 
        case N_SYM_CMPLR:
          continue;
 
        case N_SYM_SE:
-          CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT);
+         CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
          if (psymfile_depth == 1 && pst)
            {
              os9k_end_psymtab (pst, psymtab_include_list, includes_used,
          if (psymfile_depth == 1 && pst)
            {
              os9k_end_psymtab (pst, psymtab_include_list, includes_used,
-                      symnum, CUR_SYMBOL_VALUE,
-                      dependency_list, dependencies_used);
+                               symnum, CUR_SYMBOL_VALUE,
+                               dependency_list, dependencies_used);
              pst = (struct partial_symtab *) 0;
              includes_used = 0;
              dependencies_used = 0;
            }
              pst = (struct partial_symtab *) 0;
              includes_used = 0;
              dependencies_used = 0;
            }
-         psymfile_depth--;
+         psymfile_depth--;
          continue;
 
          continue;
 
-       case N_SYM_SYM:         /* Typedef or automatic variable. */
+       case N_SYM_SYM: /* Typedef or automatic variable. */
          namestring = bufp->n_strx;
          namestring = bufp->n_strx;
-          p = (char *) strchr (namestring, ':');
-          if (!p)
-            continue;           /* Not a debugging symbol.   */
+         p = (char *) strchr (namestring, ':');
+         if (!p)
+           continue;           /* Not a debugging symbol.   */
 
          /* Main processing section for debugging symbols which
             the initial read through the symbol tables needs to worry
 
          /* Main processing section for debugging symbols which
             the initial read through the symbol tables needs to worry
@@ -697,92 +661,107 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
 
          switch (p[1])
            {
 
          switch (p[1])
            {
-           case 'S' :
+           case 'S':
              {
                unsigned long valu;
              {
                unsigned long valu;
-               enum language tmp_language;
-               
-               valu = CUR_SYMBOL_VALUE + 
-                 ANOFFSET (section_offsets, SECT_OFF_TEXT);
+               enum language tmp_language;
+               char *str, *p;
+               int n;
+
+               valu = CUR_SYMBOL_VALUE;
+               if (valu)
+                 valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
                past_first_source_file = 1;
 
                past_first_source_file = 1;
 
-               if (psymfile_depth == 0) {
-                 if (!pst)
-                   pst = os9k_start_psymtab (objfile, section_offsets,
-                                namestring, valu,
-                                cursymoffset,
-                                symnum-1,
-                                objfile -> global_psymbols.next,
-                                objfile -> static_psymbols.next);
-               } else { /* this is a include file */
-                 tmp_language = deduce_language_from_filename (namestring);
-                 if (tmp_language != language_unknown
-                       && (tmp_language != language_c
-                       || psymtab_language != language_cplus))
-                       psymtab_language = tmp_language;
+               p = strchr (namestring, ':');
+               if (p)
+                 n = p - namestring;
+               else
+                 n = strlen (namestring);
+               str = alloca (n + 1);
+               strncpy (str, namestring, n);
+               str[n] = '\0';
 
 
-/*
-                 if (pst && STREQ (namestring, pst->filename))
-                   continue;
+               if (psymfile_depth == 0)
                  {
                  {
-                   register int i;
-                   for (i = 0; i < includes_used; i++)
-                     if (STREQ (namestring, psymtab_include_list[i]))
-                       {
-                         i = -1; 
-                         break;
-                       }
-                   if (i == -1)
-                     continue;
+                   if (!pst)
+                     pst = os9k_start_psymtab (objfile,
+                                               str, valu,
+                                               cursymoffset,
+                                               symnum - 1,
+                                             objfile->global_psymbols.next,
+                                            objfile->static_psymbols.next);
                  }
                  }
-*/
-
-                  psymtab_include_list[includes_used++] = namestring;
-                  if (includes_used >= includes_allocated)
-                    {
-                      char **orig = psymtab_include_list;
+               else
+                 {             /* this is a include file */
+                   tmp_language = deduce_language_from_filename (str);
+                   if (tmp_language != language_unknown
+                       && (tmp_language != language_c
+                           || psymtab_language != language_cplus))
+                     psymtab_language = tmp_language;
 
 
-                      psymtab_include_list = (char **)
-                         alloca ((includes_allocated *= 2) * sizeof (char *));
-                      memcpy ((PTR)psymtab_include_list, (PTR)orig,
-                          includes_used * sizeof (char *));
-                   }
+/*
+   if (pst && STREQ (str, pst->filename))
+   continue;
+   {
+   register int i;
+   for (i = 0; i < includes_used; i++)
+   if (STREQ (str, psymtab_include_list[i]))
+   {
+   i = -1; 
+   break;
+   }
+   if (i == -1)
+   continue;
+   }
+ */
+
+                   psymtab_include_list[includes_used++] = str;
+                   if (includes_used >= includes_allocated)
+                     {
+                       char **orig = psymtab_include_list;
+
+                       psymtab_include_list = (char **)
+                         alloca ((includes_allocated *= 2) * sizeof (char *));
+                       memcpy ((PTR) psymtab_include_list, (PTR) orig,
+                               includes_used * sizeof (char *));
+                     }
 
 
-               }
-               psymfile_depth++;
+                 }
+               psymfile_depth++;
                continue;
              }
 
            case 'v':
                continue;
              }
 
            case 'v':
-             ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
-                                       VAR_NAMESPACE, LOC_STATIC,
-                                       objfile->static_psymbols,
-                                       CUR_SYMBOL_VALUE,
-                                       psymtab_language, objfile);
+             add_psymbol_to_list (namestring, p - namestring,
+                                  VAR_NAMESPACE, LOC_STATIC,
+                                  &objfile->static_psymbols,
+                                  0, CUR_SYMBOL_VALUE,
+                                  psymtab_language, objfile);
              continue;
            case 'V':
              continue;
            case 'V':
-             ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
-                                       VAR_NAMESPACE, LOC_STATIC,
-                                       objfile->global_psymbols,
-                                       CUR_SYMBOL_VALUE,
-                                       psymtab_language, objfile);
+             add_psymbol_to_list (namestring, p - namestring,
+                                  VAR_NAMESPACE, LOC_STATIC,
+                                  &objfile->global_psymbols,
+                                  0, CUR_SYMBOL_VALUE,
+                                  psymtab_language, objfile);
              continue;
 
            case 'T':
              if (p != namestring)      /* a name is there, not just :T... */
                {
              continue;
 
            case 'T':
              if (p != namestring)      /* a name is there, not just :T... */
                {
-                 ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+                 add_psymbol_to_list (namestring, p - namestring,
                                       STRUCT_NAMESPACE, LOC_TYPEDEF,
                                       STRUCT_NAMESPACE, LOC_TYPEDEF,
-                                      objfile->static_psymbols,
-                                      CUR_SYMBOL_VALUE,
+                                      &objfile->static_psymbols,
+                                      CUR_SYMBOL_VALUE, 0,
                                       psymtab_language, objfile);
                  if (p[2] == 't')
                    {
                      /* Also a typedef with the same name.  */
                                       psymtab_language, objfile);
                  if (p[2] == 't')
                    {
                      /* Also a typedef with the same name.  */
-                     ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+                     add_psymbol_to_list (namestring, p - namestring,
                                           VAR_NAMESPACE, LOC_TYPEDEF,
                                           VAR_NAMESPACE, LOC_TYPEDEF,
-                                          objfile->static_psymbols,
-                                          CUR_SYMBOL_VALUE, psymtab_language,
+                                          &objfile->static_psymbols,
+                                     CUR_SYMBOL_VALUE, 0, psymtab_language,
                                           objfile);
                      p += 1;
                    }
                                           objfile);
                      p += 1;
                    }
@@ -792,43 +771,43 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                     We make the typedef here so that "ptype foo" works as
                     expected for cfront translated code.  */
                  else if (psymtab_language == language_cplus)
                     We make the typedef here so that "ptype foo" works as
                     expected for cfront translated code.  */
                  else if (psymtab_language == language_cplus)
-                  {
+                   {
                      /* Also a typedef with the same name.  */
                      /* Also a typedef with the same name.  */
-                     ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+                     add_psymbol_to_list (namestring, p - namestring,
                                           VAR_NAMESPACE, LOC_TYPEDEF,
                                           VAR_NAMESPACE, LOC_TYPEDEF,
-                                          objfile->static_psymbols,
-                                          CUR_SYMBOL_VALUE, psymtab_language,
+                                          &objfile->static_psymbols,
+                                     CUR_SYMBOL_VALUE, 0, psymtab_language,
                                           objfile);
                                           objfile);
-                  }
+                   }
                }
              goto check_enum;
            case 't':
              if (p != namestring)      /* a name is there, not just :T... */
                {
                }
              goto check_enum;
            case 't':
              if (p != namestring)      /* a name is there, not just :T... */
                {
-                 ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+                 add_psymbol_to_list (namestring, p - namestring,
                                       VAR_NAMESPACE, LOC_TYPEDEF,
                                       VAR_NAMESPACE, LOC_TYPEDEF,
-                                      objfile->static_psymbols,
-                                      CUR_SYMBOL_VALUE,
+                                      &objfile->static_psymbols,
+                                      CUR_SYMBOL_VALUE, 0,
                                       psymtab_language, objfile);
                }
            check_enum:
              /* If this is an enumerated type, we need to
                                       psymtab_language, objfile);
                }
            check_enum:
              /* If this is an enumerated type, we need to
-                add all the enum constants to the partial symbol
-                table.  This does not cover enums without names, e.g.
-                "enum {a, b} c;" in C, but fortunately those are
-                rare.  There is no way for GDB to find those from the
-                enum type without spending too much time on it.  Thus
-                to solve this problem, the compiler needs to put out the
-                enum in a nameless type.  GCC2 does this.  */
+                add all the enum constants to the partial symbol
+                table.  This does not cover enums without names, e.g.
+                "enum {a, b} c;" in C, but fortunately those are
+                rare.  There is no way for GDB to find those from the
+                enum type without spending too much time on it.  Thus
+                to solve this problem, the compiler needs to put out the
+                enum in a nameless type.  GCC2 does this.  */
 
              /* We are looking for something of the form
 
              /* We are looking for something of the form
-                <name> ":" ("t" | "T") [<number> "="] "e" <size>
-                {<constant> ":" <value> ","} ";".  */
+                <name> ":" ("t" | "T") [<number> "="] "e" <size>
+                {<constant> ":" <value> ","} ";".  */
 
              /* Skip over the colon and the 't' or 'T'.  */
              p += 2;
              /* This type may be given a number.  Also, numbers can come
 
              /* Skip over the colon and the 't' or 'T'.  */
              p += 2;
              /* This type may be given a number.  Also, numbers can come
-                in pairs like (0,26).  Skip over it.  */
+                in pairs like (0,26).  Skip over it.  */
              while ((*p >= '0' && *p <= '9')
                     || *p == '(' || *p == ',' || *p == ')'
                     || *p == '=')
              while ((*p >= '0' && *p <= '9')
                     || *p == '(' || *p == ',' || *p == ')'
                     || *p == '=')
@@ -837,7 +816,8 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
              if (*p++ == 'e')
                {
                  /* We have found an enumerated type. skip size */
              if (*p++ == 'e')
                {
                  /* We have found an enumerated type. skip size */
-                 while (*p >= '0' && *p <= '9') p++;
+                 while (*p >= '0' && *p <= '9')
+                   p++;
                  /* According to comments in read_enum_type
                     a comma could end it instead of a semicolon.
                     I don't know where that happens.
                  /* According to comments in read_enum_type
                     a comma could end it instead of a semicolon.
                     I don't know where that happens.
@@ -847,21 +827,21 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                      char *q;
 
                      /* Check for and handle cretinous dbx symbol name
                      char *q;
 
                      /* Check for and handle cretinous dbx symbol name
-                        continuation! 
-                     if (*p == '\\')
-                       p = next_symbol_text ();
-                     */
+                        continuation! 
+                        if (*p == '\\')
+                        p = next_symbol_text (objfile);
+                      */
 
                      /* Point to the character after the name
 
                      /* Point to the character after the name
-                        of the enum constant.  */
+                        of the enum constant.  */
                      for (q = p; *q && *q != ':'; q++)
                        ;
                      /* Note that the value doesn't matter for
                      for (q = p; *q && *q != ':'; q++)
                        ;
                      /* Note that the value doesn't matter for
-                        enum constants in psymtabs, just in symtabs.  */
-                     ADD_PSYMBOL_TO_LIST (p, q - p,
+                        enum constants in psymtabs, just in symtabs.  */
+                     add_psymbol_to_list (p, q - p,
                                           VAR_NAMESPACE, LOC_CONST,
                                           VAR_NAMESPACE, LOC_CONST,
-                                          objfile->static_psymbols, 0,
-                                          psymtab_language, objfile);
+                                          &objfile->static_psymbols, 0,
+                                          0, psymtab_language, objfile);
                      /* Point past the name.  */
                      p = q;
                      /* Skip over the value.  */
                      /* Point past the name.  */
                      p = q;
                      /* Skip over the value.  */
@@ -875,65 +855,65 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
              continue;
            case 'c':
              /* Constant, e.g. from "const" in Pascal.  */
              continue;
            case 'c':
              /* Constant, e.g. from "const" in Pascal.  */
-             ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+             add_psymbol_to_list (namestring, p - namestring,
                                   VAR_NAMESPACE, LOC_CONST,
                                   VAR_NAMESPACE, LOC_CONST,
-                                  objfile->static_psymbols, CUR_SYMBOL_VALUE,
-                                  psymtab_language, objfile);
+                               &objfile->static_psymbols, CUR_SYMBOL_VALUE,
+                                  0, psymtab_language, objfile);
              continue;
 
            case 'f':
              continue;
 
            case 'f':
-             CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT);
-              if (pst && pst->textlow == 0)
-                pst->textlow = CUR_SYMBOL_VALUE;
+             CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+             if (pst && pst->textlow == 0)
+               pst->textlow = CUR_SYMBOL_VALUE;
 
 
-             ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+             add_psymbol_to_list (namestring, p - namestring,
                                   VAR_NAMESPACE, LOC_BLOCK,
                                   VAR_NAMESPACE, LOC_BLOCK,
-                                  objfile->static_psymbols, CUR_SYMBOL_VALUE,
-                                  psymtab_language, objfile);
+                               &objfile->static_psymbols, CUR_SYMBOL_VALUE,
+                                  0, psymtab_language, objfile);
              continue;
 
            case 'F':
              continue;
 
            case 'F':
-             CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT);
-              if (pst && pst->textlow == 0)
-                pst->textlow = CUR_SYMBOL_VALUE;
+             CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+             if (pst && pst->textlow == 0)
+               pst->textlow = CUR_SYMBOL_VALUE;
 
 
-             ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+             add_psymbol_to_list (namestring, p - namestring,
                                   VAR_NAMESPACE, LOC_BLOCK,
                                   VAR_NAMESPACE, LOC_BLOCK,
-                                  objfile->global_psymbols, CUR_SYMBOL_VALUE,
-                                  psymtab_language, objfile);
+                               &objfile->global_psymbols, CUR_SYMBOL_VALUE,
+                                  0, psymtab_language, objfile);
              continue;
 
            case 'p':
            case 'l':
              continue;
 
            case 'p':
            case 'l':
-            case 's':
+           case 's':
              continue;
 
            case ':':
              /* It is a C++ nested symbol.  We don't need to record it
              continue;
 
            case ':':
              /* It is a C++ nested symbol.  We don't need to record it
-                (I don't think); if we try to look up foo::bar::baz,
-                then symbols for the symtab containing foo should get
-                read in, I think.  */
+                (I don't think); if we try to look up foo::bar::baz,
+                then symbols for the symtab containing foo should get
+                read in, I think.  */
              /* Someone says sun cc puts out symbols like
              /* Someone says sun cc puts out symbols like
-                /foo/baz/maclib::/usr/local/bin/maclib,
-                which would get here with a symbol type of ':'.  */
+                /foo/baz/maclib::/usr/local/bin/maclib,
+                which would get here with a symbol type of ':'.  */
              continue;
 
            default:
              /* Unexpected symbol descriptor.  The second and subsequent stabs
              continue;
 
            default:
              /* Unexpected symbol descriptor.  The second and subsequent stabs
-                of a continued stab can show up here.  The question is
-                whether they ever can mimic a normal stab--it would be
-                nice if not, since we certainly don't want to spend the
-                time searching to the end of every string looking for
-                a backslash.  */
+                of a continued stab can show up here.  The question is
+                whether they ever can mimic a normal stab--it would be
+                nice if not, since we certainly don't want to spend the
+                time searching to the end of every string looking for
+                a backslash.  */
 
              complain (&unknown_symchar_complaint, p[1]);
              continue;
            }
 
        case N_SYM_RBRAC:
 
              complain (&unknown_symchar_complaint, p[1]);
              continue;
            }
 
        case N_SYM_RBRAC:
-         CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT);
+         CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 #ifdef HANDLE_RBRAC
 #ifdef HANDLE_RBRAC
-         HANDLE_RBRAC(CUR_SYMBOL_VALUE);
+         HANDLE_RBRAC (CUR_SYMBOL_VALUE);
          continue;
 #endif
        case N_SYM_LBRAC:
          continue;
 #endif
        case N_SYM_LBRAC:
@@ -954,22 +934,22 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
   if (DBX_SYMCOUNT (objfile) > 0
 /*FIXME, does this have a bug at start address 0? */
       && last_o_file_start
   if (DBX_SYMCOUNT (objfile) > 0
 /*FIXME, does this have a bug at start address 0? */
       && last_o_file_start
-      && objfile -> ei.entry_point < bufp->n_value
-      && objfile -> ei.entry_point >= last_o_file_start)
+      && objfile->ei.entry_point < bufp->n_value
+      && objfile->ei.entry_point >= last_o_file_start)
     {
     {
-      objfile -> ei.entry_file_lowpc = last_o_file_start;
-      objfile -> ei.entry_file_highpc = bufp->n_value;
+      objfile->ei.entry_file_lowpc = last_o_file_start;
+      objfile->ei.entry_file_highpc = bufp->n_value;
     }
 
   if (pst)
     {
       os9k_end_psymtab (pst, psymtab_include_list, includes_used,
     }
 
   if (pst)
     {
       os9k_end_psymtab (pst, psymtab_include_list, includes_used,
-                  symnum, end_of_text_addr,
-                  dependency_list, dependencies_used);
+                       symnum, end_of_text_addr,
+                       dependency_list, dependencies_used);
     }
 /*
     }
 /*
-  do_cleanups (back_to);
-*/
+   do_cleanups (back_to);
+ */
 }
 
 /* Allocate and partially fill a partial symtab.  It will be
 }
 
 /* Allocate and partially fill a partial symtab.  It will be
@@ -981,26 +961,20 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
 
 
 static struct partial_symtab *
 
 
 static struct partial_symtab *
-os9k_start_psymtab (objfile, section_offsets,
-              filename, textlow, ldsymoff,ldsymcnt,  global_syms, static_syms)
-     struct objfile *objfile;
-     struct section_offsets *section_offsets;
-     char *filename;
-     CORE_ADDR textlow;
-     int ldsymoff;
-     int ldsymcnt;
-     struct partial_symbol *global_syms;
-     struct partial_symbol *static_syms;
+os9k_start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow,
+                   int ldsymoff, int ldsymcnt,
+                   struct partial_symbol **global_syms,
+                   struct partial_symbol **static_syms)
 {
   struct partial_symtab *result =
 {
   struct partial_symtab *result =
-      start_psymtab_common(objfile, section_offsets,
-                          filename, textlow, global_syms, static_syms);
+  start_psymtab_common (objfile, objfile->section_offsets,
+                       filename, textlow, global_syms, static_syms);
 
   result->read_symtab_private = (char *)
 
   result->read_symtab_private = (char *)
-    obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc));
+    obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc));
 
 
-  LDSYMOFF(result) = ldsymoff;
-  LDSYMCNT(result) = ldsymcnt;
+  LDSYMOFF (result) = ldsymoff;
+  LDSYMCNT (result) = ldsymcnt;
   result->read_symtab = os9k_psymtab_to_symtab;
 
   /* Deduce the source language from the filename for this psymtab. */
   result->read_symtab = os9k_psymtab_to_symtab;
 
   /* Deduce the source language from the filename for this psymtab. */
@@ -1013,23 +987,18 @@ os9k_start_psymtab (objfile, section_offsets,
    FIXME:  List variables and peculiarities of same.  */
 
 static struct partial_symtab *
    FIXME:  List variables and peculiarities of same.  */
 
 static struct partial_symtab *
-os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
-            capping_text, dependency_list, number_dependencies)
-     struct partial_symtab *pst;
-     char **include_list;
-     int num_includes;
-     int capping_symbol_cnt;
-     CORE_ADDR capping_text;
-     struct partial_symtab **dependency_list;
-     int number_dependencies;
-/*     struct partial_symbol *capping_global, *capping_static;*/
+os9k_end_psymtab (struct partial_symtab *pst, char **include_list,
+                 int num_includes, int capping_symbol_cnt,
+                 CORE_ADDR capping_text,
+                 struct partial_symtab **dependency_list,
+                 int number_dependencies)
 {
   int i;
   struct partial_symtab *p1;
 {
   int i;
   struct partial_symtab *p1;
-  struct objfile *objfile = pst -> objfile;
+  struct objfile *objfile = pst->objfile;
 
   if (capping_symbol_cnt != -1)
 
   if (capping_symbol_cnt != -1)
-      LDSYMCNT(pst) = capping_symbol_cnt - LDSYMCNT(pst);
+    LDSYMCNT (pst) = capping_symbol_cnt - LDSYMCNT (pst);
 
   /* Under Solaris, the N_SO symbols always have a value of 0,
      instead of the usual address of the .o file.  Therefore,
 
   /* Under Solaris, the N_SO symbols always have a value of 0,
      instead of the usual address of the .o file.  Therefore,
@@ -1054,45 +1023,49 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
      down the partial_symtab_list filling in previous texthighs that
      are still unknown.  */
 
      down the partial_symtab_list filling in previous texthighs that
      are still unknown.  */
 
-  if (pst->texthigh == 0 && last_function_name) {
-    char *p;
-    int n;
-    struct minimal_symbol *minsym;
-
-    p = strchr (last_function_name, ':');
-    if (p == NULL)
-      p = last_function_name;
-    n = p - last_function_name;
-    p = alloca (n + 1);
-    strncpy (p, last_function_name, n);
-    p[n] = 0;
-    
-    minsym = lookup_minimal_symbol (p, objfile);
-
-    if (minsym) {
-      pst->texthigh = SYMBOL_VALUE_ADDRESS(minsym)+(long)MSYMBOL_INFO(minsym);
-    } else {
-      /* This file ends with a static function, and it's
-        difficult to imagine how hard it would be to track down
-        the elf symbol.  Luckily, most of the time no one will notice,
-        since the next file will likely be compiled with -g, so
-        the code below will copy the first fuction's start address 
-        back to our texthigh variable.  (Also, if this file is the
-        last one in a dynamically linked program, texthigh already
-        has the right value.)  If the next file isn't compiled
-        with -g, then the last function in this file winds up owning
-        all of the text space up to the next -g file, or the end (minus
-        shared libraries).  This only matters for single stepping,
-        and even then it will still work, except that it will single
-        step through all of the covered functions, instead of setting
-        breakpoints around them as it usualy does.  This makes it
-        pretty slow, but at least it doesn't fail.
-
-        We can fix this with a fairly big change to bfd, but we need
-        to coordinate better with Cygnus if we want to do that.  FIXME.  */
+  if (pst->texthigh == 0 && last_function_name)
+    {
+      char *p;
+      int n;
+      struct minimal_symbol *minsym;
+
+      p = strchr (last_function_name, ':');
+      if (p == NULL)
+       p = last_function_name;
+      n = p - last_function_name;
+      p = alloca (n + 1);
+      strncpy (p, last_function_name, n);
+      p[n] = 0;
+
+      minsym = lookup_minimal_symbol (p, NULL, objfile);
+
+      if (minsym)
+       {
+         pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) + (long) MSYMBOL_INFO (minsym);
+       }
+      else
+       {
+         /* This file ends with a static function, and it's
+            difficult to imagine how hard it would be to track down
+            the elf symbol.  Luckily, most of the time no one will notice,
+            since the next file will likely be compiled with -g, so
+            the code below will copy the first fuction's start address 
+            back to our texthigh variable.  (Also, if this file is the
+            last one in a dynamically linked program, texthigh already
+            has the right value.)  If the next file isn't compiled
+            with -g, then the last function in this file winds up owning
+            all of the text space up to the next -g file, or the end (minus
+            shared libraries).  This only matters for single stepping,
+            and even then it will still work, except that it will single
+            step through all of the covered functions, instead of setting
+            breakpoints around them as it usualy does.  This makes it
+            pretty slow, but at least it doesn't fail.
+
+            We can fix this with a fairly big change to bfd, but we need
+            to coordinate better with Cygnus if we want to do that.  FIXME.  */
+       }
+      last_function_name = NULL;
     }
     }
-    last_function_name = NULL;
-  }
 
   /* this test will be true if the last .o file is only data */
   if (pst->textlow == 0)
 
   /* this test will be true if the last .o file is only data */
   if (pst->textlow == 0)
@@ -1103,16 +1076,19 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
      address, set it to our starting address.  Take care to not set our
      own ending address to our starting address, nor to set addresses on
      `dependency' files that have both textlow and texthigh zero.  */
      address, set it to our starting address.  Take care to not set our
      own ending address to our starting address, nor to set addresses on
      `dependency' files that have both textlow and texthigh zero.  */
-  if (pst->textlow) {
-    ALL_OBJFILE_PSYMTABS (objfile, p1) {
-      if (p1->texthigh == 0  && p1->textlow != 0 && p1 != pst) {
-       p1->texthigh = pst->textlow;
-       /* if this file has only data, then make textlow match texthigh */
-       if (p1->textlow == 0)
-         p1->textlow = p1->texthigh;
+  if (pst->textlow)
+    {
+      ALL_OBJFILE_PSYMTABS (objfile, p1)
+      {
+       if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst)
+         {
+           p1->texthigh = pst->textlow;
+           /* if this file has only data, then make textlow match texthigh */
+           if (p1->textlow == 0)
+             p1->textlow = p1->texthigh;
+         }
       }
     }
       }
     }
-  }
 
   /* End of kludge for patching Solaris textlow and texthigh.  */
 
 
   /* End of kludge for patching Solaris textlow and texthigh.  */
 
@@ -1126,9 +1102,9 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
     {
       pst->dependencies = (struct partial_symtab **)
        obstack_alloc (&objfile->psymbol_obstack,
     {
       pst->dependencies = (struct partial_symtab **)
        obstack_alloc (&objfile->psymbol_obstack,
-                      number_dependencies * sizeof (struct partial_symtab *));
+                   number_dependencies * sizeof (struct partial_symtab *));
       memcpy (pst->dependencies, dependency_list,
       memcpy (pst->dependencies, dependency_list,
-            number_dependencies * sizeof (struct partial_symtab *));
+             number_dependencies * sizeof (struct partial_symtab *));
     }
   else
     pst->dependencies = 0;
     }
   else
     pst->dependencies = 0;
@@ -1136,19 +1112,19 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
   for (i = 0; i < num_includes; i++)
     {
       struct partial_symtab *subpst =
   for (i = 0; i < num_includes; i++)
     {
       struct partial_symtab *subpst =
-       allocate_psymtab (include_list[i], objfile);
+      allocate_psymtab (include_list[i], objfile);
 
       subpst->section_offsets = pst->section_offsets;
       subpst->read_symtab_private =
 
       subpst->section_offsets = pst->section_offsets;
       subpst->read_symtab_private =
-         (char *) obstack_alloc (&objfile->psymbol_obstack,
-                                 sizeof (struct symloc));
-      LDSYMOFF(subpst) =
-       LDSYMCNT(subpst) =
-         subpst->textlow =
-           subpst->texthigh = 0;
+       (char *) obstack_alloc (&objfile->psymbol_obstack,
+                               sizeof (struct symloc));
+      LDSYMOFF (subpst) =
+       LDSYMCNT (subpst) =
+       subpst->textlow =
+       subpst->texthigh = 0;
 
       /* We could save slight bits of space by only making one of these,
 
       /* We could save slight bits of space by only making one of these,
-        shared by the entire set of include files.  FIXME-someday.  */
+         shared by the entire set of include files.  FIXME-someday.  */
       subpst->dependencies = (struct partial_symtab **)
        obstack_alloc (&objfile->psymbol_obstack,
                       sizeof (struct partial_symtab *));
       subpst->dependencies = (struct partial_symtab **)
        obstack_alloc (&objfile->psymbol_obstack,
                       sizeof (struct partial_symtab *));
@@ -1157,8 +1133,8 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
 
       subpst->globals_offset =
        subpst->n_global_syms =
 
       subpst->globals_offset =
        subpst->n_global_syms =
-         subpst->statics_offset =
-           subpst->n_static_syms = 0;
+       subpst->statics_offset =
+       subpst->n_static_syms = 0;
 
       subpst->readin = 0;
       subpst->symtab = 0;
 
       subpst->readin = 0;
       subpst->symtab = 0;
@@ -1174,46 +1150,34 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
   free_named_symtabs (pst->filename);
 
   if (num_includes == 0
   free_named_symtabs (pst->filename);
 
   if (num_includes == 0
-   && number_dependencies == 0
-   && pst->n_global_syms == 0
-   && pst->n_static_syms == 0) {
-    /* Throw away this psymtab, it's empty.  We can't deallocate it, since
-       it is on the obstack, but we can forget to chain it on the list.  */
-    struct partial_symtab *prev_pst;
-
-    /* First, snip it out of the psymtab chain */
-
-    if (pst->objfile->psymtabs == pst)
-      pst->objfile->psymtabs = pst->next;
-    else
-      for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next)
-       if (prev_pst->next == pst)
-         prev_pst->next = pst->next;
-
-    /* Next, put it on a free list for recycling */
-    pst->next = pst->objfile->free_psymtabs;
-    pst->objfile->free_psymtabs = pst;
-
-    /* Indicate that psymtab was thrown away.  */
-    pst = (struct partial_symtab *)NULL;
-  }
+      && number_dependencies == 0
+      && pst->n_global_syms == 0
+      && pst->n_static_syms == 0)
+    {
+      /* Throw away this psymtab, it's empty.  We can't deallocate it, since
+         it is on the obstack, but we can forget to chain it on the list.  */
+      /* Indicate that psymtab was thrown away.  */
+
+      discard_psymtab (pst);
+
+      pst = (struct partial_symtab *) NULL;
+    }
   return pst;
 }
 \f
 static void
   return pst;
 }
 \f
 static void
-os9k_psymtab_to_symtab_1 (pst)
-     struct partial_symtab *pst;
+os9k_psymtab_to_symtab_1 (struct partial_symtab *pst)
 {
   struct cleanup *old_chain;
   int i;
 {
   struct cleanup *old_chain;
   int i;
-  
+
   if (!pst)
     return;
 
   if (pst->readin)
     {
       fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
   if (!pst)
     return;
 
   if (pst->readin)
     {
       fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
-              pst->filename);
+                         pst->filename);
       return;
     }
 
       return;
     }
 
@@ -1229,13 +1193,13 @@ os9k_psymtab_to_symtab_1 (pst)
            fputs_filtered ("and ", gdb_stdout);
            wrap_here ("");
            printf_filtered ("%s...", pst->dependencies[i]->filename);
            fputs_filtered ("and ", gdb_stdout);
            wrap_here ("");
            printf_filtered ("%s...", pst->dependencies[i]->filename);
-           wrap_here ("");             /* Flush output */
+           wrap_here ("");     /* Flush output */
            gdb_flush (gdb_stdout);
          }
        os9k_psymtab_to_symtab_1 (pst->dependencies[i]);
       }
 
            gdb_flush (gdb_stdout);
          }
        os9k_psymtab_to_symtab_1 (pst->dependencies[i]);
       }
 
-  if (LDSYMCNT(pst))           /* Otherwise it's a dummy */
+  if (LDSYMCNT (pst))          /* Otherwise it's a dummy */
     {
       /* Init stuff necessary for reading in symbols */
       stabsread_init ();
     {
       /* Init stuff necessary for reading in symbols */
       stabsread_init ();
@@ -1255,8 +1219,7 @@ os9k_psymtab_to_symtab_1 (pst)
    Be verbose about it if the user wants that.  */
 
 static void
    Be verbose about it if the user wants that.  */
 
 static void
-os9k_psymtab_to_symtab (pst)
-     struct partial_symtab *pst;
+os9k_psymtab_to_symtab (struct partial_symtab *pst)
 {
   bfd *sym_bfd;
 
 {
   bfd *sym_bfd;
 
@@ -1266,14 +1229,14 @@ os9k_psymtab_to_symtab (pst)
   if (pst->readin)
     {
       fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
   if (pst->readin)
     {
       fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
-              pst->filename);
+                         pst->filename);
       return;
     }
 
       return;
     }
 
-  if (LDSYMCNT(pst) || pst->number_of_dependencies)
+  if (LDSYMCNT (pst) || pst->number_of_dependencies)
     {
       /* Print the message now, before reading the string table,
     {
       /* Print the message now, before reading the string table,
-        to avoid disconcerting pauses.  */
+         to avoid disconcerting pauses.  */
       if (info_verbose)
        {
          printf_filtered ("Reading in symbols for %s...", pst->filename);
       if (info_verbose)
        {
          printf_filtered ("Reading in symbols for %s...", pst->filename);
@@ -1295,8 +1258,7 @@ os9k_psymtab_to_symtab (pst)
 
 /* Read in a defined section of a specific object file's symbols. */
 static void
 
 /* Read in a defined section of a specific object file's symbols. */
 static void
-os9k_read_ofile_symtab (pst)
-     struct partial_symtab *pst;
+os9k_read_ofile_symtab (struct partial_symtab *pst)
 {
   register struct internal_symstruct *bufp;
   unsigned char type;
 {
   register struct internal_symstruct *bufp;
   unsigned char type;
@@ -1306,15 +1268,13 @@ os9k_read_ofile_symtab (pst)
   int sym_offset;              /* Offset to start of symbols to read */
   CORE_ADDR text_offset;       /* Start of text segment for symbols */
   int text_size;               /* Size of text segment for symbols */
   int sym_offset;              /* Offset to start of symbols to read */
   CORE_ADDR text_offset;       /* Start of text segment for symbols */
   int text_size;               /* Size of text segment for symbols */
-  struct section_offsets *section_offsets;
   FILE *dbg_file;
 
   objfile = pst->objfile;
   FILE *dbg_file;
 
   objfile = pst->objfile;
-  sym_offset = LDSYMOFF(pst);
-  max_symnum = LDSYMCNT(pst);
+  sym_offset = LDSYMOFF (pst);
+  max_symnum = LDSYMCNT (pst);
   text_offset = pst->textlow;
   text_size = pst->texthigh - pst->textlow;
   text_offset = pst->textlow;
   text_size = pst->texthigh - pst->textlow;
-  section_offsets = pst->section_offsets;
 
   current_objfile = objfile;
   subfile_stack = NULL;
 
   current_objfile = objfile;
   subfile_stack = NULL;
@@ -1329,10 +1289,10 @@ os9k_read_ofile_symtab (pst)
      occurs before the N_SO symbol.
      Detecting this in read_dbx_symtab
      would slow down initial readin, so we look for it here instead. */
      occurs before the N_SO symbol.
      Detecting this in read_dbx_symtab
      would slow down initial readin, so we look for it here instead. */
-  if (!processing_acc_compilation && sym_offset >= (int)symbol_size)
+  if (!processing_acc_compilation && sym_offset >= (int) symbol_size)
     {
       fseek (objefile->auxf2, sym_offset, SEEK_CUR);
     {
       fseek (objefile->auxf2, sym_offset, SEEK_CUR);
-      fill_sym(objfile->auxf2, abfd);
+      fill_sym (objfile->auxf2, abfd);
       bufp = symbuf;
 
       processing_gcc_compilation = 0;
       bufp = symbuf;
 
       processing_gcc_compilation = 0;
@@ -1345,7 +1305,7 @@ os9k_read_ofile_symtab (pst)
        }
 
       /* Try to select a C++ demangling based on the compilation unit
        }
 
       /* Try to select a C++ demangling based on the compilation unit
-        producer. */
+         producer. */
 
       if (processing_gcc_compilation)
        {
 
       if (processing_gcc_compilation)
        {
@@ -1358,33 +1318,34 @@ os9k_read_ofile_symtab (pst)
   else
     {
       /* The N_SO starting this symtab is the first symbol, so we
   else
     {
       /* The N_SO starting this symtab is the first symbol, so we
-        better not check the symbol before it.  I'm not this can
-        happen, but it doesn't hurt to check for it.  */
+         better not check the symbol before it.  I'm not this can
+         happen, but it doesn't hurt to check for it.  */
       bfd_seek (symfile_bfd, sym_offset, SEEK_CUR);
       processing_gcc_compilation = 0;
     }
 #endif /* 0 */
 
       bfd_seek (symfile_bfd, sym_offset, SEEK_CUR);
       processing_gcc_compilation = 0;
     }
 #endif /* 0 */
 
-  fseek(dbg_file, (long)sym_offset, 0);
+  fseek (dbg_file, (long) sym_offset, 0);
 /*
 /*
-  if (bufp->n_type != (unsigned char)N_SYM_SYM)
-    error("First symbol in segment of executable not a source symbol");
-*/
+   if (bufp->n_type != (unsigned char)N_SYM_SYM)
+   error("First symbol in segment of executable not a source symbol");
+ */
 
   for (symnum = 0; symnum < max_symnum; symnum++)
     {
       QUIT;                    /* Allow this to be interruptable */
 
   for (symnum = 0; symnum < max_symnum; symnum++)
     {
       QUIT;                    /* Allow this to be interruptable */
-      fill_sym(dbg_file, abfd);
+      fill_sym (dbg_file, abfd);
       bufp = symbuf;
       type = bufp->n_type;
 
       bufp = symbuf;
       type = bufp->n_type;
 
-      os9k_process_one_symbol (type, bufp->n_desc, bufp->n_value,
-             bufp->n_strx, section_offsets, objfile);
+      os9k_process_one_symbol ((int) type, (int) bufp->n_desc,
+        (CORE_ADDR) bufp->n_value, bufp->n_strx, pst->section_offsets, objfile);
 
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
 #if 0
 
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
 #if 0
-      else if (type == N_TEXT)
+      else
+      if (type == N_TEXT)
        {
          /* I don't think this code will ever be executed, because
             the GCC_COMPILED_FLAG_SYMBOL usually is right before
        {
          /* I don't think this code will ever be executed, because
             the GCC_COMPILED_FLAG_SYMBOL usually is right before
@@ -1402,9 +1363,10 @@ os9k_read_ofile_symtab (pst)
              set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
            }
        }
              set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
            }
        }
-      else if (type & N_EXT || type == (unsigned char)N_TEXT
-              || type == (unsigned char)N_NBTEXT
-              ) {
+      else if (type & N_EXT || type == (unsigned char) N_TEXT
+              || type == (unsigned char) N_NBTEXT
+       )
+       {
          /* Global symbol: see if we came across a dbx defintion for
             a corresponding symbol.  If so, store the value.  Remove
             syms from the chain when their values are stored, but
          /* Global symbol: see if we came across a dbx defintion for
             a corresponding symbol.  If so, store the value.  Remove
             syms from the chain when their values are stored, but
@@ -1415,7 +1377,7 @@ os9k_read_ofile_symtab (pst)
             be satisfied in each file as it appears. So we skip this
             section. */
          ;
             be satisfied in each file as it appears. So we skip this
             section. */
          ;
-        }
+       }
 #endif /* 0 */
     }
 
 #endif /* 0 */
     }
 
@@ -1426,12 +1388,11 @@ os9k_read_ofile_symtab (pst)
      which comes from pst->textlow is correct. */
   if (last_source_start_addr == 0)
     last_source_start_addr = text_offset;
      which comes from pst->textlow is correct. */
   if (last_source_start_addr == 0)
     last_source_start_addr = text_offset;
-  pst->symtab = end_symtab (text_offset + text_size, 0, 0, objfile,
-                           SECT_OFF_TEXT);
+  pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
   end_stabs ();
 }
   end_stabs ();
 }
-
 \f
 \f
+
 /* This handles a single symbol from the symbol-file, building symbols
    into a GDB symtab.  It takes these arguments and an implicit argument.
 
 /* This handles a single symbol from the symbol-file, building symbols
    into a GDB symtab.  It takes these arguments and an implicit argument.
 
@@ -1440,19 +1401,16 @@ os9k_read_ofile_symtab (pst)
    VALU is the value field of the ".stab" entry.
    NAME is the symbol name, in our address space.
    SECTION_OFFSETS is a set of amounts by which the sections of this object
    VALU is the value field of the ".stab" entry.
    NAME is the symbol name, in our address space.
    SECTION_OFFSETS is a set of amounts by which the sections of this object
-          file were relocated when it was loaded into memory.
-          All symbols that refer
-         to memory locations need to be offset by these amounts.
+   file were relocated when it was loaded into memory.
+   All symbols that refer
+   to memory locations need to be offset by these amounts.
    OBJFILE is the object file from which we are reading symbols.
    OBJFILE is the object file from which we are reading symbols.
-              It is used in end_symtab.  */
+   It is used in end_symtab.  */
 
 static void
 
 static void
-os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
-     int type, desc;
-     CORE_ADDR valu;
-     char *name;
-     struct section_offsets *section_offsets;
-     struct objfile *objfile;
+os9k_process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
+                        struct section_offsets *section_offsets,
+                        struct objfile *objfile)
 {
   register struct context_stack *new;
   /* The stab type used for the definition of the last function.
 {
   register struct context_stack *new;
   /* The stab type used for the definition of the last function.
@@ -1462,12 +1420,12 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
 #if 0
   /* Something is wrong if we see real data before
      seeing a source file name.  */
 #if 0
   /* Something is wrong if we see real data before
      seeing a source file name.  */
-  if (last_source_file == NULL && type != (unsigned char)N_SO)
+  if (last_source_file == NULL && type != (unsigned char) N_SO)
     {
     {
-      /* Ignore any symbols which appear before an N_SO symbol.  Currently
-        no one puts symbols there, but we should deal gracefully with the
-        case.  A complain()t might be in order (if !IGNORE_SYMBOL (type)),
-        but this should not be an error ().  */
+      /* Ignore any symbols which appear before an N_SO symbol.
+         Currently no one puts symbols there, but we should deal
+         gracefully with the case.  A complain()t might be in order,
+         but this should not be an error ().  */
       return;
     }
 #endif /* 0 */
       return;
     }
 #endif /* 0 */
@@ -1476,20 +1434,20 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     {
     case N_SYM_LBRAC:
       /* On most machines, the block addresses are relative to the
     {
     case N_SYM_LBRAC:
       /* On most machines, the block addresses are relative to the
-        N_SO, the linker did not relocate them (sigh).  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); 
+         N_SO, the linker did not relocate them (sigh).  */
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
       new = push_context (desc, valu);
       break;
 
     case N_SYM_RBRAC:
       new = push_context (desc, valu);
       break;
 
     case N_SYM_RBRAC:
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); 
-      new = pop_context();
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      new = pop_context ();
 
 #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
 #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1
 #endif
 
 
 #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
 #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1
 #endif
 
-      if (!OS9K_VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
+      if (!OS9K_VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
        local_symbols = new->locals;
 
       if (context_stack_depth > 1)
        local_symbols = new->locals;
 
       if (context_stack_depth > 1)
@@ -1503,7 +1461,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          if (local_symbols != NULL)
            {
              /* Muzzle a compiler bug that makes end < start.  (which
          if (local_symbols != NULL)
            {
              /* Muzzle a compiler bug that makes end < start.  (which
-                compilers?  Is this ever harmful?).  */
+                compilers?  Is this ever harmful?).  */
              if (new->start_addr > valu)
                {
                  complain (&lbrac_rbrac_complaint);
              if (new->start_addr > valu)
                {
                  complain (&lbrac_rbrac_complaint);
@@ -1521,23 +1479,26 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
              within_function = 0;
              /* Make a block for the local symbols within.  */
              finish_block (new->name, &local_symbols, new->old_blocks,
              within_function = 0;
              /* Make a block for the local symbols within.  */
              finish_block (new->name, &local_symbols, new->old_blocks,
-                       new->start_addr, valu, objfile);
+                           new->start_addr, valu, objfile);
            }
          else
            {
              /* attach local_symbols to the end of new->locals */
            }
          else
            {
              /* attach local_symbols to the end of new->locals */
-             if (!new->locals) new->locals = local_symbols;
-             else {
-               struct pending *p;
+             if (!new->locals)
+               new->locals = local_symbols;
+             else
+               {
+                 struct pending *p;
 
 
-               p = new->locals;
-               while (p->next) p = p->next; 
-               p->next = local_symbols;
-             }
+                 p = new->locals;
+                 while (p->next)
+                   p = p->next;
+                 p->next = local_symbols;
+               }
            }
        }
 
            }
        }
 
-      if (OS9K_VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
+      if (OS9K_VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
        /* Now pop locals of block just finished.  */
        local_symbols = new->locals;
       break;
        /* Now pop locals of block just finished.  */
        local_symbols = new->locals;
       break;
@@ -1545,15 +1506,17 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
 
     case N_SYM_SLINE:
       /* This type of "symbol" really just records
 
     case N_SYM_SLINE:
       /* This type of "symbol" really just records
-        one line-number -- core-address correspondence.
-        Enter it in the line list for this symbol table.  */
+         one line-number -- core-address correspondence.
+         Enter it in the line list for this symbol table. */
       /* Relocate for dynamic loading and for ELF acc fn-relative syms.  */
       /* Relocate for dynamic loading and for ELF acc fn-relative syms.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); 
-      record_line (current_subfile, (int)name, valu);
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      /* FIXME: loses if sizeof (char *) > sizeof (int) */
+      gdb_assert (sizeof (name) <= sizeof (int));
+      record_line (current_subfile, (int) name, valu);
       break;
 
       break;
 
-    /* The following symbol types need to have the appropriate offset added
-       to their value; then we process symbol definitions in the name.  */
+      /* The following symbol types need to have the appropriate offset added
+         to their value; then we process symbol definitions in the name.  */
     case N_SYM_SYM:
 
       if (name)
     case N_SYM_SYM:
 
       if (name)
@@ -1570,34 +1533,42 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          switch (deftype)
            {
            case 'S':
          switch (deftype)
            {
            case 'S':
-             valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-             n = strrchr(name, '/');
-             if (n != NULL) {
-               *n = '\0';
-               n++;
-               dirn = name;
-             } else {
-               n = name;
-               dirn = NULL;
-             }
+             valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+             n = strrchr (name, '/');
+             if (n != NULL)
+               {
+                 *n = '\0';
+                 n++;
+                 dirn = name;
+               }
+             else
+               {
+                 n = name;
+                 dirn = NULL;
+               }
              *p = '\0';
              *p = '\0';
-             if (symfile_depth++ == 0) {
-               if (last_source_file) {
-                 end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT);
-                 end_stabs ();
+             if (symfile_depth++ == 0)
+               {
+                 if (last_source_file)
+                   {
+                     end_symtab (valu, objfile, SECT_OFF_TEXT (objfile));
+                     end_stabs ();
+                   }
+                 start_stabs ();
+                 os9k_stabs = 1;
+                 start_symtab (n, dirn, valu);
+                 record_debugformat ("OS9");
+               }
+             else
+               {
+                 push_subfile ();
+                 start_subfile (n, dirn != NULL ? dirn : current_subfile->dirname);
                }
                }
-               start_stabs ();
-               os9k_stabs = 1;
-               start_symtab (n, dirn, valu);
-             } else {
-               push_subfile();
-               start_subfile (n, dirn!=NULL ? dirn : current_subfile->dirname);
-             }
              break;
 
            case 'f':
            case 'F':
              break;
 
            case 'f':
            case 'F':
-              valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+             valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
              function_stab_type = type;
 
              within_function = 1;
              function_stab_type = type;
 
              within_function = 1;
@@ -1607,7 +1578,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
 
            case 'V':
            case 'v':
 
            case 'V':
            case 'v':
-              valu += ANOFFSET (section_offsets, SECT_OFF_DATA);
+             valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
              define_symbol (valu, name, desc, type, objfile);
              break;
 
              define_symbol (valu, name, desc, type, objfile);
              break;
 
@@ -1619,13 +1590,13 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
       break;
 
     case N_SYM_SE:
       break;
 
     case N_SYM_SE:
-       if (--symfile_depth != 0)
-         start_subfile(pop_subfile(), current_subfile->dirname);
+      if (--symfile_depth != 0)
+       start_subfile (pop_subfile (), current_subfile->dirname);
       break;
 
     default:
       complain (&unknown_symtype_complaint,
       break;
 
     default:
       complain (&unknown_symtype_complaint,
-               local_hex_string((unsigned long) type));
+               local_hex_string ((unsigned long) type));
       /* FALLTHROUGH */
       break;
 
       /* FALLTHROUGH */
       break;
 
@@ -1634,43 +1605,20 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     }
   previous_stab_code = type;
 }
     }
   previous_stab_code = type;
 }
-\f
-/* Parse the user's idea of an offset for dynamic linking, into our idea
-   of how to represent it for fast symbol reading.  */
-
-static struct section_offsets *
-os9k_symfile_offsets (objfile, addr)
-     struct objfile *objfile;
-     CORE_ADDR addr;
-{
-  struct section_offsets *section_offsets;
-  int i;
-
-  objfile->num_sections = SECT_OFF_MAX;
-  section_offsets = (struct section_offsets *)
-    obstack_alloc (&objfile -> psymbol_obstack,
-                  sizeof (struct section_offsets)
-                  + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
 
 
-  for (i = 0; i < SECT_OFF_MAX; i++)
-    ANOFFSET (section_offsets, i) = addr;
-  
-  return section_offsets;
-}
-\f
 static struct sym_fns os9k_sym_fns =
 {
   bfd_target_os9k_flavour,
 static struct sym_fns os9k_sym_fns =
 {
   bfd_target_os9k_flavour,
-  os9k_new_init,       /* sym_new_init: init anything gbl to entire symtab */
-  os9k_symfile_init,   /* sym_init: read initial info, setup for sym_read() */
-  os9k_symfile_read,   /* sym_read: read a symbol file into symtab */
-  os9k_symfile_finish, /* sym_finish: finished with file, cleanup */
-  os9k_symfile_offsets,        /* sym_offsets: parse user's offsets to internal form*/
-  NULL                 /* next: pointer to next struct sym_fns */
+  os9k_new_init,               /* sym_new_init: init anything gbl to entire symtab */
+  os9k_symfile_init,           /* sym_init: read initial info, setup for sym_read() */
+  os9k_symfile_read,           /* sym_read: read a symbol file into symtab */
+  os9k_symfile_finish,         /* sym_finish: finished with file, cleanup */
+  default_symfile_offsets,     /* sym_offsets: parse user's offsets to internal form */
+  NULL                         /* next: pointer to next struct sym_fns */
 };
 
 void
 };
 
 void
-_initialize_os9kread ()
+_initialize_os9kread (void)
 {
 {
-  add_symtab_fns(&os9k_sym_fns);
+  add_symtab_fns (&os9k_sym_fns);
 }
 }
This page took 0.052388 seconds and 4 git commands to generate.