For d10v, do not sign-extend pointers.
[deliverable/binutils-gdb.git] / gdb / os9kread.c
index 7a392925b1f634216e57383d4db014718a2c6e24..e143090e13ddde79a987e7eae476ed643734ed47 100644 (file)
@@ -1,5 +1,5 @@
 /* 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, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -16,7 +16,7 @@ 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.  */
+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 
@@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    for real.  os9k_psymtab_to_symtab() is the function that does this */
 
 #include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
 #include <stdio.h>
 
 #if defined(USG) || defined(__CYGNUSCLIB__)
@@ -41,19 +41,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #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 "libbfd.h"            /* FIXME Secret internal BFD stuff (bfd_read) */
 #include "libaout.h"           /* FIXME Secret internal BFD stuff for a.out */
 #include "symfile.h"
 #include "objfiles.h"
@@ -65,11 +60,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "os9k.h"
 #include "stabsread.h"
 
-#if !defined (SEEK_SET)
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#endif
-
 /* 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
    to a full symbol table entry.
@@ -105,9 +95,6 @@ extern int info_verbose;
 
 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;
@@ -125,14 +112,19 @@ extern struct complaint repeated_header_complaint;
 
 extern struct complaint repeated_header_name_complaint;
 
+#if 0
 static struct complaint lbrac_unmatched_complaint =
   {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
 
 static struct complaint lbrac_mismatch_complaint =
   {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
-
+#endif
 \f
 /* Local function prototypes */
+
+static void
+read_minimal_symbols PARAMS ((struct objfile *, struct section_offsets *));
+
 static void
 os9k_read_ofile_symtab PARAMS ((struct partial_symtab *));
 
@@ -146,12 +138,6 @@ static void
 read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *,
                          CORE_ADDR, int));
 
-static void
-init_psymbol_list PARAMS ((struct objfile *));
-
-static char *
-os9k_next_symbol_text PARAMS ((void));
-
 static int
 fill_sym PARAMS ((FILE *, bfd *));
 
@@ -173,15 +159,16 @@ os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *,
 
 static struct partial_symtab *
 os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *,
-                       CORE_ADDR, int, int, struct partial_symbol *,
-                       struct partial_symbol *));
+                       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 void
-record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
+record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *, 
+                    struct section_offsets *));
 \f
 #define HANDLE_RBRAC(val) \
   if ((val) > pst->texthigh) pst->texthigh = (val);
@@ -207,28 +194,41 @@ record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
 #define N_ABS 6
 
 static void
-record_minimal_symbol (name, address, type, objfile)
+record_minimal_symbol (name, address, type, objfile, section_offsets)
      char *name;
      CORE_ADDR address;
      int type;
      struct objfile *objfile;
+     struct section_offsets *section_offsets;
 {
   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(section_offsets, SECT_OFF_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;
   }
 
-  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 */
@@ -249,9 +249,10 @@ struct stbsymbol {
 };
 #define STBSYMSIZE 10
 
-static int 
-read_minimal_symbols(objfile)
+static void
+read_minimal_symbols(objfile, section_offsets)
      struct objfile *objfile;
+     struct section_offsets *section_offsets;
 {
 FILE *fp;
 bfd *abfd;
@@ -272,6 +273,7 @@ char buf[64], buf1[128];
     if (ch == 0) break;
     ch = getc(fp);
   };
+  if (i%2) ch=getc(fp);
   hdr.name = &buf[0];
 
   fread(&hdr.fmtno, sizeof(hdr.fmtno), 1, fp);
@@ -298,11 +300,11 @@ char buf[64], buf1[128];
        if (ch == 0) break;
        ch = getc(fp);
     };
-    record_minimal_symbol(buf1, sym.value, sym.type&7, objfile);
+    record_minimal_symbol(buf1, sym.value, sym.type&7, objfile, section_offsets);
     off += STBSYMSIZE;
   };
   install_minimal_symbols (objfile);
