Add support for a ".file 0" directive if supporting DWARF 5 or higher.
authorNick Clifton <nickc@redhat.com>
Fri, 6 Mar 2020 17:13:22 +0000 (17:13 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 6 Mar 2020 17:13:22 +0000 (17:13 +0000)
PR 25614
* dwarf2dbg.c (dwarf2_directive_filename): Allow a file number of
0 if the dwarf_level is 5 or more.  Complain if a filename follows
a file 0.
* testsuite/gas/elf/dwarf-5-file0.s: New test.
* testsuite/gas/elf/dwarf-5-file0.d: New test driver.
* testsuite/gas/elf/elf.exp: Run the new test.

PR 25612
* config/tc-ia64.h (DWARF2_VERISION): Fix typo.
* doc/as.texi: Fix another typo.

gas/ChangeLog
gas/config/tc-ia64.h
gas/doc/as.texi
gas/dwarf2dbg.c
gas/testsuite/gas/elf/dwarf-5-file0.d [new file with mode: 0644]
gas/testsuite/gas/elf/dwarf-5-file0.s [new file with mode: 0644]
gas/testsuite/gas/elf/elf.exp

index 1b377fd3b346210b09c734feafd9bbcf4da483e4..c6a8a4f19b41009575716e1a495c8a82fb37f790 100644 (file)
@@ -1,3 +1,17 @@
+2020-03-06  Nick Clifton  <nickc@redhat.com>
+
+       PR 25614
+       * dwarf2dbg.c (dwarf2_directive_filename): Allow a file number of
+       0 if the dwarf_level is 5 or more.  Complain if a filename follows
+       a file 0.
+       * testsuite/gas/elf/dwarf-5-file0.s: New test.
+       * testsuite/gas/elf/dwarf-5-file0.d: New test driver.
+       * testsuite/gas/elf/elf.exp: Run the new test.
+
+       PR 25612
+       * config/tc-ia64.h (DWARF2_VERISION): Fix typo.
+       * doc/as.texi: Fix another typo.
+
 2020-03-06  Nick Clifton  <nickc@redhat.com>
 
        PR 25612
index 3a50f86b229e0ceca6a597d1197e7df5d2589485..e982e57b477c7b39fe0aa13463fb33144888299d 100644 (file)
@@ -325,5 +325,5 @@ typedef struct unwind_record
 
 /* VMS backtraces expect dwarf version 3.  */
 #ifdef TE_VMS
-#define DWARF2_VERSION      (dwarf_level < 3 ? 3  : debug_level)
+#define DWARF2_VERSION      (dwarf_level < 3 ? 3  : dwarf_level)
 #endif
index ff0ef63fbd81335cc14e3e10bfc23e36db519535..711578fc76238ffa3788b18b3f2638df17b87be0 100644 (file)
@@ -780,7 +780,7 @@ per target basis.
 @item --gdwarf-5
 This option is the same as the @option{--gdwarf-2} option, except that it
 allows for the possibility of the generation of extra debug information as per
-version 4 of the DWARF specification.  Note - enabling this option does not
+version 5 of the DWARF specification.  Note - enabling this option does not
 guarantee the generation of any extra infortmation, the choice to do so is on a
 per target basis.
 
index 7384a17c57759bb19a0c578ee2071d723408ebee..181401300e6b54d5cc5f1e34f2d0c01a59074980 100644 (file)
@@ -794,17 +794,27 @@ dwarf2_directive_filename (void)
     }
 
   num = get_absolute_expression ();
-  filename = demand_copy_C_string (&filename_len);
-  if (filename == NULL)
-    return NULL;
-  demand_empty_rest_of_line ();
 
-  if ((offsetT) num < 1)
+  if ((offsetT) num < 1 && dwarf_level < 5)
     {
       as_bad (_("file number less than one"));
+      ignore_rest_of_line ();
       return NULL;
     }
 
+  if (num == 0)
+    {
+      demand_empty_rest_of_line ();
+      return NULL;
+    }
+
+  filename = demand_copy_C_string (&filename_len);
+  if (filename == NULL)
+    /* demand_copy_C_string will have already generated an error message.  */
+    return NULL;
+
+  demand_empty_rest_of_line ();
+
   /* A .file directive implies compiler generated debug information is
      being supplied.  Turn off gas generated debug info.  */
   debug_type = DEBUG_NONE;
@@ -821,7 +831,7 @@ dwarf2_directive_filename (void)
       return NULL;
     }
 
-  get_filenum (filename, (unsigned int) num);
+  (void) get_filenum (filename, (unsigned int) num);
 
   return filename;
 }
diff --git a/gas/testsuite/gas/elf/dwarf-5-file0.d b/gas/testsuite/gas/elf/dwarf-5-file0.d
new file mode 100644 (file)
index 0000000..a3d1fdf
--- /dev/null
@@ -0,0 +1,6 @@
+#as: --gdwarf-5
+#name: DWARF5 .line 0
+#readelf: -wl
+
+#pass
+
diff --git a/gas/testsuite/gas/elf/dwarf-5-file0.s b/gas/testsuite/gas/elf/dwarf-5-file0.s
new file mode 100644 (file)
index 0000000..c00ec5e
--- /dev/null
@@ -0,0 +1,18 @@
+       .text
+
+.file 0
+.line 1
+       .long 3
+
+.file 1 "asdf"
+.line 2
+       .long 5
+
+.file 0
+.line 4
+       .long 3
+
+.file 2 "def"
+.line 5
+       .long 3
+
index b0522af3bb1482df9b29cf51a6df6ddae79d5374..c80175cc51d7947a5b17385e52ea2e974c06e2e2 100644 (file)
@@ -272,6 +272,7 @@ if { [is_elf_format] } then {
     run_dump_test "dwarf2-17" $dump_opts
     run_dump_test "dwarf2-18" $dump_opts
     run_dump_test "dwarf2-19" $dump_opts
+    run_dump_test "dwarf-5-file0" $dump_opts
     run_dump_test "bss"
     run_dump_test "bad-bss"
     run_dump_test "bad-section-flag"
This page took 0.033924 seconds and 4 git commands to generate.