* coffread.c (coff_sym_fns): Add default_symfile_segments.
[deliverable/binutils-gdb.git] / gdb / coffread.c
index 669e33de459b82f46ab907f07cd5fdce1773d088..dcd17d35faa069f805840a86b61acf60f702cf9c 100644 (file)
@@ -1,6 +1,6 @@
 /* Read coff symbol tables and convert to internal format, for GDB.
    Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
    Free Software Foundation, Inc.
    Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
 
@@ -277,19 +277,9 @@ static int
 cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
 {
   asection *sect = cs_to_bfd_section (cs, objfile);
-  int off = SECT_OFF_TEXT (objfile);
-  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;
+  if (sect == NULL)
+    return SECT_OFF_TEXT (objfile);
+  return sect->index;
 }
 
 /* Return the address of the section of a COFF symbol.  */
@@ -711,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
@@ -903,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 */
@@ -912,36 +904,36 @@ 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
                      || cs->c_sclass == C_THUMBEXT ?
                      mst_text : mst_file_text;
-                   tmpaddr = SMASH_TEXT_ADDRESS (tmpaddr);
+                   tmpaddr = gdbarch_smash_text_address
+                               (current_gdbarch, 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;
              }
 
-           {
-             struct minimal_symbol *msym;
-             msym = record_minimal_symbol (cs, tmpaddr, ms_type, sec, objfile);
-             if (msym)
-               COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);
-           }
+           msym = record_minimal_symbol (cs, tmpaddr, ms_type, sec, objfile);
+           if (msym)
+             gdbarch_coff_make_msymbol_special
+             (current_gdbarch, cs->c_sclass, msym);
 
            if (SDB_TYPE (cs->c_type))
              {
@@ -1557,7 +1549,8 @@ process_coff_symbol (struct coff_symbol *cs,
 #endif
        case C_REG:
          SYMBOL_CLASS (sym) = LOC_REGISTER;
-         SYMBOL_VALUE (sym) = SDB_REG_TO_REGNUM (cs->c_value);
+         SYMBOL_VALUE (sym) = gdbarch_sdb_reg_to_regnum
+                                (current_gdbarch, cs->c_value);
          add_symbol_to_list (sym, &local_symbols);
          break;
 
@@ -1569,7 +1562,7 @@ process_coff_symbol (struct coff_symbol *cs,
          SYMBOL_CLASS (sym) = LOC_ARG;
          add_symbol_to_list (sym, &local_symbols);
 #if !defined (BELIEVE_PCC_PROMOTION)
-         if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+         if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
            {
              /* If PCC says a parameter is a short or a char,
                 aligned on an int boundary, realign it to the
@@ -1591,7 +1584,8 @@ process_coff_symbol (struct coff_symbol *cs,
 
        case C_REGPARM:
          SYMBOL_CLASS (sym) = LOC_REGPARM;
-         SYMBOL_VALUE (sym) = SDB_REG_TO_REGNUM (cs->c_value);
+         SYMBOL_VALUE (sym) = gdbarch_sdb_reg_to_regnum
+                                (current_gdbarch, cs->c_value);
          add_symbol_to_list (sym, &local_symbols);
 #if !defined (BELIEVE_PCC_PROMOTION)
          /* FIXME:  This should retain the current type, since it's just
@@ -1818,7 +1812,8 @@ decode_base_type (struct coff_symbol *cs, unsigned int c_type,
 
     case T_LONG:
       if (cs->c_sclass == C_FIELD
-         && aux->x_sym.x_misc.x_lnsz.x_size > TARGET_LONG_BIT)
+         && aux->x_sym.x_misc.x_lnsz.x_size
+            > gdbarch_long_bit (current_gdbarch))
        return lookup_fundamental_type (current_objfile, FT_LONG_LONG);
       else
        return lookup_fundamental_type (current_objfile, FT_LONG);
@@ -1918,7 +1913,8 @@ decode_base_type (struct coff_symbol *cs, unsigned int c_type,
 
     case T_ULONG:
       if (cs->c_sclass == C_FIELD
-         && aux->x_sym.x_misc.x_lnsz.x_size > TARGET_LONG_BIT)
+         && aux->x_sym.x_misc.x_lnsz.x_size
+            > gdbarch_long_bit (current_gdbarch))
        return lookup_fundamental_type (current_objfile, FT_UNSIGNED_LONG_LONG);
       else
        return lookup_fundamental_type (current_objfile, FT_UNSIGNED_LONG);
@@ -2091,8 +2087,8 @@ coff_read_enum_type (int index, int length, int lastsym)
 
   if (length > 0)
     TYPE_LENGTH (type) = length;
-  else
-    TYPE_LENGTH (type) = TARGET_INT_BIT / TARGET_CHAR_BIT;     /* Assume ints */
+  else /* Assume ints.  */
+    TYPE_LENGTH (type) = gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT;
   TYPE_CODE (type) = TYPE_CODE_ENUM;
   TYPE_NFIELDS (type) = nsyms;
   TYPE_FIELDS (type) = (struct field *)
@@ -2143,6 +2139,8 @@ static struct sym_fns coff_sym_fns =
   coff_symfile_read,           /* sym_read: read a symbol file into symtab */
   coff_symfile_finish,         /* sym_finish: finished with file, cleanup */
   default_symfile_offsets,     /* sym_offsets:  xlate external to internal form */
+  default_symfile_segments,    /* sym_segments: Get segment information from
+                                  a file.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
This page took 0.031774 seconds and 4 git commands to generate.