projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* coffread.c (coff_symfile_init): Use set_objfile_data.
[deliverable/binutils-gdb.git]
/
gdb
/
coffread.c
diff --git
a/gdb/coffread.c
b/gdb/coffread.c
index 3494eb1f69cda1c09861ef4c6afb772b41a055ad..94d0554dab5d47c5e817f315d09a0c212e758d99 100644
(file)
--- a/
gdb/coffread.c
+++ b/
gdb/coffread.c
@@
-1,7
+1,5
@@
/* Read coff symbol tables and convert to internal format, for GDB.
/* 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.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
This file is part of GDB.
@@
-49,6
+47,10
@@
extern void _initialize_coffread (void);
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. */
struct coff_symfile_info
{
file_ptr min_lineno_offset; /* Where in file lowest line#s are. */
@@
-178,7
+180,7
@@
static int init_lineno (bfd *, long, int);
static char *getsymname (struct internal_syment *);
static char *getsymname (struct internal_syment *);
-static char *coff_getfilename (union internal_auxent *);
+static c
onst c
har *coff_getfilename (union internal_auxent *);
static void free_stringtab (void);
static void free_stringtab (void);
@@
-309,7
+311,7
@@
cs_section_address (struct coff_symbol *cs, bfd *abfd)
args.resultp = §
bfd_map_over_sections (abfd, find_targ_sec, &args);
if (sect != NULL)
args.resultp = §
bfd_map_over_sections (abfd, find_targ_sec, &args);
if (sect != NULL)
- addr = bfd_get_section_vma (
objfile->o
bfd, sect);
+ addr = bfd_get_section_vma (
a
bfd, sect);
return addr;
}
return addr;
}
@@
-355,7
+357,7
@@
coff_alloc_type (int index)
We will fill it in later if we find out how. */
if (type == NULL)
{
We will fill it in later if we find out how. */
if (type == NULL)
{
- type = alloc_type (c
urrent
_objfile);
+ type = alloc_type (c
offread
_objfile);
*type_addr = type;
}
return type;
*type_addr = type;
}
return type;
@@
-366,7
+368,7
@@
coff_alloc_type (int index)
it indicates the start of data for one original source file. */
static void
it indicates the start of data for one original source file. */
static void
-coff_start_symtab (char *name)
+coff_start_symtab (c
onst c
har *name)
{
start_symtab (
/* We fill in the filename later. start_symtab puts this pointer
{
start_symtab (
/* We fill in the filename later. start_symtab puts this pointer
@@
-388,7
+390,7
@@
coff_start_symtab (char *name)
text. */
static void
text. */
static void
-complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
+complete_symtab (c
onst c
har *name, CORE_ADDR start_addr, unsigned int size)
{
if (last_source_file != NULL)
xfree (last_source_file);
{
if (last_source_file != NULL)
xfree (last_source_file);
@@
-405,12
+407,10
@@
complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
static void
coff_end_symtab (struct objfile *objfile)
{
static void
coff_end_symtab (struct objfile *objfile)
{
- struct symtab *symtab;
-
last_source_start_addr = current_source_start_addr;
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;
/* Reinitialize for beginning of new file. */
last_source_file = NULL;
@@
-450,12
+450,11
@@
record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
static void
coff_symfile_init (struct objfile *objfile)
{
static void
coff_symfile_init (struct objfile *objfile)
{
- /* Allocate struct to keep track of stab reading. */
- objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
- xmalloc (sizeof (struct dbx_symfile_info));
+ struct dbx_symfile_info *dbx;
- memset (objfile->deprecated_sym_stab_info, 0,
- sizeof (struct dbx_symfile_info));
+ /* Allocate struct to keep track of stab reading. */
+ dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
/* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_private
/* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_private
@@
-528,7
+527,7
@@
coff_symfile_read (struct objfile *objfile, int symfile_flags)
int stabstrsize;
info = (struct coff_symfile_info *) objfile->deprecated_sym_private;
int stabstrsize;
info = (struct coff_symfile_info *) objfile->deprecated_sym_private;
- dbxinfo =
objfile->deprecated_sym_stab_info
;
+ dbxinfo =
DBX_SYMFILE_INFO (objfile)
;
symfile_bfd = abfd; /* Kludge for swap routines. */
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
symfile_bfd = abfd; /* Kludge for swap routines. */
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
@@
-623,8
+622,8
@@
coff_symfile_read (struct objfile *objfile, int symfile_flags)
{
if (!info->stabstrsect)
{
{
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.\n
The
"
+ "file has a `.stabs' section, but no `.stabstr' section."),
name);
}
name);
}
@@
-639,7
+638,7
@@
coff_symfile_read (struct objfile *objfile, int symfile_flags)
info->stabsects,
info->stabstrsect->filepos, stabstrsize);
}
info->stabsects,
info->stabstrsect->filepos, stabstrsize);
}
- if (dwarf2_has_info (objfile))
+ if (dwarf2_has_info (objfile
, NULL
))
{
/* DWARF2 sections. */
dwarf2_build_psymtabs (objfile);
{
/* DWARF2 sections. */
dwarf2_build_psymtabs (objfile);
@@
-653,13
+652,14
@@
coff_symfile_read (struct objfile *objfile, int symfile_flags)
char *debugfile;
debugfile = find_separate_debug_file_by_debuglink (objfile);
char *debugfile;
debugfile = find_separate_debug_file_by_debuglink (objfile);
+ make_cleanup (xfree, debugfile);
if (debugfile)
{
bfd *abfd = symfile_bfd_open (debugfile);
if (debugfile)
{
bfd *abfd = symfile_bfd_open (debugfile);
+ make_cleanup_bfd_unref (abfd);
symbol_file_add_separate (abfd, symfile_flags, objfile);
symbol_file_add_separate (abfd, symfile_flags, objfile);
- xfree (debugfile);
}
}
}
}
@@
-715,7
+715,7
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
int in_source_file = 0;
int next_file_symnum = -1;
/* Name of the current file. */
int in_source_file = 0;
int next_file_symnum = -1;
/* Name of the current file. */
- char *filestring = "";
+ c
onst c
har *filestring = "";
int depth = 0;
int fcn_first_line = 0;
CORE_ADDR fcn_first_line_addr = 0;
int depth = 0;
int fcn_first_line = 0;
CORE_ADDR fcn_first_line_addr = 0;
@@
-747,7
+747,7
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
if (val < 0)
perror_with_name (objfile->name);
if (val < 0)
perror_with_name (objfile->name);
- c
urrent
_objfile = objfile;
+ c
offread
_objfile = objfile;
nlist_bfd_global = objfile->obfd;
nlist_nsyms_global = nsyms;
last_source_file = NULL;
nlist_bfd_global = objfile->obfd;
nlist_nsyms_global = nsyms;
last_source_file = NULL;
@@
-904,22
+904,14
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
if (cs->c_secnum == N_UNDEF)
{
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)
{
}
else if (cs->c_secnum == N_ABS)
{
@@
-948,7
+940,7
@@
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;
cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
|| cs->c_sclass == C_THUMBEXT ?
mst_text : mst_file_text;
- tmpaddr = gdbarch_
smash_text_address
(gdbarch, tmpaddr);
+ tmpaddr = gdbarch_
addr_bits_remove
(gdbarch, tmpaddr);
}
else if (bfd_section->flags & SEC_ALLOC
&& bfd_section->flags & SEC_LOAD)
}
else if (bfd_section->flags & SEC_ALLOC
&& bfd_section->flags & SEC_LOAD)
@@
-1023,7
+1015,8
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
if (context_stack_depth <= 0)
{ /* We attempted to pop an empty context stack. */
complaint (&symfile_complaints,
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;
cs->c_symnum);
within_function = 0;
break;
@@
-1034,7
+1027,8
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
if (context_stack_depth > 0 || new == NULL)
{
complaint (&symfile_complaints,
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;
cs->c_symnum);
within_function = 0;
break;
@@
-1088,9
+1082,10
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
else if (strcmp (cs->c_name, ".eb") == 0)
{
if (context_stack_depth <= 0)
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,
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;
}
cs->c_symnum);
break;
}
@@
-1098,8
+1093,9
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
new = pop_context ();
if (depth-- != new->depth)
{
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;
}
symnum);
break;
}
@@
-1138,7
+1134,7
@@
coff_symtab_read (long symtab_offset, unsigned int nsyms,
ALL_OBJFILE_SYMTABS (objfile, s)
patch_opaque_types (s);
ALL_OBJFILE_SYMTABS (objfile, s)
patch_opaque_types (s);
- c
urrent
_objfile = NULL;
+ c
offread
_objfile = NULL;
}
\f
/* Routines for reading headers and symbols from executable. */
}
\f
/* Routines for reading headers and symbols from executable. */
@@
-1159,14
+1155,14
@@
read_one_sym (struct coff_symbol *cs,
cs->c_symnum = symnum;
bytes = bfd_bread (temp_sym, local_symesz, nlist_bfd_global);
if (bytes != local_symesz)
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)
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);
bfd_coff_swap_aux_in (symfile_bfd, temp_aux,
sym->n_type, sym->n_sclass,
0, cs->c_naux, (char *) aux);
@@
-1176,7
+1172,7
@@
read_one_sym (struct coff_symbol *cs,
{
bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
if (bytes != local_auxesz)
{
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);
}
}
cs->c_name = getsymname (sym);
@@
-1306,15
+1302,18
@@
getsymname (struct internal_syment *symbol_entry)
Return only the last component of the name. Result is in static
storage and is only good for temporary use. */
Return only the last component of the name. Result is in static
storage and is only good for temporary use. */
-static char *
+static c
onst c
har *
coff_getfilename (union internal_auxent *aux_entry)
{
static char buffer[BUFSIZ];
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)
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);
else
{
strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
@@
-1325,8
+1324,7
@@
coff_getfilename (union internal_auxent *aux_entry)
/* FIXME: We should not be throwing away the information about what
directory. It should go into dirname of the symtab, or some such
place. */
/* 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
return (result);
}
\f
@@
-1456,10
+1454,11
@@
patch_type (struct type *type, struct type *real_type)
if (TYPE_NAME (real_target))
{
if (TYPE_NAME (real_target))
{
+ /* The previous copy of TYPE_NAME is allocated by
+ process_coff_symbol. */
if (TYPE_NAME (target))
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));
}
}
}
}
@@
-1471,7
+1470,7
@@
static void
patch_opaque_types (struct symtab *s)
{
struct block *b;
patch_opaque_types (struct symtab *s)
{
struct block *b;
- struct
dict
_iterator iter;
+ struct
block
_iterator iter;
struct symbol *real_sym;
/* Go through the per-file symbols only. */
struct symbol *real_sym;
/* Go through the per-file symbols only. */
@@
-1487,7
+1486,7
@@
patch_opaque_types (struct symtab *s)
&& TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
&& 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);
+ c
onst c
har *name = SYMBOL_LINKAGE_NAME (real_sym);
int hash = hashname (name);
struct symbol *sym, *prev;
int hash = hashname (name);
struct symbol *sym, *prev;
@@
-1648,7
+1647,7
@@
process_coff_symbol (struct coff_symbol *cs,
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
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
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
{
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
@@
-1676,7
+1675,7
@@
process_coff_symbol (struct coff_symbol *cs,
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
}
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
}
/* Keep track of any type which points to empty structured
@@
-2159,7
+2158,7
@@
coff_read_enum_type (int index, int length, int lastsym,
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = SYMBOL_LINKAGE_NAME (xsym);
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;
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
@@
-2185,6
+2184,7
@@
static const struct sym_fns coff_sym_fns =
for sym_read() */
coff_symfile_read, /* sym_read: read a symbol file into
symtab */
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
coff_symfile_finish, /* sym_finish: finished with file,
cleanup */
default_symfile_offsets, /* sym_offsets: xlate external to
@@
-2195,6
+2195,7
@@
static const struct sym_fns coff_sym_fns =
default_symfile_relocate, /* sym_relocate: Relocate a debug
section. */
default_symfile_relocate, /* sym_relocate: Relocate a debug
section. */
+ NULL, /* sym_probe_fns */
&psym_functions
};
&psym_functions
};
This page took
0.06948 seconds
and
4
git commands to generate.