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.
This commit is contained in:
parent
93cf38c095
commit
ae9d2233e6
5 changed files with 89 additions and 11 deletions
|
@ -1,3 +1,14 @@
|
|||
2020-10-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
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.
|
||||
|
||||
2020-10-26 Cooper Qu <cooper.qu@linux.alibaba.com>
|
||||
|
||||
* config/tc-csky.c (dump_literals): Fix the literal dump
|
||||
|
|
|
@ -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,
|
||||
|
|
50
gas/testsuite/gas/i386/dwarf4-line-1.d
Normal file
50
gas/testsuite/gas/i386/dwarf4-line-1.d
Normal file
|
@ -0,0 +1,50 @@
|
|||
#as: -gdwarf-4
|
||||
#readelf: -wl
|
||||
#name: DWARF4 .debug_line 1
|
||||
|
||||
Raw dump of debug contents of section \.z?debug_line:
|
||||
|
||||
Offset: 0x0
|
||||
Length: .*
|
||||
DWARF Version: 4
|
||||
Prologue Length: .*
|
||||
Minimum Instruction Length: 1
|
||||
Maximum Ops per Instruction: 1
|
||||
Initial value of 'is_stmt': 1
|
||||
Line Base: -5
|
||||
Line Range: 14
|
||||
Opcode Base: 13
|
||||
|
||||
Opcodes:
|
||||
Opcode 1 has 0 args
|
||||
Opcode 2 has 1 arg
|
||||
Opcode 3 has 1 arg
|
||||
Opcode 4 has 1 arg
|
||||
Opcode 5 has 1 arg
|
||||
Opcode 6 has 0 args
|
||||
Opcode 7 has 0 args
|
||||
Opcode 8 has 0 args
|
||||
Opcode 9 has 1 arg
|
||||
Opcode 10 has 0 args
|
||||
Opcode 11 has 0 args
|
||||
Opcode 12 has 1 arg
|
||||
|
||||
The Directory Table \(offset 0x.*\):
|
||||
1 .*/gas/testsuite/gas/i386
|
||||
|
||||
The File Name Table \(offset 0x.*\):
|
||||
Entry Dir Time Size Name
|
||||
1 0 0 0 foo.c
|
||||
2 0 0 0 foo.h
|
||||
|
||||
Line Number Statements:
|
||||
\[0x.*\] Extended opcode 2: set Address to 0x0
|
||||
\[0x.*\] Advance Line by 81 to 82
|
||||
\[0x.*\] Copy
|
||||
\[0x.*\] Set File Name to entry 2 in the File Name Table
|
||||
\[0x.*\] Advance Line by -73 to 9
|
||||
\[0x.*\] Special opcode 19: advance Address by 1 to 0x1 and Line by 0 to 9
|
||||
\[0x.*\] Advance PC by 3 to 0x4
|
||||
\[0x.*\] Extended opcode 1: End of Sequence
|
||||
|
||||
|
14
gas/testsuite/gas/i386/dwarf4-line-1.s
Normal file
14
gas/testsuite/gas/i386/dwarf4-line-1.s
Normal file
|
@ -0,0 +1,14 @@
|
|||
.file "foo.c"
|
||||
.text
|
||||
bar:
|
||||
#APP
|
||||
# 82 "foo.h" 1
|
||||
nop
|
||||
# 0 "" 2
|
||||
#NO_APP
|
||||
ret
|
||||
foo:
|
||||
.file 1 "foo.c"
|
||||
nop
|
||||
.file 2 "foo.h"
|
||||
ret
|
|
@ -619,6 +619,7 @@ if [gas_32_check] then {
|
|||
run_dump_test "dwarf2-line-2"
|
||||
run_dump_test "dwarf2-line-3"
|
||||
run_dump_test "dwarf2-line-4"
|
||||
run_dump_test "dwarf4-line-1"
|
||||
run_dump_test "dwarf5-line-1"
|
||||
run_dump_test "dwarf5-line-2"
|
||||
run_dump_test "dwarf5-line-3"
|
||||
|
|
Loading…
Add table
Reference in a new issue