]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Gas generated incorrect debug info (top-level DW_TAG_unspecified_type DIE)
authorNick Clifton <nickc@redhat.com>
Thu, 8 Sep 2022 11:43:33 +0000 (12:43 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 8 Sep 2022 11:43:33 +0000 (12:43 +0100)
PR 29559
* dwarf2dbg.c (out_debug_info): Place DW_TAG_unspecified_type at
the end of the list of children, not at the start of the CU
information.
* testsuite/gas/elf/dwarf-3-func.d: Update expected output.
* testsuite/gas/elf/dwarf-5-func-global.d: Likewise.
* testsuite/gas/elf/dwarf-5-func-local.d: Likewise.
* testsuite/gas/elf/dwarf-5-func.d: Likewise.

gas/ChangeLog
gas/dwarf2dbg.c
gas/testsuite/gas/elf/dwarf-3-func.d
gas/testsuite/gas/elf/dwarf-5-func-global.d
gas/testsuite/gas/elf/dwarf-5-func-local.d
gas/testsuite/gas/elf/dwarf-5-func.d

index a54e5e2c6806b7be417bb378c8ae7e2d663dca24..6bca7add8f98747ec9b73bb41ff458914f3d2f40 100644 (file)
@@ -1,3 +1,14 @@
+2022-09-08  Nick Clifton  <nickc@redhat.com>
+
+       PR 29559
+       * dwarf2dbg.c (out_debug_info): Place DW_TAG_unspecified_type at
+       the end of the list of children, not at the start of the CU
+       information.
+       * testsuite/gas/elf/dwarf-3-func.d: Update expected output.
+       * testsuite/gas/elf/dwarf-5-func-global.d: Likewise.
+       * testsuite/gas/elf/dwarf-5-func-local.d: Likewise.
+       * testsuite/gas/elf/dwarf-5-func.d: Likewise.
+
 2022-08-31  Frederic Cambus  <fred@statdns.com>
 
        * configure.tgt (aarch64*-*-openbsd*): Add target.
index dbcf9cf7226f24ac46edc74f1838fa3e5ff86300..612d810343870724d740531ebcc7dd754d0759e5 100644 (file)
@@ -2817,7 +2817,6 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
   expressionS exp;
   symbolS *info_end;
   int sizeof_offset;
-  valueT no_type_die = 0;
 
   memset (&exp, 0, sizeof exp);
   sizeof_offset = out_header (info_seg, &exp);
@@ -2846,16 +2845,6 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
       TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
     }
 
-  if (func_form && DWARF2_VERSION > 2)
-    {
-      /* PR 29517: Generate a DIE for the unspecified type abbrev.
-        We do it here so that the offset from the start of the
-        section is fixed.  */
-      subseg_set (info_seg, 0);
-      no_type_die = frag_now_fix_octets ();
-      out_uleb128 (GAS_ABBREV_NO_TYPE);
-    }
-
   /* DW_TAG_compile_unit DIE abbrev */
   out_uleb128 (GAS_ABBREV_COMP_UNIT);
 
@@ -2908,6 +2897,12 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
   if (func_form)
     {
       symbolS *symp;
+      symbolS *no_type_tag;
+
+      if (DWARF2_VERSION > 2)
+       no_type_tag = symbol_make (".Ldebug_no_type_tag");
+      else
+       no_type_tag = NULL;
 
       for (symp = symbol_rootP; symp; symp = symbol_next (symp))
        {
@@ -2957,10 +2952,15 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
          if (func_form == DW_FORM_flag)
            out_byte (S_IS_EXTERNAL (symp));
 
-         /* PR 29517: Let consumers know that we do not
-            have return type information for this function.  */
+         /* PR 29517: Let consumers know that we do not have
+            return type information for this function.  */
          if (DWARF2_VERSION > 2)
-           out_uleb128 (no_type_die);
+           {
+             exp.X_op = O_symbol;
+             exp.X_add_symbol = no_type_tag;
+             exp.X_add_number = 0;
+             emit_leb128_expr (&exp, 0);
+           }
 
          /* DW_AT_low_pc */
          exp.X_op = O_symbol;
@@ -2982,6 +2982,15 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
            emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0);
        }
 
