use remote-utils facilities for baud_rate
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 012fac20119951405e4b30ebd6a5ab11c2fc7214..cc0c43ea9f7bdee82085178f13037a8bd227760b 100644 (file)
@@ -407,8 +407,8 @@ explicit_lookup_type (real_filenum, index)
       f->length *= 2;
       f->vector = (struct type **)
        xrealloc (f->vector, f->length * sizeof (struct type *));
-      bzero (&f->vector[f->length / 2],
-            f->length * sizeof (struct type *) / 2);
+      memset (&f->vector[f->length / 2],
+            '\0', f->length * sizeof (struct type *) / 2);
     }
   return &f->vector[index];
 }
@@ -438,10 +438,28 @@ record_minimal_symbol (name, address, type, objfile)
       ms_type = mst_file_data;
       break;
 #endif
+    case N_TEXT:
+      /* Don't put gcc_compiled, __gnu_compiled_cplus, and friends into
+        the minimal symbols, because if there is also another symbol
+        at the same address (e.g. the first function of the file),
+        lookup_minimal_symbol_by_pc would have no way of getting the
+        right one.  */
+      if (name[0] == 'g'
+         && (strcmp (name, GCC_COMPILED_FLAG_SYMBOL) == 0
+             || strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0))
+       return;
+
+      {
+       char *tempstring = name;
+       if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))
+         ++tempstring;
+       if (STREQN (tempstring, "__gnu_compiled", 14))
+         return;
+      }
+
     case N_NBTEXT:
     case N_FN:
     case N_FN_SEQ:
-    case N_TEXT:
       ms_type = mst_file_text;
       break;
 
@@ -450,9 +468,8 @@ record_minimal_symbol (name, address, type, objfile)
 
       /* Check for __DYNAMIC, which is used by Sun shared libraries. 
         Record it as global even if it's local, not global, so
-        lookup_minimal_symbol can find it.
-        FIXME:  this might want to check for _DYNAMIC and the current
-        symbol_leading_char.  */
+        lookup_minimal_symbol can find it.  We don't check symbol_leading_char
+        because for SunOS4 it always is '_'.  */
       if (name[8] == 'C' && STREQ ("__DYNAMIC", name))
        ms_type = mst_data;
 
@@ -1032,19 +1049,12 @@ start_psymtab (objfile, section_offsets,
   return result;
 }
 
-/* Close off the current usage of a partial_symbol table entry.  This
-   involves setting the correct number of includes (with a realloc),
-   setting the high text mark, setting the symbol length in the
-   executable, and setting the length of the global and static lists
-   of psymbols.
-
-   The global symbols and static symbols are then seperately sorted.
+/* Close off the current usage of PST.  
+   Returns PST or NULL if the partial symtab was empty and thrown away.
 
-   Then the partial symtab is put on the global list.
-   *** List variables and peculiarities of same. ***
-   */
+   FIXME:  List variables and peculiarities of same.  */
 
-void
+struct partial_symtab *
 end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
             capping_text, dependency_list, number_dependencies)
      struct partial_symtab *pst;
@@ -1228,7 +1238,11 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
 
     pst->next = pst->objfile->free_psymtabs;
     pst->objfile->free_psymtabs = pst;
+
+    /* Indicate that psymtab was thrown away.  */
+    pst = (struct partial_symtab *)NULL;
   }
+  return pst;
 }
 \f
 static void
@@ -1342,7 +1356,6 @@ read_ofile_symtab (pst)
   unsigned char type;
   unsigned max_symnum;
   register bfd *abfd;
-  struct symtab *rtn;
   struct objfile *objfile;
   int sym_offset;              /* Offset to start of symbols to read */
   int sym_size;                        /* Size of symbols to read */
@@ -1796,7 +1809,10 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
        .stab "foo:V...",N_STSYM        is relative (section base subtracted).
        This leaves us no choice but to search for the 'S' or 'V'...
        (or pass the whole section_offsets stuff down ONE MORE function
-       call level, which we really don't want to do).  */
+       call level, which we really don't want to do).
+
+       The above is indeed true for Solaris 2.1.  I'm not sure what
+       happens in Solaris 2.3, in which ld stops relocating stabs.  */
       {
        char *p;
        p = strchr (name, ':');
@@ -1804,7 +1820,9 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          {
            /* FIXME!  We relocate it by the TEXT offset, in case the
               whole module moved in memory.  But this is wrong, since
-              the sections can side around independently.  */
+              the sections can side around independently.  (I suspect that
+              the text offset is always zero anyway--elfread.c doesn't
+              process (and Sun cc doesn't produce) Ttext.text symbols).  */
            valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
            goto define_a_symbol;
          }
@@ -1898,7 +1916,15 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                 previous function. This means that we can use the
                 minimal symbol table to get the address.  */
 
-             if (type == N_GSYM || type == N_STSYM)
+             /* On solaris up to 2.2, the N_FUN stab gets relocated.
+                On Solaris 2.3, ld no longer relocates stabs (which
+                is good), and the N_FUN's value is now always zero.
+                We only provide this correction for functions, not for
+                all N_FUN symbols, because that is easiest and all
+                readonly variables seem to go in the .rodata on Solaris.  */
+
+             if (type == N_GSYM || type == N_STSYM
+                 || (type == N_FUN && valu == 0))
                {
                  struct minimal_symbol *m;
                  int l = colon_pos - name;
@@ -2063,8 +2089,7 @@ elfstab_build_psymtabs (objfile, section_offsets, mainline,
   DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
   DBX_SYMTAB_OFFSET  (objfile) = staboffset;
   
-  if (stabstrsize < 0  /* FIXME:  stabstrsize is unsigned; never true! */
-      || stabstrsize > bfd_get_size (sym_bfd))
+  if (stabstrsize > bfd_get_size (sym_bfd))
     error ("ridiculous string table size: %d bytes", stabstrsize);
   DBX_STRINGTAB (objfile) = (char *)
     obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1);
@@ -2142,7 +2167,7 @@ dbx_symfile_offsets (objfile, addr)
 }
 \f
 /* Register our willingness to decode symbols for SunOS and a.out and
-   b.out files handled by BFD... */
+   NetBSD and b.out files handled by BFD... */
 static struct sym_fns sunos_sym_fns =
 {
   "sunOs",             /* sym_name: name or name prefix of BFD target type */
This page took 0.024705 seconds and 4 git commands to generate.