X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fcoffread.c;h=7b93f3d4d88eba3074030470473cb0c489dc7c47;hb=3a42e9d0622736d6ad84c37a2d4f4f54a0c30469;hp=526e0e40c9efbcae92dd324e55e2d864663dbbec;hpb=b6ba6518e9254bc25f88088228e93ac966ebccd1;p=binutils-gdb.git diff --git a/gdb/coffread.c b/gdb/coffread.c index 526e0e40c9e..7b93f3d4d88 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -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 + 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu). @@ -43,6 +43,7 @@ #include "stabsread.h" #include "complaints.h" #include "target.h" +#include "gdb_assert.h" extern void _initialize_coffread (void); @@ -311,7 +312,7 @@ struct find_targ_sec_arg asection **resultp; }; -static void find_targ_sec (bfd *, asection *, void *); +static void find_targ_sec (bfd *, asection *, PTR); static void find_targ_sec (bfd *abfd, asection *sect, PTR obj) @@ -688,6 +689,11 @@ coff_symfile_read (struct objfile *objfile, int mainline) info->stabsects, info->stabstrsect->filepos, stabstrsize); } + if (dwarf2_has_info (abfd)) + { + /* DWARF2 sections. */ + dwarf2_build_psymtabs (objfile, mainline); + } do_cleanups (back_to); } @@ -740,7 +746,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, char *filestring = ""; int depth = 0; int fcn_first_line = 0; - CORE_ADDR fcn_first_line_addr; + CORE_ADDR fcn_first_line_addr = 0; int fcn_last_line = 0; int fcn_start_addr = 0; long fcn_line_ptr = 0; @@ -966,9 +972,15 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, { struct minimal_symbol *msym; + /* FIXME: cagney/2001-02-01: The nasty (int) -> (long) + -> (void*) cast is to ensure that that the value of + cs->c_sclass can be correctly stored in a void + pointer in MSYMBOL_INFO. Better solutions + welcome. */ + gdb_assert (sizeof (void *) >= sizeof (cs->c_sclass)); msym = prim_record_minimal_symbol_and_info - (cs->c_name, tmpaddr, ms_type, (char *) cs->c_sclass, sec, - NULL, objfile); + (cs->c_name, tmpaddr, ms_type, (void *) (long) cs->c_sclass, + sec, NULL, objfile); #ifdef COFF_MAKE_MSYMBOL_SPECIAL if (msym) COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym); @@ -1009,6 +1021,8 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, } else if (STREQ (cs->c_name, ".ef")) { + if (!within_function) + error ("Bad coff function information\n"); /* the value of .ef is the address of epilogue code; not useful for gdb. */ /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno @@ -1140,18 +1154,18 @@ read_one_sym (register struct coff_symbol *cs, int i; cs->c_symnum = symnum; - bfd_read (temp_sym, local_symesz, 1, nlist_bfd_global); + bfd_bread (temp_sym, local_symesz, nlist_bfd_global); bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *) sym); cs->c_naux = sym->n_numaux & 0xff; if (cs->c_naux >= 1) { - bfd_read (temp_aux, local_auxesz, 1, nlist_bfd_global); + bfd_bread (temp_aux, local_auxesz, nlist_bfd_global); 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_read (temp_aux, local_auxesz, 1, nlist_bfd_global); + bfd_bread (temp_aux, local_auxesz, nlist_bfd_global); } cs->c_name = getsymname (sym); cs->c_value = sym->n_value; @@ -1218,7 +1232,7 @@ init_stringtab (bfd *abfd, long offset) if (bfd_seek (abfd, offset, 0) < 0) return -1; - val = bfd_read ((char *) lengthbuf, sizeof lengthbuf, 1, abfd); + val = bfd_bread ((char *) lengthbuf, sizeof lengthbuf, abfd); length = bfd_h_get_32 (symfile_bfd, lengthbuf); /* If no string table is needed, then the file may end immediately @@ -1233,7 +1247,8 @@ init_stringtab (bfd *abfd, long offset) if (length == sizeof length) /* Empty table -- just the count */ return 0; - val = bfd_read (stringtab + sizeof lengthbuf, length - sizeof lengthbuf, 1, abfd); + val = bfd_bread (stringtab + sizeof lengthbuf, length - sizeof lengthbuf, + abfd); if (val != length - sizeof lengthbuf || stringtab[length - 1] != '\0') return -1; @@ -1332,7 +1347,7 @@ init_lineno (bfd *abfd, long offset, int size) /* Allocate the desired table, plus a sentinel */ linetab = (char *) xmalloc (size + local_linesz); - val = bfd_read (linetab, size, 1, abfd); + val = bfd_bread (linetab, size, abfd); if (val != size) return -1;