* pe-dll.c (fill_edata): don't strip underscores
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index d7af14f239934cf650bf9872012fcfde1a67fe03..63613cbae349d8519eae39e8e3b113593a5b7fd6 100644 (file)
@@ -1,5 +1,5 @@
 /* Read dbx symbol tables and convert to internal format, for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
+   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -638,7 +638,7 @@ dbx_symfile_init (objfile)
   unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
 
   /* Allocate struct to keep track of the symfile */
-  objfile->sym_stab_info = (PTR)
+  objfile->sym_stab_info = (struct dbx_symfile_info *)
     xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
   memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
 
@@ -1338,12 +1338,16 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
 
   if (pst)
     {
+      /* Don't set pst->texthigh lower than it already is.  */
+      CORE_ADDR text_end =
+       (lowest_text_address == (CORE_ADDR)-1
+        ? (text_addr + section_offsets->offsets[SECT_OFF_TEXT])
+        : lowest_text_address)
+       + text_size;
+
       end_psymtab (pst, psymtab_include_list, includes_used,
                   symnum * symbol_size,
-                  (lowest_text_address == (CORE_ADDR)-1
-                   ? (text_addr + section_offsets->offsets[SECT_OFF_TEXT])
-                   : lowest_text_address)
-                  + text_size,
+                  text_end > pst->texthigh ? text_end : pst->texthigh,
                   dependency_list, dependencies_used, textlow_not_set);
     }
 
@@ -1444,11 +1448,20 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
       if (p == NULL)
        p = last_function_name;
       n = p - last_function_name;
-      p = alloca (n + 1);
+      p = alloca (n + 2);
       strncpy (p, last_function_name, n);
       p[n] = 0;
     
       minsym = lookup_minimal_symbol (p, pst->filename, objfile);
+      if (minsym == NULL)
+       {
+         /* Sun Fortran appends an underscore to the minimal symbol name,
+            try again with an appended underscore if the minimal symbol
+            was not found.  */
+         p[n] = '_';
+         p[n + 1] = 0;
+         minsym = lookup_minimal_symbol (p, pst->filename, objfile);
+       }
 
       if (minsym)
        pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym);
@@ -1553,21 +1566,8 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
         is wrong, in that a psymtab with N_SLINE entries but nothing else
         is not empty, but we don't realize that.  Fixing that without slowing
         things down might be tricky.  */
-      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;
+      discard_psymtab (pst);
 
       /* Indicate that psymtab was thrown away.  */
       pst = (struct partial_symtab *)NULL;
@@ -1931,11 +1931,18 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          finish_block (new->name, &local_symbols, new->old_blocks,
                        new->start_addr, new->start_addr + valu,
                        objfile);
+
+         if (block_address_function_relative)
+           function_start_offset = 0;
+
          break;
        }
 
       /* Relocate for dynamic loading */
       valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+#ifdef SMASH_TEXT_ADDRESS
+      SMASH_TEXT_ADDRESS (valu);
+#endif
       goto define_a_symbol;
 
     case N_LBRAC:
@@ -1946,10 +1953,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
       if (n_opt_found && desc == 1)
        break;
 
-#if defined(BLOCK_ADDRESS_ABSOLUTE)
-      /* Relocate for dynamic loading (?).  */
-      valu += function_start_offset;
-#else
       if (block_address_function_relative)
        /* Relocate for Sun ELF acc fn-relative syms.  */
        valu += function_start_offset;
@@ -1957,7 +1960,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
        /* On most machines, the block addresses are relative to the
           N_SO, the linker did not relocate them (sigh).  */
        valu += last_source_start_addr;
-#endif
 
 #ifdef SUN_FIXED_LBRAC_BUG
       if (!SUN_FIXED_LBRAC_BUG && valu < last_pc_address) {
@@ -1977,10 +1979,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
       if (n_opt_found && desc == 1)
        break;
 
-#if defined(BLOCK_ADDRESS_ABSOLUTE)
-      /* Relocate for dynamic loading (?).  */
-      valu += function_start_offset;
-#else
       if (block_address_function_relative)
        /* Relocate for Sun ELF acc fn-relative syms.  */
        valu += function_start_offset;
@@ -1988,7 +1986,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
        /* On most machines, the block addresses are relative to the
           N_SO, the linker did not relocate them (sigh).  */
        valu += last_source_start_addr;
-#endif
 
       new = pop_context();
       if (desc != new->depth)
@@ -2094,6 +2091,9 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
       if (*name == '\000')
        break;
 
+      if (block_address_function_relative)
+        function_start_offset = 0;
+
       start_stabs ();
       start_symtab (name, NULL, valu);
       record_debugformat ("stabs");
@@ -2127,8 +2127,10 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
       /* This type of "symbol" really just records
         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.  */
       valu += function_start_offset;
+
 #ifdef SUN_FIXED_LBRAC_BUG
       last_pc_address = valu;  /* Save for SunOS bug circumcision */
 #endif
@@ -2273,12 +2275,22 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                  if (p == NULL)
                    p = name;
                  n = p - name;
-                 p = alloca (n + 1);
+                 p = alloca (n + 2);
                  strncpy (p, name, n);
                  p[n] = 0;
 
                  msym = lookup_minimal_symbol (p, last_source_file,
                                                objfile);
+                 if (msym == NULL)
+                   {
+                     /* Sun Fortran appends an underscore to the minimal
+                        symbol name, try again with an appended underscore
+                        if the minimal symbol was not found.  */
+                     p[n] = '_';
+                     p[n + 1] = 0;
+                     msym = lookup_minimal_symbol (p, last_source_file,
+                                                   objfile);
+                   }
                  if (msym)
                    valu = SYMBOL_VALUE_ADDRESS (msym);
                }
@@ -2394,6 +2406,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                    file's symbols at once.  */
     case N_ENDM:               /* Solaris 2:  End of module */
     case N_MAIN:               /* Name of main routine.  */
+    case N_ALIAS:              /* SunPro F77: alias name, ignore for now.  */
       break;
     }
 
@@ -2408,19 +2421,16 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          a definition.  If symbol reference is being defined, go 
          ahead and add it.  Otherwise, just return sym. */
 
-      char *s;
+      char *s = name;
       int refnum;
 
-      /* If defined, store away a pointer to the symbol;
-        we'll use it later when we resolve references in
-        "resolve_symbol_reference". */
-
       /* If this stab defines a new reference ID that is not on the
         reference list, then put it on the reference list.
 
         We go ahead and advance NAME past the reference, even though
         it is not strictly necessary at this time.  */
-      if (refnum = symbol_reference_defined (&s), refnum)
+      refnum = symbol_reference_defined (&s);
+      if (refnum >= 0)
        if (!ref_search (refnum))
          ref_add (refnum, 0, name, valu);
       name = s;
@@ -2664,7 +2674,8 @@ stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name,
     error ("stabsect_build_psymtabs:  Found stabs (%s), but not string section (%s)",
           stab_name, stabstr_name);
 
-  objfile->sym_stab_info = (PTR) xmalloc (sizeof (struct dbx_symfile_info));
+  objfile->sym_stab_info = (struct dbx_symfile_info *)
+    xmalloc (sizeof (struct dbx_symfile_info));
   memset (objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
 
   text_sect = bfd_get_section_by_name (sym_bfd, text_name);
This page took 0.027864 seconds and 4 git commands to generate.