* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / paread.c
index 46a6e3d2537001495251391fa7a8bbcdcb6c6be8..d21aa54d26d9fd1277279d1550cf2f476eafe067 100644 (file)
@@ -20,18 +20,25 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include "defs.h"
 #include "bfd.h"
+#include <time.h> /* For time_t in libbfd.h.  */
+#include <sys/types.h> /* For time_t, if not in time.h.  */
 #include "libbfd.h"
-#include "libhppa.h"
+#include "som.h"
 #include <syms.h>
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
 #include "buildsym.h"
+#include "stabsread.h"
 #include "gdb-stabs.h"
 #include "complaints.h"
 #include <string.h>
 #include "demangle.h"
 #include <sys/file.h>
+
+/* Size of n_value and n_strx fields in a stab symbol.  */
+#define BYTES_IN_WORD 4
+
 #include "aout/aout64.h"
 
 /* Various things we might complain about... */
@@ -105,7 +112,8 @@ pa_symtab_read (abfd, addr, objfile)
   unsigned int i;
   int val;
   char *stringtab;
-  struct symbol_dictionary_record *buf, *bufp;
+  struct symbol_dictionary_record *buf, *bufp, *endbufp;
+  char *symname;
   CONST int symsize = sizeof (struct symbol_dictionary_record);
 
   number_of_symbols = bfd_get_symcount (abfd);
@@ -121,41 +129,96 @@ pa_symtab_read (abfd, addr, objfile)
   val = bfd_read (stringtab, obj_stringtab_size (abfd), 1, abfd);
   if (val != obj_stringtab_size (abfd))
     error ("Can't read in HP string table.");
-  
-  for (i = 0, bufp = buf; i < number_of_symbols; i++, bufp++)
+
+  endbufp = buf + number_of_symbols;
+  for (bufp = buf; bufp < endbufp; ++bufp)
     {
       enum minimal_symbol_type ms_type;
 
       QUIT;
 
-      if (bufp->symbol_scope != SS_UNIVERSAL)
-       continue;
-
-      switch (bufp->symbol_type)
-        {
-        case ST_SYM_EXT:
-        case ST_ARG_EXT:
-          continue;
-        case ST_CODE:
-        case ST_PRI_PROG:
-        case ST_SEC_PROG:
-        case ST_ENTRY:
-        case ST_MILLICODE:
-          ms_type = mst_text;
-          bufp->symbol_value &= ~0x3; /* clear out permission bits */
-          break;
-        case ST_DATA:
-          ms_type = mst_data;
-          break;
-        default:
-          continue;
-        }
+      switch (bufp->symbol_scope)
+       {
+       case SS_UNIVERSAL:
+         switch (bufp->symbol_type)
+           {
+           case ST_SYM_EXT:
+           case ST_ARG_EXT:
+             continue;
+
+           case ST_CODE:
+           case ST_PRI_PROG:
+           case ST_SEC_PROG:
+           case ST_ENTRY:
+           case ST_MILLICODE:
+             symname = bufp->name.n_strx + stringtab;
+             ms_type = mst_text;
+             bufp->symbol_value &= ~0x3; /* clear out permission bits */
+             break;
+           case ST_DATA:
+             symname = bufp->name.n_strx + stringtab;
+             ms_type = mst_data;
+             break;
+           default:
+             continue;
+           }
+         break;
+
+#if 0
+         /* SS_GLOBAL and SS_LOCAL are two names for the same thing (!).  */
+       case SS_GLOBAL:
+#endif
+       case SS_LOCAL:
+         switch (bufp->symbol_type)
+           {
+           case ST_SYM_EXT:
+           case ST_ARG_EXT:
+             continue;
+
+           case ST_CODE:
+             symname = bufp->name.n_strx + stringtab;
+             ms_type = mst_file_text;
+             bufp->symbol_value &= ~0x3; /* clear out permission bits */
+
+           check_strange_names:
+             /* GAS leaves symbols with the prefixes "LS$", "LBB$",
+                and "LBE$" in .o files after assembling.  And thus
+                they appear in the final executable.  This can
+                cause problems if these special symbols have the
+                same value as real symbols.  So ignore them.  Also "LC$".  */
+             if (*symname == 'L'
+                 && (symname[2] == '$' || symname[3] == '$'))
+               continue;
+             break;
+
+           case ST_PRI_PROG:
+           case ST_SEC_PROG:
+           case ST_ENTRY:
+           case ST_MILLICODE:
+             symname = bufp->name.n_strx + stringtab;
+             ms_type = mst_file_text;
+             bufp->symbol_value &= ~0x3; /* clear out permission bits */
+             break;
+
+           case ST_DATA:
+             symname = bufp->name.n_strx + stringtab;
+             ms_type = mst_file_data;
+             goto check_strange_names;
+
+           default:
+             continue;
+           }
+         break;
+
+       default:
+         continue;
+       }
 
       if (bufp->name.n_strx > obj_stringtab_size (abfd))
        error ("Invalid symbol data; bad HP string table offset: %d",
               bufp->name.n_strx);
 
-      record_minimal_symbol (bufp->name.n_strx + stringtab,
+      record_minimal_symbol (symname,
                             bufp->symbol_value, ms_type, 
                             objfile);
     }
@@ -262,7 +325,7 @@ pa_symfile_read (objfile, section_offsets, mainline)
   do_cleanups (back_to);
 }
 