-  return 1;
+  return;
 }
 \f
 /* Scan and build partial symbols for a symbol file.
@@ -322,33 +324,25 @@ os9k_symfile_read (objfile, section_offsets, mainline)
      int mainline;     /* FIXME comments above */
 {
   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 */
   if (mainline || objfile->global_psymbols.size == 0 || 
     objfile->static_psymbols.size == 0)
-    init_psymbol_list (objfile);
+    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
 
-  pending_blocks = 0;
+  free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
   make_cleanup (discard_minimal_symbols, 0);
-  read_minimal_symbols (objfile);
+  read_minimal_symbols (objfile, section_offsets);
 
   /* 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 ("");
-  }
+                    DBX_TEXT_ADDR (objfile),
+                    DBX_TEXT_SIZE (objfile));
 
   do_cleanups (back_to);
 }
@@ -383,13 +377,12 @@ static void
 os9k_symfile_init (objfile)
      struct objfile *objfile;
 {
-  int val;
   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;
-
+  asection *text_sect;
 
   strcpy(dbgname, name);
   strcat(dbgname, ".dbg");
@@ -411,9 +404,11 @@ os9k_symfile_init (objfile)
     xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
   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");
+  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) */
@@ -439,13 +434,14 @@ os9k_symfile_finish (objfile)
 }
 
 \f
-struct dbghdr {
+struct st_dbghdr {
   int sync;
   short rev;
   int crc;
   short os;
   short cpu;
 };
+#define SYNC           (int)0xefbefeca
 
 #define SWAP_DBGHDR(hdrp, abfd) \
   { \
@@ -471,17 +467,22 @@ struct internal_symstruct {
 };
 static struct internal_symstruct symbol;
 static struct internal_symstruct *symbuf = &symbol;
-static char strbuf[256];
+static char strbuf[4096];
+static struct st_dbghdr dbghdr;
+static short cmplrid;
+
+#define VER_PRE_ULTRAC ((short)4)
+#define VER_ULTRAC     ((short)5)
 
 static int
 fill_sym (dbg_file, abfd)
      FILE *dbg_file;
      bfd *abfd;
 {
-short id;
-short si;
+short si, nmask;
 long li;
 int ii;
+char *p;
 
   int nbytes = fread(&si, sizeof(si), 1, dbg_file);
   if (nbytes == 0)
@@ -498,6 +499,7 @@ int ii;
     case N_SYM_CMPLR:
       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:
       fread(&li, sizeof(li), 1, dbg_file);
@@ -516,6 +518,15 @@ int ii;
        strbuf[si++] = (char) ii;
       } while (ii != 0 || si % 2 != 0);
       symbuf->n_strx = strbuf;
+      p = (char *) strchr (strbuf, ':');
+      if (!p) break;
+      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);
+       }
       break;
     case N_SYM_LBRAC:
       fread(&li, sizeof(li), 1, dbg_file);
@@ -531,30 +542,6 @@ int ii;
     return 1;
 }
 \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.
