/* 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, 2007, 2008, 2009,
- 2010 Free Software Foundation, Inc.
+ Copyright (C) 1987-2005, 2007-2012 Free Software Foundation, Inc.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
This file is part of GDB.
extern void _initialize_coffread (void);
+/* The objfile we are currently reading. */
+
+static struct objfile *coffread_objfile;
+
struct coff_symfile_info
{
file_ptr min_lineno_offset; /* Where in file lowest line#s are. */
static char *getsymname (struct internal_syment *);
-static char *coff_getfilename (union internal_auxent *);
+static const char *coff_getfilename (union internal_auxent *);
static void free_stringtab (void);
We will fill it in later if we find out how. */
if (type == NULL)
{
- type = alloc_type (current_objfile);
+ type = alloc_type (coffread_objfile);
*type_addr = type;
}
return type;
it indicates the start of data for one original source file. */
static void
-coff_start_symtab (char *name)
+coff_start_symtab (const char *name)
{
start_symtab (
/* We fill in the filename later. start_symtab puts this pointer
text. */
static void
-complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
+complete_symtab (const char *name, CORE_ADDR start_addr, unsigned int size)
{
if (last_source_file != NULL)
xfree (last_source_file);
static void
coff_end_symtab (struct objfile *objfile)
{
- struct symtab *symtab;
-
last_source_start_addr = current_source_start_addr;
- symtab = end_symtab (current_source_end_addr, objfile,
- SECT_OFF_TEXT (objfile));
+ end_symtab (current_source_end_addr, objfile,
+ SECT_OFF_TEXT (objfile));
/* Reinitialize for beginning of new file. */
last_source_file = NULL;
{
if (!info->stabstrsect)
{
- error (_("The debugging information in `%s' is corrupted.\n"
- "The file has a `.stabs' section, but no `.stabstr' section."),
+ error (_("The debugging information in `%s' is corrupted.\nThe "
+ "file has a `.stabs' section, but no `.stabstr' section."),
name);
}
info->stabsects,
info->stabstrsect->filepos, stabstrsize);
}
- if (dwarf2_has_info (objfile))
+ if (dwarf2_has_info (objfile, NULL))
{
/* DWARF2 sections. */
dwarf2_build_psymtabs (objfile);
int in_source_file = 0;
int next_file_symnum = -1;
/* Name of the current file. */
- char *filestring = "";
+ const char *filestring = "";
int depth = 0;
int fcn_first_line = 0;
CORE_ADDR fcn_first_line_addr = 0;
if (val < 0)
perror_with_name (objfile->name);
- current_objfile = objfile;
+ coffread_objfile = objfile;
nlist_bfd_global = objfile->obfd;
nlist_nsyms_global = nsyms;
last_source_file = NULL;
if (cs->c_secnum == N_UNDEF)
{
- /* This is a common symbol. See if the target
- environment knows where it has been relocated to. */
- CORE_ADDR reladdr;
-
- if (target_lookup_symbol (cs->c_name, &reladdr))
- {
- /* Error in lookup; ignore symbol. */
- break;
- }
- tmpaddr = reladdr;
- /* The address has already been relocated; make sure that
- objfile_relocate doesn't relocate it again. */
- sec = -2;
- ms_type = cs->c_sclass == C_EXT
- || cs->c_sclass == C_THUMBEXT ?
- mst_bss : mst_file_bss;
+ /* This is a common symbol. We used to rely on
+ the target to tell us whether it knows where
+ the symbol has been relocated to, but none of
+ the target implementations actually provided
+ that operation. So we just ignore the symbol,
+ the same way we would do if we had a target-side
+ symbol lookup which returned no match. */
+ break;
}
else if (cs->c_secnum == N_ABS)
{
if (context_stack_depth <= 0)
{ /* We attempted to pop an empty context stack. */
complaint (&symfile_complaints,
- _("`.ef' symbol without matching `.bf' symbol ignored starting at symnum %d"),
+ _("`.ef' symbol without matching `.bf' "
+ "symbol ignored starting at symnum %d"),
cs->c_symnum);
within_function = 0;
break;
if (context_stack_depth > 0 || new == NULL)
{
complaint (&symfile_complaints,
- _("Unmatched .ef symbol(s) ignored starting at symnum %d"),
+ _("Unmatched .ef symbol(s) ignored "
+ "starting at symnum %d"),
cs->c_symnum);
within_function = 0;
break;
else if (strcmp (cs->c_name, ".eb") == 0)
{
if (context_stack_depth <= 0)
- { /* We attempted to pop an empty context stack. */
+ { /* We attempted to pop an empty context stack. */
complaint (&symfile_complaints,
- _("`.eb' symbol without matching `.bb' symbol ignored starting at symnum %d"),
+ _("`.eb' symbol without matching `.bb' "
+ "symbol ignored starting at symnum %d"),
cs->c_symnum);
break;
}
new = pop_context ();
if (depth-- != new->depth)
{
- complaint (&symfile_complaints,
- _("Mismatched .eb symbol ignored starting at symnum %d"),
+ complaint (&symfile_complaints,
+ _("Mismatched .eb symbol ignored "
+ "starting at symnum %d"),
symnum);
break;
}
ALL_OBJFILE_SYMTABS (objfile, s)
patch_opaque_types (s);
- current_objfile = NULL;
+ coffread_objfile = NULL;
}
\f
/* Routines for reading headers and symbols from executable. */
cs->c_symnum = symnum;
bytes = bfd_bread (temp_sym, local_symesz, nlist_bfd_global);
if (bytes != local_symesz)
- error ("%s: error reading symbols", current_objfile->name);
+ error (_("%s: error reading symbols"), coffread_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)
{
bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
if (bytes != local_auxesz)
- error ("%s: error reading symbols", current_objfile->name);
+ error (_("%s: error reading symbols"), coffread_objfile->name);
bfd_coff_swap_aux_in (symfile_bfd, temp_aux,
sym->n_type, sym->n_sclass,
0, cs->c_naux, (char *) aux);
{
bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
if (bytes != local_auxesz)
- error ("%s: error reading symbols", current_objfile->name);
+ error (_("%s: error reading symbols"), coffread_objfile->name);
}
}
cs->c_name = getsymname (sym);
Return only the last component of the name. Result is in static
storage and is only good for temporary use. */
-static char *
+static const char *
coff_getfilename (union internal_auxent *aux_entry)
{
static char buffer[BUFSIZ];
char *temp;
- char *result;
+ const char *result;
if (aux_entry->x_file.x_n.x_zeroes == 0)
- strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset);
+ {
+ if (strlen (stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ)
+ internal_error (__FILE__, __LINE__, _("coff file name too long"));
+ strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset);
+ }
else
{
strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
/* FIXME: We should not be throwing away the information about what
directory. It should go into dirname of the symtab, or some such
place. */
- if ((temp = strrchr (result, '/')) != NULL)
- result = temp + 1;
+ result = lbasename (result);
return (result);
}
\f
if (TYPE_NAME (real_target))
{
+ /* The previous copy of TYPE_NAME is allocated by
+ process_coff_symbol. */
if (TYPE_NAME (target))
- xfree (TYPE_NAME (target));
- TYPE_NAME (target) = concat (TYPE_NAME (real_target),
- (char *) NULL);
+ xfree ((char*) TYPE_NAME (target));
+ TYPE_NAME (target) = xstrdup (TYPE_NAME (real_target));
}
}
&& TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
- char *name = SYMBOL_LINKAGE_NAME (real_sym);
+ const char *name = SYMBOL_LINKAGE_NAME (real_sym);
int hash = hashname (name);
struct symbol *sym, *prev;
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- /* If type has no name, give it one */
+ /* If type has no name, give it one. */
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
{
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
- concat (SYMBOL_LINKAGE_NAME (sym), (char *) NULL);
+ xstrdup (SYMBOL_LINKAGE_NAME (sym));
}
/* Keep track of any type which points to empty structured
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = SYMBOL_LINKAGE_NAME (xsym);
- SET_FIELD_BITPOS (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
+ SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
for sym_read() */
coff_symfile_read, /* sym_read: read a symbol file into
symtab */
+ NULL, /* sym_read_psymbols */
coff_symfile_finish, /* sym_finish: finished with file,
cleanup */
default_symfile_offsets, /* sym_offsets: xlate external to
default_symfile_relocate, /* sym_relocate: Relocate a debug
section. */
+ NULL, /* sym_probe_fns */
&psym_functions
};