+      if (DWARF2_VERSION > 2)
+       {
+         /* PR 29517: Generate a DIE for the unspecified type abbrev.
+            We do it here because it cannot be part of the top level DIE.   */
+         subseg_set (info_seg, 0);
+         symbol_set_value_now (no_type_tag);
+         out_uleb128 (GAS_ABBREV_NO_TYPE);
+       }
+
       /* End of children.  */
       out_leb128 (0);
     }
index d084518aba1b32a1860ffd46646329c3c63735a3..c92b0d311c0ebce313c5353e06be053cb2a3ada5 100644 (file)
@@ -10,34 +10,34 @@ Contents of the .debug_info section:
  +Version: +3
  +Abbrev Offset: +(0x)?0
  +Pointer Size: .*
- <0><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
 #...
  <0><[0-9a-f]+>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
 #...
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): efunc1
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?0
  +<[0-9a-f]+> +DW_AT_high_pc +: \(addr\) (0x)?2
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): lfunc1
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 0
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?2
  +<[0-9a-f]+> +DW_AT_high_pc +: \(addr\) (0x)?13
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): efunc2
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?13
  +<[0-9a-f]+> +DW_AT_high_pc +: \(addr\) (0x)?35
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): lfunc2
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 0
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?35
  +<[0-9a-f]+> +DW_AT_high_pc +: \(addr\) (0x)?38
+ <1><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
  <1><[0-9a-f]+>: Abbrev Number: 0
 
 Contents of the .debug_abbrev section:
index 65c2ab0f512754a2363e009796e09d3d3c679ccc..090b8dabce34f8ff989237a9492c12bf382cdbad 100644 (file)
@@ -12,22 +12,22 @@ Contents of the .debug_info section:
  +Unit Type: +DW_UT_compile \(1\)
  +Abbrev Offset: +(0x)?0
  +Pointer Size: .*
- <0><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
 #...
  <0><[0-9a-f]+>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
 #...
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): efunc1
  +<[0-9a-f]+> +DW_AT_external +: \(flag_present\) 1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?0
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 2
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): efunc2
  +<[0-9a-f]+> +DW_AT_external +: \(flag_present\) 1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?2
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 34
+ <1><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
  <1><[0-9a-f]+>: Abbrev Number: 0
 
 Contents of the .debug_abbrev section:
index ac666ea93e14cbc6d23c49e7e6f9e045d7eb5d9f..7580c3e66db97791716c87d209fc3ac55f08698a 100644 (file)
@@ -12,20 +12,20 @@ Contents of the .debug_info section:
  +Unit Type: +DW_UT_compile \(1\)
  +Abbrev Offset: +(0x)?0
  +Pointer Size: .*
- <0><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
 #...
  <0><[0-9a-f]+>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
 #...
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): lfunc1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?0
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 17
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): lfunc2
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?11
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 3
+ <1><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
  <1><[0-9a-f]+>: Abbrev Number: 0
 
 Contents of the .debug_abbrev section:
index 612c9f23b16e8d578b37977dc5bef9b314d85981..df5cfc7882dcd115a6358aad98efdafdb369955a 100644 (file)
@@ -12,34 +12,34 @@ Contents of the .debug_info section:
  +Unit Type: +DW_UT_compile \(1\)
  +Abbrev Offset: +(0x)?0
  +Pointer Size: .*
- <0><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
 #...
  <0><[0-9a-f]+>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
 #...
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): efunc1
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?0
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 2
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): lfunc1
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 0
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?2
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 17
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): efunc2
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 1
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?13
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 34
  <1><[0-9a-f]+>: Abbrev Number: 2 \(DW_TAG_subprogram\)
  +<[0-9a-f]+> +DW_AT_name +: \(strp\) \(offset: (0x)?[0-9a-f]+\): lfunc2
  +<[0-9a-f]+> +DW_AT_external +: \(flag\) 0
- +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x.>
+ +<[0-9a-f]+> +DW_AT_type +: \(ref_udata\) <0x[0-9a-f]+>
  +<[0-9a-f]+> +DW_AT_low_pc +: \(addr\) (0x)?35
  +<[0-9a-f]+> +DW_AT_high_pc +: \(udata\) 3
+ <1><[0-9a-f]+>: Abbrev Number: 3 \(DW_TAG_unspecified_type\)
  <1><[0-9a-f]+>: Abbrev Number: 0
 
 Contents of the .debug_abbrev section: