aboutsummaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-26 06:16:08 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-26 06:16:21 -0700
commitae9d2233e61a98ff8dba56be10219aa5306ffc9a (patch)
tree660106b67bb2843a8828b283acc6e759fc6235ea /gas/dwarf2dbg.c
parent93cf38c095afbee84ed580c431d001f20442f73e (diff)
downloadgdb-ae9d2233e61a98ff8dba56be10219aa5306ffc9a.zip
gdb-ae9d2233e61a98ff8dba56be10219aa5306ffc9a.tar.gz
gdb-ae9d2233e61a98ff8dba56be10219aa5306ffc9a.tar.bz2
gas: Clear all auto-assigned file slots
Since a file slot is auto-assigned for the #APP marker appeared before the first .file <NUMBER> directive has been seen, clear all auto-assigned file slots when seeing the first .file <NUMBER> directive. PR gas/26778 * * dwarf2dbg.c (num_of_auto_assigned): New. (allocate_filenum): Increment num_of_auto_assigned. (dwarf2_directive_filename): Clear the slots auto-assigned before the first .file <NUMBER> directive was seen. * testsuite/gas/i386/dwarf4-line-1.d: New file. * testsuite/gas/i386/dwarf4-line-1.s: Likewise. * testsuite/gas/i386/i386.exp: Run dwarf4-line-1.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 75ef7c4..4e03c63 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -218,6 +218,7 @@ struct file_entry
static struct file_entry *files;
static unsigned int files_in_use;
static unsigned int files_allocated;
+static unsigned int num_of_auto_assigned;
/* Table of directories used by .debug_line. */
static char ** dirs = NULL;
@@ -718,6 +719,8 @@ allocate_filenum (const char * pathname)
if (!assign_file_to_slot (i, file, dir))
return -1;
+ num_of_auto_assigned++;
+
last_used = i;
last_used_dir_len = dir_len;
@@ -1013,6 +1016,7 @@ dwarf2_directive_filename (void)
char *filename;
const char * dirname = NULL;
int filename_len;
+ unsigned int i;
/* Continue to accept a bare string and pass it off. */
SKIP_WHITESPACE ();
@@ -1079,18 +1083,16 @@ dwarf2_directive_filename (void)
return NULL;
}
- if (files_in_use == 2)
+ if (num_of_auto_assigned)
{
- /* 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;
- }
+ /* Clear slots auto-assigned before the first .file <NUMBER>
+ directive was seen. */
+ if (files_in_use != (num_of_auto_assigned + 1))
+ abort ();
+ for (i = 1; i < files_in_use; i++)
+ files[i].filename = NULL;
+ files_in_use = 0;
+ num_of_auto_assigned = 0;
}
if (! allocate_filename_to_slot (dirname, filename, (unsigned int) num,