aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-01-18 06:25:05 -0800
committerH.J. Lu <hjl.tools@gmail.com>2021-01-26 06:22:42 -0800
commit74c2eff55954b850b8bc9804cbf4e599919a811a (patch)
tree0eab8c605743a59c690029bbfb41d759b5a1d343
parent1ae65e19b214068e0fd3389f755d5a4ffffaca83 (diff)
downloadfsf-binutils-gdb-74c2eff55954b850b8bc9804cbf4e599919a811a.zip
fsf-binutils-gdb-74c2eff55954b850b8bc9804cbf4e599919a811a.tar.gz
fsf-binutils-gdb-74c2eff55954b850b8bc9804cbf4e599919a811a.tar.bz2
as: Automatically enable DWARF5 support
Currently $ as -o x.o x.s fails when x.s contains DWARF5 ".file 0" or ".loc 0" directives. Update assembler to automatically enable DWARF5 support so that $ gcc -S -g -c x.c $ gcc -c x.s works. PR gas/27195 * dwarf2dbg.c (dwarf2_gen_line_info): Set dwarf_level to 5 if needed. (dwarf2_directive_filename): Likewise. (dwarf2_directive_loc): Likewise. * testsuite/gas/elf/dwarf-5-file0.d: Pass --gdwarf-3. * testsuite/gas/lns/lns-diag-1.l: Remove the "Error: file number less than one" errors. (cherry picked from commit 705989f19adf20dd70c50237ec61cd708f2b0939)
-rw-r--r--gas/ChangeLog11
-rw-r--r--gas/dwarf2dbg.c24
-rw-r--r--gas/testsuite/gas/elf/dwarf-5-file0.d2
-rw-r--r--gas/testsuite/gas/lns/lns-diag-1.l2
4 files changed, 30 insertions, 9 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 3ac2f7b..bb336ab 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,14 @@
+2021-01-25 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gas/27195
+ * dwarf2dbg.c (dwarf2_gen_line_info): Set dwarf_level to 5 if
+ needed.
+ (dwarf2_directive_filename): Likewise.
+ (dwarf2_directive_loc): Likewise.
+ * testsuite/gas/elf/dwarf-5-file0.d: Pass --gdwarf-3.
+ * testsuite/gas/lns/lns-diag-1.l: Remove the
+ "Error: file number less than one" errors.
+
2020-11-15 Mark Wielaard <mark@klomp.org>
Backport from the mainline:
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 1160caf..0195a82 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -537,7 +537,11 @@ dwarf2_gen_line_info (addressT ofs, struct dwarf2_line_info *loc)
if (loc->line == 0)
return;
if (loc->filenum == 0 && DWARF2_LINE_VERSION < 5)
- return;
+ {
+ dwarf_level = 5;
+ if (DWARF2_LINE_VERSION < 5)
+ return;
+ }
/* Don't emit sequences of line symbols for the same line when the
symbols apply to assembler code. It is necessary to emit
@@ -1030,9 +1034,13 @@ dwarf2_directive_filename (void)
if ((offsetT) num < 1 && DWARF2_LINE_VERSION < 5)
{
- as_bad (_("file number less than one"));
- ignore_rest_of_line ();
- return NULL;
+ dwarf_level = 5;
+ if (DWARF2_LINE_VERSION < 5)
+ {
+ as_bad (_("file number less than one"));
+ ignore_rest_of_line ();
+ return NULL;
+ }
}
/* FIXME: Should we allow ".file <N>\n" as an expression meaning
@@ -1129,8 +1137,12 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
{
if (filenum != 0 || DWARF2_LINE_VERSION < 5)
{
- as_bad (_("file number less than one"));
- return;
+ dwarf_level = 5;
+ if (DWARF2_LINE_VERSION < 5)
+ {
+ as_bad (_("file number less than one"));
+ return;
+ }
}
}
diff --git a/gas/testsuite/gas/elf/dwarf-5-file0.d b/gas/testsuite/gas/elf/dwarf-5-file0.d
index 5d76b7b..6cc96e3 100644
--- a/gas/testsuite/gas/elf/dwarf-5-file0.d
+++ b/gas/testsuite/gas/elf/dwarf-5-file0.d
@@ -1,4 +1,4 @@
-#as: --gdwarf-5
+#as: --gdwarf-3
#name: DWARF5 .line 0
#readelf: -wl
diff --git a/gas/testsuite/gas/lns/lns-diag-1.l b/gas/testsuite/gas/lns/lns-diag-1.l
index 1256e85..3d8a52f 100644
--- a/gas/testsuite/gas/lns/lns-diag-1.l
+++ b/gas/testsuite/gas/lns/lns-diag-1.l
@@ -1,5 +1,4 @@
.*: Assembler messages:
-.*:2: Error: file number less than one
.*:3: Error: missing string
.*:4: Error: file table slot 1 is already occupied.*
.*:8: Error: unassigned file number 3
@@ -9,7 +8,6 @@
.*:19: Error: bad or irreducible absolute expression
.*:23: Error: isa number less than zero
.*:26: Error: bad or irreducible absolute expression
-.*:26: Error: file number less than one
.*:27: Error: bad or irreducible absolute expression
.*:28: Error: unknown .loc sub-directive `frobnitz'
.*:29: Error: unknown .loc sub-directive `frobnitz'