* ada-lang.c: Add include of source.h.
[deliverable/binutils-gdb.git] / gdb / coffread.c
index 205b733b98a1071bb474fbee3d22febd7500d171..e90e925faee89cbdb73d0a046b7d1cc6101c1146 100644 (file)
@@ -1,6 +1,6 @@
 /* Read coff symbol tables and convert to internal format, for GDB.
-   Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
 
@@ -18,8 +18,8 @@
 
    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.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "symtab.h"
@@ -259,29 +259,27 @@ find_targ_sec (bfd *abfd, asection *sect, void *obj)
     *args->resultp = sect;
 }
 
-/* Return the section number (SECT_OFF_*) that CS points to.  */
-static int
-cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
+/* Return the bfd_section that CS points to.  */
+static struct bfd_section*
+cs_to_bfd_section (struct coff_symbol *cs, struct objfile *objfile)
 {
   asection *sect = NULL;
   struct find_targ_sec_arg args;
-  int off = SECT_OFF_TEXT (objfile);
 
   args.targ_index = cs->c_secnum;
   args.resultp = §
   bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
-  if (sect != NULL)
-    {
-      /* This is the section.  Figure out what SECT_OFF_* code it is.  */
-      if (bfd_get_section_flags (abfd, sect) & SEC_CODE)
-       off = SECT_OFF_TEXT (objfile);
-      else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
-       off = SECT_OFF_DATA (objfile);
-      else
-       /* Just return the bfd section index. */
-       off = sect->index;
-    }
-  return off;
+  return sect;
+}
+
+/* Return the section number (SECT_OFF_*) that CS points to.  */
+static int
+cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
+{
+  asection *sect = cs_to_bfd_section (cs, objfile);
+  if (sect == NULL)
+    return SECT_OFF_TEXT (objfile);
+  return sect->index;
 }
 
 /* Return the address of the section of a COFF symbol.  */
@@ -408,15 +406,19 @@ coff_end_symtab (struct objfile *objfile)
   last_source_file = NULL;
 }
 \f
-static void
-record_minimal_symbol (char *name, CORE_ADDR address,
-                      enum minimal_symbol_type type, struct objfile *objfile)
+static struct minimal_symbol *
+record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
+                      enum minimal_symbol_type type, int section, 
+                      struct objfile *objfile)
 {
+  struct bfd_section *bfd_section;
   /* We don't want TDESC entry points in the minimal symbol table */
-  if (name[0] == '@')
-    return;
+  if (cs->c_name[0] == '@')
+    return NULL;
 
-  prim_record_minimal_symbol (name, address, type, objfile);
+  bfd_section = cs_to_bfd_section (cs, objfile);
+  return prim_record_minimal_symbol_and_info (cs->c_name, address, type,
+    NULL, section, bfd_section, objfile);
 }
 \f
 /* coff_symfile_init ()
@@ -699,6 +701,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
   long fcn_line_ptr = 0;
   int val;
   CORE_ADDR tmpaddr;
+  struct minimal_symbol *msym;
 
   /* Work around a stdio bug in SunOS4.1.1 (this makes me nervous....
      it's hard to know I've really worked around it.  The fix should be
@@ -762,8 +765,9 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
       if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF)
        {
          /* Record all functions -- external and static -- in minsyms. */
+         int section = cs_to_section (cs, objfile);
          tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
-         record_minimal_symbol (cs->c_name, tmpaddr, mst_text, objfile);
+         record_minimal_symbol (cs, tmpaddr, mst_text, section, objfile);
 
          fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
          fcn_start_addr = tmpaddr;
@@ -890,6 +894,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
              }
            else
              {
+               asection *bfd_section = cs_to_bfd_section (cs, objfile);
                sec = cs_to_section (cs, objfile);
                tmpaddr = cs->c_value;
                /* Statics in a PE file also get relocated */
@@ -899,7 +904,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
                    || (pe_file && (cs->c_sclass == C_STAT)))
                  tmpaddr += ANOFFSET (objfile->section_offsets, sec);
 
-               if (sec == SECT_OFF_TEXT (objfile))
+               if (bfd_section->flags & SEC_CODE)
                  {
                    ms_type =
                      cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
@@ -907,31 +912,27 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
                      mst_text : mst_file_text;
                    tmpaddr = SMASH_TEXT_ADDRESS (tmpaddr);
                  }
-               else if (sec == SECT_OFF_DATA (objfile))
+               else if (bfd_section->flags & SEC_ALLOC
+                        && bfd_section->flags & SEC_LOAD)
                  {
                    ms_type =
                      cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT ?
                      mst_data : mst_file_data;
                  }
-               else if (sec == SECT_OFF_BSS (objfile))
+               else if (bfd_section->flags & SEC_ALLOC)
                  {
                    ms_type =
                      cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT ?
-                     mst_data : mst_file_data;
+                     mst_bss : mst_file_bss;
                  }
                else
                  ms_type = mst_unknown;
              }
 
-           if (cs->c_name[0] != '@' /* Skip tdesc symbols */ )
-             {
-               struct minimal_symbol *msym;
-               msym = prim_record_minimal_symbol_and_info
-                 (cs->c_name, tmpaddr, ms_type, NULL,
-                  sec, NULL, objfile);
-               if (msym)
-                 COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);
-             }
+           msym = record_minimal_symbol (cs, tmpaddr, ms_type, sec, objfile);
+           if (msym)
+             COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);
+
            if (SDB_TYPE (cs->c_type))
              {
                struct symbol *sym;
@@ -1399,7 +1400,7 @@ patch_type (struct type *type, struct type *real_type)
     {
       if (TYPE_NAME (target))
        xfree (TYPE_NAME (target));
-      TYPE_NAME (target) = concat (TYPE_NAME (real_target), NULL);
+      TYPE_NAME (target) = concat (TYPE_NAME (real_target), (char *)NULL);
     }
 }
 
@@ -1636,7 +1637,7 @@ process_coff_symbol (struct coff_symbol *cs,
                }
              else
                TYPE_NAME (SYMBOL_TYPE (sym)) =
-                 concat (DEPRECATED_SYMBOL_NAME (sym), NULL);
+                 concat (DEPRECATED_SYMBOL_NAME (sym), (char *)NULL);
            }
 
          /* Keep track of any type which points to empty structured type,
@@ -1671,7 +1672,7 @@ process_coff_symbol (struct coff_symbol *cs,
                && *DEPRECATED_SYMBOL_NAME (sym) != '~'
                && *DEPRECATED_SYMBOL_NAME (sym) != '.')
              TYPE_TAG_NAME (SYMBOL_TYPE (sym)) =
-               concat (DEPRECATED_SYMBOL_NAME (sym), NULL);
+               concat (DEPRECATED_SYMBOL_NAME (sym), (char *)NULL);
 
          add_symbol_to_list (sym, &file_symbols);
          break;
This page took 0.026672 seconds and 4 git commands to generate.