-/* This cleans up the objfile's sym_private pointer, and the chain of
+/* This cleans up the objfile's sym_stab_info pointer, and the chain of
    stab_section_info's, that might be dangling from it.  */
 
 static void
@@ -271,7 +334,7 @@ free_painfo (objp)
 {
   struct objfile *objfile = (struct objfile *)objp;
   struct dbx_symfile_info *dbxinfo = (struct dbx_symfile_info *)
-                                    objfile->sym_private;
+                                    objfile->sym_stab_info;
   struct stab_section_info *ssi, *nssi;
 
   ssi = dbxinfo->stab_section_info;
@@ -308,9 +371,9 @@ static void
 pa_symfile_finish (objfile)
      struct objfile *objfile;
 {
-  if (objfile -> sym_private != NULL)
+  if (objfile -> sym_stab_info != NULL)
     {
-      mfree (objfile -> md, objfile -> sym_private);
+      mfree (objfile -> md, objfile -> sym_stab_info);
     }
 }
 
@@ -338,10 +401,10 @@ pa_symfile_init (objfile)
   stringsect = bfd_get_section_by_name (sym_bfd, "$GDB_STRINGS$");
 
   /* Allocate struct to keep track of the symfile */
-  objfile->sym_private = (PTR)
+  objfile->sym_stab_info = (PTR)
     xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
 
-  memset ((PTR) objfile->sym_private, 0, sizeof (struct dbx_symfile_info));
+  memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
 
   if (!stabsect)
     return;
@@ -360,6 +423,9 @@ pa_symfile_init (objfile)
   if (!DBX_TEXT_SECT (objfile))
     error ("Can't find .text section in symbol file");
 
+  /* FIXME: I suspect this should be external_nlist.  The size of host
+     types like long and bfd_vma should not affect how we read the
+     file.  */
   DBX_SYMBOL_SIZE (objfile) = sizeof (struct internal_nlist);
   DBX_SYMCOUNT (objfile) = bfd_section_size (sym_bfd, stabsect)
     / DBX_SYMBOL_SIZE (objfile);
@@ -399,8 +465,14 @@ pa_symfile_init (objfile)
     perror_with_name (name);
   val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1,
                  sym_bfd);
-  if (val != DBX_STRINGTAB_SIZE (objfile))
+  if (val == 0)
+    error ("End of file reading string table");
+  else if (val < 0)
+    /* It's possible bfd_read should be setting bfd_error, and we should be
+       checking that.  But currently it doesn't set bfd_error.  */
     perror_with_name (name);
+  else if (val != DBX_STRINGTAB_SIZE (objfile))
+    error ("Short read reading string table");
 }
 
 /* PA specific parsing routine for section offsets.
This page took 0.025918 seconds and 4 git commands to generate.