/* 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, 2008
Free Software Foundation, Inc.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
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,
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"
csi = (struct coff_symfile_info *) csip;
name = bfd_get_section_name (abfd, sectp);
- if (DEPRECATED_STREQ (name, ".text"))
+ if (strcmp (name, ".text") == 0)
{
csi->textaddr = bfd_section_vma (abfd, sectp);
csi->textsize += bfd_section_size (abfd, sectp);
{
csi->textsize += bfd_section_size (abfd, sectp);
}
- else if (DEPRECATED_STREQ (name, ".stabstr"))
+ else if (strcmp (name, ".stabstr") == 0)
{
csi->stabstrsect = sectp;
}
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. */
/* Let stabs reader clean up */
stabsread_clear_cache ();
+
+ dwarf2_free_objfile (objfile);
}
\f
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
case C_THUMBSTATFUNC:
if (cs->c_name[0] == '.')
{
- if (DEPRECATED_STREQ (cs->c_name, ".text"))
+ if (strcmp (cs->c_name, ".text") == 0)
{
/* FIXME: don't wire in ".text" as section name
or symbol name! */
}
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 */
|| (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))
{
break;
case C_FCN:
- if (DEPRECATED_STREQ (cs->c_name, ".bf"))
+ if (strcmp (cs->c_name, ".bf") == 0)
{
within_function = 1;
new->name =
process_coff_symbol (&fcn_cs_saved, &fcn_aux_saved, objfile);
}
- else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
+ else if (strcmp (cs->c_name, ".ef") == 0)
{
if (!within_function)
error (_("Bad coff function information."));
break;
case C_BLOCK:
- if (DEPRECATED_STREQ (cs->c_name, ".bb"))
+ if (strcmp (cs->c_name, ".bb") == 0)
{
tmpaddr = cs->c_value;
tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
push_context (++depth, tmpaddr);
}
- else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
+ else if (strcmp (cs->c_name, ".eb") == 0)
{
if (context_stack_depth <= 0)
{ /* We attempted to pop an empty context stack */
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;
#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;
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:
*dim = 0;
base_type = decode_type (cs, new_c_type, aux);
- index_type = lookup_fundamental_type (current_objfile, FT_INTEGER);
+ index_type = builtin_type_int32;
range_type =
create_range_type ((struct type *) NULL, index_type, 0, n - 1);
type =
{
case T_NULL:
/* shows up with "void (*foo)();" structure members */
- return lookup_fundamental_type (current_objfile, FT_VOID);
+ return builtin_type (current_gdbarch)->builtin_void;
#ifdef T_VOID
case T_VOID:
/* Intel 960 COFF has this symbol and meaning. */
- return lookup_fundamental_type (current_objfile, FT_VOID);
+ return builtin_type (current_gdbarch)->builtin_void;
#endif
case T_CHAR:
- return lookup_fundamental_type (current_objfile, FT_CHAR);
+ return builtin_type (current_gdbarch)->builtin_char;
case T_SHORT:
- return lookup_fundamental_type (current_objfile, FT_SHORT);
+ return builtin_type (current_gdbarch)->builtin_short;
case T_INT:
- return lookup_fundamental_type (current_objfile, FT_INTEGER);
+ return builtin_type (current_gdbarch)->builtin_int;
case T_LONG:
if (cs->c_sclass == C_FIELD
- && aux->x_sym.x_misc.x_lnsz.x_size > TARGET_LONG_BIT)
- return lookup_fundamental_type (current_objfile, FT_LONG_LONG);
+ && aux->x_sym.x_misc.x_lnsz.x_size
+ > gdbarch_long_bit (current_gdbarch))
+ return builtin_type (current_gdbarch)->builtin_long_long;
else
- return lookup_fundamental_type (current_objfile, FT_LONG);
+ return builtin_type (current_gdbarch)->builtin_long;
case T_FLOAT:
- return lookup_fundamental_type (current_objfile, FT_FLOAT);
+ return builtin_type (current_gdbarch)->builtin_float;
case T_DOUBLE:
- return lookup_fundamental_type (current_objfile, FT_DBL_PREC_FLOAT);
+ return builtin_type (current_gdbarch)->builtin_double;
case T_LNGDBL:
- return lookup_fundamental_type (current_objfile, FT_EXT_PREC_FLOAT);
+ return builtin_type (current_gdbarch)->builtin_long_double;
case T_STRUCT:
if (cs->c_naux != 1)
break;
case T_UCHAR:
- return lookup_fundamental_type (current_objfile, FT_UNSIGNED_CHAR);
+ return builtin_type (current_gdbarch)->builtin_unsigned_char;
case T_USHORT:
- return lookup_fundamental_type (current_objfile, FT_UNSIGNED_SHORT);
+ return builtin_type (current_gdbarch)->builtin_unsigned_short;
case T_UINT:
- return lookup_fundamental_type (current_objfile, FT_UNSIGNED_INTEGER);
+ return builtin_type (current_gdbarch)->builtin_unsigned_int;
case T_ULONG:
if (cs->c_sclass == C_FIELD
- && aux->x_sym.x_misc.x_lnsz.x_size > TARGET_LONG_BIT)
- return lookup_fundamental_type (current_objfile, FT_UNSIGNED_LONG_LONG);
+ && aux->x_sym.x_misc.x_lnsz.x_size
+ > gdbarch_long_bit (current_gdbarch))
+ return builtin_type (current_gdbarch)->builtin_unsigned_long_long;
else
- return lookup_fundamental_type (current_objfile, FT_UNSIGNED_LONG);
+ return builtin_type (current_gdbarch)->builtin_unsigned_long;
}
complaint (&symfile_complaints, _("Unexpected type for symbol %s"), cs->c_name);
- return lookup_fundamental_type (current_objfile, FT_VOID);
+ return builtin_type (current_gdbarch)->builtin_void;
}
\f
/* This page contains subroutines of read_type. */
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 *)
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 */
};