* dwarf2.c (concat_filename): Apply DW_AT_comp_dir if dir table

entry isn't absolute.
This commit is contained in:
Alan Modra 2006-09-17 02:44:38 +00:00
parent 882d0cb477
commit 7421a730ce
2 changed files with 37 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2006-09-17 Anton Blanchard <anton@samba.org>
Alan Modra <amodra@bigpond.net.au>
* dwarf2.c (concat_filename): Apply DW_AT_comp_dir if dir table
entry isn't absolute.
2006-09-17 Mei Ligang <ligang@sunnorth.com.cn>
* cpu-score.c: New file.

View File

@ -874,24 +874,45 @@ concat_filename (struct line_info_table *table, unsigned int file)
filename = table->files[file - 1].name;
if (! IS_ABSOLUTE_PATH (filename))
if (!IS_ABSOLUTE_PATH (filename))
{
char *dirname = (table->files[file - 1].dir
? table->dirs[table->files[file - 1].dir - 1]
: table->comp_dir);
char *dirname = NULL;
char *subdirname = NULL;
char *name;
size_t len;
/* Not all tools set DW_AT_comp_dir, so dirname may be unknown.
The best we can do is return the filename part. */
if (dirname != NULL)
if (table->files[file - 1].dir)
subdirname = table->dirs[table->files[file - 1].dir - 1];
if (!subdirname || !IS_ABSOLUTE_PATH (subdirname))
dirname = table->comp_dir;
if (!dirname)
{
unsigned int len = strlen (dirname) + strlen (filename) + 2;
char * name;
dirname = subdirname;
subdirname = NULL;
}
if (!dirname)
return strdup (filename);
len = strlen (dirname) + strlen (filename) + 2;
if (subdirname)
{
len += strlen (subdirname) + 1;
name = bfd_malloc (len);
if (name)
sprintf (name, "%s/%s/%s", dirname, subdirname, filename);
}
else
{
name = bfd_malloc (len);
if (name)
sprintf (name, "%s/%s", dirname, filename);
return name;
}
return name;
}
return strdup (filename);