2005-11-03 Jim Blandy <jimb@redhat.com>

Checked in by Elena Zannoni  <ezannoni@redhat.com>

       * dwarf2read.c (file_full_name): Cope with file numbers that are
       out of range for the given line header.
This commit is contained in:
Elena Zannoni 2005-11-04 02:46:45 +00:00
parent 6255354386
commit 6a83a1e604
2 changed files with 47 additions and 21 deletions

View File

@ -1,3 +1,10 @@
2005-11-03 Jim Blandy <jimb@redhat.com>
Checked in by Elena Zannoni <ezannoni@redhat.com>
* dwarf2read.c (file_full_name): Cope with file numbers that are
out of range for the given line header.
2005-11-03 Daniel Jacobowitz <dan@codesourcery.com>
Checked in by Elena Zannoni <ezannoni@redhat.com>

View File

@ -8795,32 +8795,51 @@ dwarf_alloc_die (void)
static char *
file_full_name (int file, struct line_header *lh, const char *comp_dir)
{
struct file_entry *fe = &lh->file_names[file - 1];
/* Is the file number a valid index into the line header's file name
table? Remember that file numbers start with one, not zero. */
if (1 <= file && file <= lh->num_file_names)
{
struct file_entry *fe = &lh->file_names[file - 1];
if (IS_ABSOLUTE_PATH (fe->name))
return xstrdup (fe->name);
if (IS_ABSOLUTE_PATH (fe->name))
return xstrdup (fe->name);
else
{
const char *dir;
int dir_len;
char *full_name;
if (fe->dir_index)
dir = lh->include_dirs[fe->dir_index - 1];
else
dir = comp_dir;
if (dir)
{
dir_len = strlen (dir);
full_name = xmalloc (dir_len + 1 + strlen (fe->name) + 1);
strcpy (full_name, dir);
full_name[dir_len] = '/';
strcpy (full_name + dir_len + 1, fe->name);
return full_name;
}
else
return xstrdup (fe->name);
}
}
else
{
const char *dir;
int dir_len;
char *full_name;
/* The compiler produced a bogus file number. We can at least
record the macro definitions made in the file, even if we
won't be able to find the file by name. */
char fake_name[80];
sprintf (fake_name, "<bad macro file number %d>", file);
if (fe->dir_index)
dir = lh->include_dirs[fe->dir_index - 1];
else
dir = comp_dir;
complaint (&symfile_complaints,
_("bad file number in macro information (%d)"),
file);
if (dir)
{
dir_len = strlen (dir);
full_name = xmalloc (dir_len + 1 + strlen (fe->name) + 1);
strcpy (full_name, dir);
full_name[dir_len] = '/';
strcpy (full_name + dir_len + 1, fe->name);
return full_name;
}
else
return xstrdup (fe->name);
return xstrdup (fake_name);
}
}