2007-10-15 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / gdb / coffread.c
index e90e925faee89cbdb73d0a046b7d1cc6101c1146..c4927490b99b8f158d1309fbe9a99326b176c74c 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).
 
@@ -8,7 +8,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,9 +17,7 @@
    GNU General Public License for more details.
 
    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., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "symtab.h"
@@ -910,7 +908,8 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
                      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 (bfd_section->flags & SEC_ALLOC
                         && bfd_section->flags & SEC_LOAD)
@@ -931,7 +930,8 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
 
            msym = record_minimal_symbol (cs, tmpaddr, ms_type, sec, objfile);
            if (msym)
-             COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);
+             gdbarch_coff_make_msymbol_special
+             (current_gdbarch, cs->c_sclass, msym);
 
            if (SDB_TYPE (cs->c_type))
              {
@@ -1116,20 +1116,29 @@ read_one_sym (struct coff_symbol *cs,
              union internal_auxent *aux)
 {
   int i;
+  bfd_size_type bytes;
 
   cs->c_symnum = symnum;
-  bfd_bread (temp_sym, local_symesz, nlist_bfd_global);
+  bytes = bfd_bread (temp_sym, local_symesz, nlist_bfd_global);
+  if (bytes != local_symesz)
+    error ("%s: error reading symbols", current_objfile->name);
   bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *) sym);
   cs->c_naux = sym->n_numaux & 0xff;
   if (cs->c_naux >= 1)
     {
-      bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
+      bytes  = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
+      if (bytes != local_auxesz)
+       error ("%s: error reading symbols", current_objfile->name);
       bfd_coff_swap_aux_in (symfile_bfd, temp_aux, sym->n_type, sym->n_sclass,
                            0, cs->c_naux, (char *) aux);
       /* If more than one aux entry, read past it (only the first aux
          is important). */
       for (i = 1; i < cs->c_naux; i++)
-       bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
+       {
+         bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
+         if (bytes != local_auxesz)
+           error ("%s: error reading symbols", current_objfile->name);
+       }
     }
   cs->c_name = getsymname (sym);
   cs->c_value = sym->n_value;
@@ -1547,7 +1556,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;
 
@@ -1558,51 +1568,13 @@ process_coff_symbol (struct coff_symbol *cs,
        case C_ARG:
          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 PCC says a parameter is a short or a char,
-                aligned on an int boundary, realign it to the
-                "little end" of the int.  */
-             struct type *temptype;
-             temptype = lookup_fundamental_type (current_objfile,
-                                                 FT_INTEGER);
-             if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype)
-                 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
-                 && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (temptype))
-               {
-                 SYMBOL_VALUE (sym) +=
-                   TYPE_LENGTH (temptype)
-                   - TYPE_LENGTH (SYMBOL_TYPE (sym));
-               }
-           }
-#endif
          break;
 
        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
-            a register value.  gnu@adobe, 26Feb93 */
-         {
-           /* If PCC says a parameter is a short or a char,
-              it is really an int.  */
-           struct type *temptype;
-           temptype =
-             lookup_fundamental_type (current_objfile, FT_INTEGER);
-           if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype)
-               && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
-             {
-               SYMBOL_TYPE (sym) =
-                 (TYPE_UNSIGNED (SYMBOL_TYPE (sym))
-                  ? lookup_fundamental_type (current_objfile,
-                                             FT_UNSIGNED_INTEGER)
-                  : temptype);
-             }
-         }
-#endif
          break;
 
        case C_TPDEF:
@@ -1808,7 +1780,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);
@@ -1908,7 +1881,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);
@@ -2081,8 +2055,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 *)
@@ -2133,6 +2107,9 @@ 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,                         /* sym_read_linetable  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
This page took 0.052544 seconds and 4 git commands to generate.