From f294329c9c4d97e0ac125937e6d01c7d572fa5f6 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 16 Jan 2021 20:42:27 -0800 Subject: [PATCH] as: Automatically enable DWARF5 support Currently $ as -o x.o x.s fails when x.s contains DWARF5 info. 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: Don't pass --gdwarf-5. * testsuite/gas/lns/lns-diag-1.l: Remove the "Error: file number less than one" errors. --- gas/dwarf2dbg.c | 13 +++---------- gas/testsuite/gas/elf/dwarf-5-file0.d | 2 +- gas/testsuite/gas/lns/lns-diag-1.l | 2 -- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index a428370ecca..6c9871cb300 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -551,7 +551,7 @@ 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; /* Don't emit sequences of line symbols for the same line when the symbols apply to assembler code. It is necessary to emit @@ -1043,11 +1043,7 @@ dwarf2_directive_filename (void) num = get_absolute_expression (); if ((offsetT) num < 1 && DWARF2_LINE_VERSION < 5) - { - as_bad (_("file number less than one")); - ignore_rest_of_line (); - return NULL; - } + dwarf_level = 5; /* FIXME: Should we allow ".file \n" as an expression meaning "switch back to the already allocated file as the current @@ -1142,10 +1138,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED) if (filenum < 1) { if (filenum != 0 || DWARF2_LINE_VERSION < 5) - { - as_bad (_("file number less than one")); - return; - } + dwarf_level = 5; } if (filenum >= (int) files_in_use || files[filenum].filename == NULL) diff --git a/gas/testsuite/gas/elf/dwarf-5-file0.d b/gas/testsuite/gas/elf/dwarf-5-file0.d index 5d76b7bcd14..898e30cbf72 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: #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 1256e85cfcb..3d8a52f4d5b 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' -- 2.29.2