gas: Use DW_FORM_sec_offset for DWARF version 4 or higher.
authorMark Wielaard <mark@klomp.org>
Tue, 1 Sep 2020 13:29:56 +0000 (15:29 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 3 Sep 2020 16:00:03 +0000 (18:00 +0200)
Older DWARF versions used DW_FORM_data4 or DW_FORM_data8 for offsets
into sections for e.g. DW_AT_stmt_list ot DW_AT_ranges. But version 4
introduced a dedicated form for such section offsets. Make sure to emit
the proper form for newer DWARF versions.

gas/ChangeLog:

* dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_sec_offset for DWARF
version 4 or higher.

gas/ChangeLog
gas/dwarf2dbg.c

index 004834f68c912c223f66a95766ca391fe54ad47c..41c92cf9c728ea26d7dde81c5a553947ce3458e5 100644 (file)
@@ -1,3 +1,8 @@
+2020-09-01  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_sec_offset for DWARF
+       version 4 or higher.
+
 2020-09-02  Alan Modra  <amodra@gmail.com>
 
        * expr.c (add_to_result, subtract_from_result): Use unsigned
index e4ba56d82ba523ec026bb735cbd18fe0c12a37d0..8d19c1d938cace7f369f8157a99387557311ed69 100644 (file)
@@ -2429,15 +2429,22 @@ out_debug_abbrev (segT abbrev_seg,
                  segT info_seg ATTRIBUTE_UNUSED,
                  segT line_seg ATTRIBUTE_UNUSED)
 {
+  int secoff_form;
   subseg_set (abbrev_seg, 0);
 
   out_uleb128 (1);
   out_uleb128 (DW_TAG_compile_unit);
   out_byte (DW_CHILDREN_no);
-  if (DWARF2_FORMAT (line_seg) == dwarf2_format_32bit)
-    out_abbrev (DW_AT_stmt_list, DW_FORM_data4);
+  if (DWARF2_VERSION < 4)
+    {
+      if (DWARF2_FORMAT (line_seg) == dwarf2_format_32bit)
+       secoff_form = DW_FORM_data4;
+      else
+       secoff_form = DW_FORM_data8;
+    }
   else
-    out_abbrev (DW_AT_stmt_list, DW_FORM_data8);
+    secoff_form = DW_FORM_sec_offset;
+  out_abbrev (DW_AT_stmt_list, secoff_form);
   if (all_segs->next == NULL)
     {
       out_abbrev (DW_AT_low_pc, DW_FORM_addr);
@@ -2447,12 +2454,7 @@ out_debug_abbrev (segT abbrev_seg,
        out_abbrev (DW_AT_high_pc, DW_FORM_udata);
     }
   else
-    {
-      if (DWARF2_FORMAT (info_seg) == dwarf2_format_32bit)
-       out_abbrev (DW_AT_ranges, DW_FORM_data4);
-      else
-       out_abbrev (DW_AT_ranges, DW_FORM_data8);
-    }
+    out_abbrev (DW_AT_ranges, secoff_form);
   out_abbrev (DW_AT_name, DW_FORM_strp);
   out_abbrev (DW_AT_comp_dir, DW_FORM_strp);
   out_abbrev (DW_AT_producer, DW_FORM_strp);