@@ -571,13 +558,13 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
 {
   register struct internal_symstruct *bufp = 0;        /* =0 avoids gcc -Wall glitch*/
   register char *namestring;
-  int nsl;
   int past_first_source_file = 0;
   CORE_ADDR last_o_file_start = 0;
+#if 0
   struct cleanup *back_to;
+#endif
   bfd *abfd;
   FILE *fp;
-  struct dbghdr hdr;
 
   /* End of the text segment of the executable file.  */
   static CORE_ADDR end_of_text_addr;
@@ -616,13 +603,14 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
 
   abfd = objfile->obfd;
   fp = objfile->auxf2; 
+  if (!fp) return;
                
-  fread(&hdr.sync, sizeof(hdr.sync), 1, fp);
-  fread(&hdr.rev, sizeof(hdr.rev), 1, fp);
-  fread(&hdr.crc, sizeof(hdr.crc), 1, fp);
-  fread(&hdr.os, sizeof(hdr.os), 1, fp);
-  fread(&hdr.cpu, sizeof(hdr.cpu), 1, fp);
-  SWAP_DBGHDR(&hdr, abfd);      
+  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;
   while(1)
@@ -684,33 +672,43 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
              {
                unsigned long valu;
                enum language tmp_language;
+               char *str, *p;
+               int n;
                
-               valu = CUR_SYMBOL_VALUE + 
-                 ANOFFSET (section_offsets, SECT_OFF_TEXT);
+               valu = CUR_SYMBOL_VALUE;
+               if (valu)
+                 valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
                past_first_source_file = 1;
 
+                p = strchr(namestring, ':');
+                if (p) n = p-namestring;
+                else n = strlen(namestring);
+                str = alloca(n+1);
+                strncpy(str, namestring, n);
+                str[n] = '\0';
+
                if (psymfile_depth == 0) {
                  if (!pst)
                    pst = os9k_start_psymtab (objfile, section_offsets,
-                                namestring, valu,
+                                str, 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);
+                 tmp_language = deduce_language_from_filename (str);
                  if (tmp_language != language_unknown
                        && (tmp_language != language_c
                        || psymtab_language != language_cplus))
                        psymtab_language = tmp_language;
 
 /*
-                 if (pst && STREQ (namestring, pst->filename))
+                 if (pst && STREQ (str, pst->filename))
                    continue;
                  {
                    register int i;
                    for (i = 0; i < includes_used; i++)
-                     if (STREQ (namestring, psymtab_include_list[i]))
+                     if (STREQ (str, psymtab_include_list[i]))
                        {
                          i = -1; 
                          break;
@@ -720,7 +718,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                  }
 */
 
-                  psymtab_include_list[includes_used++] = namestring;
+                  psymtab_include_list[includes_used++] = str;
                   if (includes_used >= includes_allocated)
                     {
                       char **orig = psymtab_include_list;
@@ -737,35 +735,35 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
              }
 
            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':
-             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... */
                {
-                 ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+                 add_psymbol_to_list (namestring, p - namestring,
                                       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.  */
-                     ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+                     add_psymbol_to_list (namestring, p - namestring,
                                           VAR_NAMESPACE, LOC_TYPEDEF,
-                                          objfile->static_psymbols,
-                                          CUR_SYMBOL_VALUE, psymtab_language,
+                                          &objfile->static_psymbols,
+                                          CUR_SYMBOL_VALUE, 0, psymtab_language,
                                           objfile);
                      p += 1;
                    }
@@ -777,10 +775,10 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                  else if (psymtab_language == language_cplus)
                   {
                      /* 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,
-                                          objfile->static_psymbols,
-                                          CUR_SYMBOL_VALUE, psymtab_language,
+                                          &objfile->static_psymbols,
+                                          CUR_SYMBOL_VALUE, 0, psymtab_language,
                                           objfile);
                   }
                }
@@ -788,10 +786,10 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
            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,
-                                      objfile->static_psymbols,
-                                      CUR_SYMBOL_VALUE,
+                                      &objfile->static_psymbols,
+                                      CUR_SYMBOL_VALUE, 0,
                                       psymtab_language, objfile);
                }
            check_enum:
@@ -832,7 +830,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                      /* Check for and handle cretinous dbx symbol name
                         continuation! 
                      if (*p == '\\')
-                       p = next_symbol_text ();
+                       p = next_symbol_text (objfile);
                      */
 
                      /* Point to the character after the name
@@ -841,10 +839,10 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                        ;
                      /* Note that the value doesn't matter for
                         enum constants in psymtabs, just in symtabs.  */
-                     ADD_PSYMBOL_TO_LIST (p, q - p,
+                     add_psymbol_to_list (p, q - p,
                                           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.  */
@@ -858,10 +856,10 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
              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,
-                                  objfile->static_psymbols, CUR_SYMBOL_VALUE,
-                                  psymtab_language, objfile);
+                                  &objfile->static_psymbols, CUR_SYMBOL_VALUE,
+                                  0, psymtab_language, objfile);
              continue;
 
            case 'f':
@@ -869,10 +867,10 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
               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,
-                                  objfile->static_psymbols, CUR_SYMBOL_VALUE,
-                                  psymtab_language, objfile);
+                                  &objfile->static_psymbols, CUR_SYMBOL_VALUE,
+                                  0, psymtab_language, objfile);
              continue;
 
            case 'F':
@@ -880,14 +878,15 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
               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,
-                                  objfile->global_psymbols, CUR_SYMBOL_VALUE,
-                                  psymtab_language, objfile);
+                                  &objfile->global_psymbols, CUR_SYMBOL_VALUE,
+                                  0, psymtab_language, objfile);
              continue;
 
            case 'p':
            case 'l':
+            case 's':
              continue;
 
            case ':':
@@ -971,8 +970,8 @@ os9k_start_psymtab (objfile, section_offsets,
      CORE_ADDR textlow;
      int ldsymoff;
      int ldsymcnt;
-     struct partial_symbol *global_syms;
-     struct partial_symbol *static_syms;
+     struct partial_symbol **global_syms;
+     struct partial_symbol **static_syms;
 {
   struct partial_symtab *result =
       start_psymtab_common(objfile, section_offsets,
@@ -1004,7 +1003,7 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
      CORE_ADDR capping_text;
      struct partial_symtab **dependency_list;
      int number_dependencies;
-/*     struct partial_symbol *capping_global, *capping_static;*/
+     /* struct partial_symbol *capping_global, *capping_static; */
 {
   int i;
   struct partial_symtab *p1;
@@ -1049,7 +1048,7 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
     strncpy (p, last_function_name, n);
     p[n] = 0;
     
-    minsym = lookup_minimal_symbol (p, objfile);
+    minsym = lookup_minimal_symbol (p, NULL, objfile);
 
     if (minsym) {
       pst->texthigh = SYMBOL_VALUE_ADDRESS(minsym)+(long)MSYMBOL_INFO(minsym);
@@ -1161,22 +1160,10 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
    && 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;
+    /* Indicate that psymtab was thrown away.  */
 
-    /* Next, put it on a free list for recycling */
-    pst->next = pst->objfile->free_psymtabs;
-    pst->objfile->free_psymtabs = pst;
+    discard_psymtab (pst);
 
-    /* Indicate that psymtab was thrown away.  */
     pst = (struct partial_symtab *)NULL;
   }
   return pst;
@@ -1360,8 +1347,8 @@ os9k_read_ofile_symtab (pst)
       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, section_offsets, objfile);
 
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
@@ -1408,8 +1395,7 @@ os9k_read_ofile_symtab (pst)
      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);
   end_stabs ();
 }
 
@@ -1459,12 +1445,12 @@ 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
         N_SO, the linker did not relocate them (sigh).  */
-      valu += last_source_start_addr;
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); 
       new = push_context (desc, valu);
       break;
 
     case N_SYM_RBRAC:
-      valu += last_source_start_addr;
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); 
       new = pop_context();
 
 #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
@@ -1528,9 +1514,10 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     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.  */
+        Enter it in the line list for this symbol table. */
       /* Relocate for dynamic loading and for ELF acc fn-relative syms.  */
-      valu += last_source_start_addr;
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); 
+      /* FIXME: loses if sizeof (char *) > sizeof (int) */
       record_line (current_subfile, (int)name, valu);
       break;
 
@@ -1565,12 +1552,13 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
              *p = '\0';
              if (symfile_depth++ == 0) {
                if (last_source_file) {
-                 end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT);
+                 end_symtab (valu, objfile, SECT_OFF_TEXT);
                  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);
@@ -1616,30 +1604,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     }
   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,
@@ -1647,7 +1612,8 @@ static struct sym_fns os9k_sym_fns =
   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*/
+  default_symfile_offsets,
+                       /* sym_offsets: parse user's offsets to internal form*/
   NULL                 /* next: pointer to next struct sym_fns */
 };
 
This page took 0.034419 seconds and 4 git commands to generate.