gas: Always use as_where for preprocessed assembly codes

Always clear the slot 1 if it was assigned to the input file before the
first .file <NUMBER> directive has been seen.  Always use as_where to
generate the correct debug infor for preprocessed assembly codes.

	PR gas/25878
	PR gas/26740
	* dwarf2dbg.c (allocate_filename_to_slot): Don't reuse the slot 1
	here.
	(dwarf2_where): Restore as_where.
	(dwarf2_directive_filename): Clear the slot 1 if it was assigned
	to the input file.
	* testsuite/gas/i386/dwarf5-line-2.d: New file.
	* testsuite/gas/i386/dwarf5-line-2.s: Likewise.
	* testsuite/gas/i386/dwarf5-line-3.d: Likewise.
	* testsuite/gas/i386/dwarf5-line-3.s: Likewise.
	* testsuite/gas/i386/i386.exp: Run dwarf5-line-2 and
	dwarf5-line-3.
This commit is contained in:
H.J. Lu
2020-10-17 04:24:22 -07:00
parent 43f8eb7547
commit bd0c565edb
7 changed files with 155 additions and 19 deletions

View File

@@ -790,24 +790,15 @@ allocate_filename_to_slot (const char * dirname,
}
fail:
/* Reuse NUM if it is 1 and was assigned to the input file before
the first .file <NUMBER> directive was seen. */
file = as_where_physical (&i);
file = get_basename (file);
if (num == 1 && filename_cmp (file, files[num].filename) == 0)
files[num].filename = NULL;
else
{
as_bad (_("file table slot %u is already occupied by a different file (%s%s%s vs %s%s%s)"),
num,
dir == NULL ? "" : dir,
dir == NULL ? "" : "/",
files[num].filename,
dirname == NULL ? "" : dirname,
dirname == NULL ? "" : "/",
filename);
return FALSE;
}
as_bad (_("file table slot %u is already occupied by a different file (%s%s%s vs %s%s%s)"),
num,
dir == NULL ? "" : dir,
dir == NULL ? "" : "/",
files[num].filename,
dirname == NULL ? "" : dirname,
dirname == NULL ? "" : "/",
filename);
return FALSE;
}
if (dirname == NULL)
@@ -894,7 +885,7 @@ dwarf2_where (struct dwarf2_line_info *line)
const char *filename;
memset (line, 0, sizeof (*line));
filename = as_where_physical (&line->line);
filename = as_where (&line->line);
line->filenum = allocate_filenum (filename);
/* FIXME: We should check the return value from allocate_filenum. */
line->column = 0;
@@ -1088,6 +1079,20 @@ dwarf2_directive_filename (void)
return NULL;
}
if (files_in_use == 2)
{
/* Clear the slot 1 if it was assigned to the input file before
the first .file <NUMBER> directive was seen. */
unsigned int lineno;
const char *file = as_where (&lineno);
file = get_basename (file);
if (filename_cmp (file, files[1].filename) == 0)
{
files[1].filename = NULL;
files_in_use = 0;
}
}
if (! allocate_filename_to_slot (dirname, filename, (unsigned int) num,
with_md5))
return NULL;