aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-16 04:03:20 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-16 04:07:59 -0700
commit6915020bb134ae29fd772295c66fd67b5944962d (patch)
tree8876a55aaee7877e764b0b1a576c36483d457ac3
parent23ae20f5e3afeeab9aa616c63ab3b357668476d5 (diff)
downloadbinutils-6915020bb134ae29fd772295c66fd67b5944962d.zip
binutils-6915020bb134ae29fd772295c66fd67b5944962d.tar.gz
binutils-6915020bb134ae29fd772295c66fd67b5944962d.tar.bz2
gas: Reuse the input file entry in the file table
Some instructions can be emitted (dwarf2_emit_insn is called) before the first .file <NUMBER> directive has been seen, which allocates the input file as the first file entry. Reuse the input file entry in the file table. PR gas/25878 PR gas/26740 * dwarf2dbg.c (file_entry): Remove auto_assigned. (assign_file_to_slot): Remove the auto_assign argument. (allocate_filenum): Updated. (allocate_filename_to_slot): Reuse the input file entry in the file table. (dwarf2_where): Replace as_where with as_where_physical. * testsuite/gas/i386/dwarf5-line-1.d: New file. * testsuite/gas/i386/dwarf5-line-1.s: Likewise. * testsuite/gas/i386/i386.exp: Run dwarf5-line-1.
-rw-r--r--gas/ChangeLog18
-rw-r--r--gas/dwarf2dbg.c28
-rw-r--r--gas/testsuite/gas/i386/dwarf5-line-1.d50
-rw-r--r--gas/testsuite/gas/i386/dwarf5-line-1.s6
-rw-r--r--gas/testsuite/gas/i386/i386.exp1
5 files changed, 84 insertions, 19 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index c5235ba..a74362b 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,6 +1,22 @@
+2020-10-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gas/25878
+ PR gas/26740
+ * dwarf2dbg.c (file_entry): Remove auto_assigned.
+ (assign_file_to_slot): Remove the auto_assign argument.
+ (allocate_filenum): Updated.
+ (allocate_filename_to_slot): Reuse the input file entry in the
+ file table.
+ (dwarf2_where): Replace as_where with as_where_physical.
+ * testsuite/gas/i386/dwarf5-line-1.d: New file.
+ * testsuite/gas/i386/dwarf5-line-1.s: Likewise.
+ * testsuite/gas/i386/i386.exp: Run dwarf5-line-1.
+
2020-10-16 Lili Cui <lili.cui@intel.com>
- * config/tc-i386.c: Move Pseudo Prefix check to match_template.
+ * config/tc-i386.c (cpu_flags_match): Move Pseudo Prefix check
+ to ...
+ (match_template): Here.
* testsuite/gas/i386/avx-vnni-inval.l: New file.
* testsuite/gas/i386/avx-vnni-inval.s: Likewise.
* testsuite/gas/i386/avx-vnni.d: Delete invalid {vex2} test.
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 1c21d58..6943dbf 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -211,7 +211,6 @@ struct file_entry
{
const char * filename;
unsigned int dir;
- bfd_boolean auto_assigned;
unsigned char md5[NUM_MD5_BYTES];
};
@@ -633,7 +632,7 @@ get_directory_table_entry (const char * dirname,
}
static bfd_boolean
-assign_file_to_slot (unsigned long i, const char *file, unsigned int dir, bfd_boolean auto_assign)
+assign_file_to_slot (unsigned long i, const char *file, unsigned int dir)
{
if (i >= files_allocated)
{
@@ -653,7 +652,6 @@ assign_file_to_slot (unsigned long i, const char *file, unsigned int dir, bfd_bo
files[i].filename = file;
files[i].dir = dir;
- files[i].auto_assigned = auto_assign;
memset (files[i].md5, 0, NUM_MD5_BYTES);
if (files_in_use < i + 1)
@@ -717,7 +715,7 @@ allocate_filenum (const char * pathname)
return i;
}
- if (!assign_file_to_slot (i, file, dir, TRUE))
+ if (!assign_file_to_slot (i, file, dir))
return -1;
last_used = i;
@@ -792,18 +790,12 @@ allocate_filename_to_slot (const char * dirname,
}
fail:
- /* If NUM was previously allocated automatically then
- choose another slot for it, so that we can reuse NUM. */
- if (files[num].auto_assigned)
- {
- /* Find an unused slot. */
- for (i = 1; i < files_in_use; ++i)
- if (files[i].filename == NULL)
- break;
- if (! assign_file_to_slot (i, files[num].filename, files[num].dir, TRUE))
- return FALSE;
- files[num].filename = NULL;
- }
+ /* 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)"),
@@ -833,7 +825,7 @@ allocate_filename_to_slot (const char * dirname,
d = get_directory_table_entry (dirname, dirlen, num == 0);
i = num;
- if (! assign_file_to_slot (i, file, d, FALSE))
+ if (! assign_file_to_slot (i, file, d))
return FALSE;
if (with_md5)
@@ -902,7 +894,7 @@ dwarf2_where (struct dwarf2_line_info *line)
const char *filename;
memset (line, 0, sizeof (*line));
- filename = as_where (&line->line);
+ filename = as_where_physical (&line->line);
line->filenum = allocate_filenum (filename);
/* FIXME: We should check the return value from allocate_filenum. */
line->column = 0;
diff --git a/gas/testsuite/gas/i386/dwarf5-line-1.d b/gas/testsuite/gas/i386/dwarf5-line-1.d
new file mode 100644
index 0000000..7d602d0
--- /dev/null
+++ b/gas/testsuite/gas/i386/dwarf5-line-1.d
@@ -0,0 +1,50 @@
+#as: -gdwarf-5
+#readelf: -wl
+#name: DWARF5 .debug_line 1
+
+Raw dump of debug contents of section \.z?debug_line:
+
+ Offset: 0x0
+ Length: .*
+ DWARF Version: 5
+ Address size \(bytes\): .*
+ Segment selector \(bytes\): 0
+ 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.*, lines 2, columns 1\):
+ Entry Name
+ 0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
+ 1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
+
+ The File Name Table \(offset 0x.*, lines 2, columns 3\):
+ Entry Dir MD5 Name
+ 0 0 0xbbd69fc03ce253b2dbaab2522dd519ae \(indirect line string, offset: 0x.*\): core.c
+ 1 0 0x00000000000000000000000000000000 \(indirect line string, offset: 0x.*\): types.h
+
+ Line Number Statements:
+ \[0x.*\] Extended opcode 2: set Address to 0x0
+ \[0x.*\] Special opcode 8: advance Address by 0 to 0x0 and Line by 3 to 4
+ \[0x.*\] Advance PC by 1 to 0x1
+ \[0x.*\] Extended opcode 1: End of Sequence
+
+
diff --git a/gas/testsuite/gas/i386/dwarf5-line-1.s b/gas/testsuite/gas/i386/dwarf5-line-1.s
new file mode 100644
index 0000000..6e343ad
--- /dev/null
+++ b/gas/testsuite/gas/i386/dwarf5-line-1.s
@@ -0,0 +1,6 @@
+ .text
+ .global kretprobe_trampoline
+kretprobe_trampoline:
+ ret
+ .file 0 "core.c" md5 0xbbd69fc03ce253b2dbaab2522dd519ae
+ .file 1 "types.h"
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 068813d..6834749 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -614,6 +614,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 "dwarf5-line-1"
run_dump_test "dw2-compress-2"
run_dump_test "dw2-compressed-2"