aboutsummaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-17 04:24:22 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-17 04:24:22 -0700
commitbd0c565edbf4ba8121fded38e389530d7fa6f963 (patch)
treea56cf044039f44e5acb214d21c0eea27d6de8e32 /gas/dwarf2dbg.c
parent43f8eb75479f1f2d91ef57b0baac90c10a6b3a3d (diff)
downloadgdb-bd0c565edbf4ba8121fded38e389530d7fa6f963.zip
gdb-bd0c565edbf4ba8121fded38e389530d7fa6f963.tar.gz
gdb-bd0c565edbf4ba8121fded38e389530d7fa6f963.tar.bz2
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.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 6943dbf..75ef7c4 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -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;