From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 02FB438387BB; Sat, 25 Jun 2022 17:12:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02FB438387BB Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix corrupt DWARF in dw2-double-set-die-type X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: a858187afda380dd0bd9479f58c152178e275903 X-Git-Newrev: 1fa2e2287e8bcac6427f2495049e0ccfb3ee8514 Message-Id: <20220625171224.02FB438387BB@sourceware.org> Date: Sat, 25 Jun 2022 17:12:23 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2022 17:12:24 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1fa2e2287e8b= cac6427f2495049e0ccfb3ee8514 commit 1fa2e2287e8bcac6427f2495049e0ccfb3ee8514 Author: Tom Tromey Date: Thu Jun 9 07:19:13 2022 -0600 Fix corrupt DWARF in dw2-double-set-die-type =20 The dw2-double-set-die-type.exp test case caused an AddressSanitizer failure in the new DWARF scanner. =20 The immediate cause was bad DWARF in the test -- in particular, the the sibling attribute here: =20 <2><181>: Abbrev Number: 33 (DW_TAG_subprogram) <182> DW_AT_external : 1 <183> DW_AT_name : address <18b> DW_AT_type : <0x171> <18f> DW_AT_declaration : 1 <190> DW_AT_sibling : <0x1a1> ... <1><1a1>: Abbrev Number: 23 (DW_TAG_pointer_type) <1a2> DW_AT_byte_size : 4 <1a3> DW_AT_type : <0x1a7> =20 ...points to a "sibling" DIE that is at a different child depth. =20 Because this test case doesn't really require sibling attributes, this patch fixes the problem by removing them from the test. =20 Note that gdb is not generally robust against malformed DWARF. Detecting and compensating for this problem would probably be expensive and, IMO, is better left to some (still hypothetical) DWARF linter. Diff: --- gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S | 31 ------------------= ---- 1 file changed, 31 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S b/gdb/tests= uite/gdb.dwarf2/dw2-double-set-die-type.S index 6f0a0a80346..ab5a2f712aa 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S +++ b/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S @@ -65,7 +65,6 @@ .Ldie_4a: .uleb128 0x4 /* (DIE (0x4a) DW_TAG_namespace) */ .ascii "std\0" /* DW_AT_name */ - .4byte OFFSET (143) /* DW_AT_sibling */ =20 .Ldie_70: .uleb128 0x8 /* (DIE (0x70) DW_TAG_class_type) */ @@ -76,7 +75,6 @@ .uleb128 0x9 /* (DIE (0x76) DW_TAG_structure_type) */ .ascii "_Vector_base >\0" /* DW_AT_name */ .byte 0x1 /* DW_AT_declaration */ - .4byte OFFSET (f7) /* DW_AT_sibling */ =20 .Ldie_80: .uleb128 0xa /* (DIE (0x80) DW_TAG_structure_type) */ @@ -131,13 +129,11 @@ .uleb128 0x1b /* (DIE (0x221) DW_TAG_class_type) */ .ascii "a\0" /* DW_AT_name */ .byte 0x18 /* DW_AT_byte_size */ - .4byte OFFSET (277) /* DW_AT_sibling */ =20 .Ldie_22b: .uleb128 0x1b /* (DIE (0x22b) DW_TAG_class_type) */ .ascii "b\0" /* DW_AT_name */ .byte 0x1 /* DW_AT_byte_size */ - .4byte OFFSET (244) /* DW_AT_sibling */ =20 .Ldie_235: .uleb128 0x1c /* (DIE (0x235) DW_TAG_subprogram) */ @@ -165,7 +161,6 @@ .ascii "a\0" /* DW_AT_name */ .byte 0x1 /* DW_AT_artificial */ .byte 0x1 /* DW_AT_declaration */ - .4byte OFFSET (262) /* DW_AT_sibling */ =20 .Ldie_25b: .uleb128 0xe /* (DIE (0x25b) DW_TAG_formal_parameter) */ @@ -201,7 +196,6 @@ .uleb128 0x20 /* (DIE (0x27d) DW_TAG_class_type) */ .4byte OFFSET (162) /* DW_AT_specification */ .byte 0x1 /* DW_AT_byte_size */ - .4byte OFFSET (3b2) /* DW_AT_sibling */ =20 .Ldie_2d0: .uleb128 0x21 /* (DIE (0x2d0) DW_TAG_subprogram) */ @@ -209,7 +203,6 @@ .ascii "address\0" /* DW_AT_name */ .4byte OFFSET (277) /* DW_AT_type */ .byte 0x1 /* DW_AT_declaration */ - .4byte OFFSET (3b2) /* DW_AT_sibling */ =20 .Ldie_2e5: .uleb128 0xe /* (DIE (0x2e5) DW_TAG_formal_parameter) */ @@ -249,7 +242,6 @@ .uleb128 0x20 /* (DIE (0x3e0) DW_TAG_class_type) */ .4byte OFFSET (70) /* DW_AT_specification */ .byte 0x1 /* DW_AT_byte_size */ - .4byte OFFSET (44e) /* DW_AT_sibling */ =20 .Ldie_3ec: .uleb128 0xb /* (DIE (0x3ec) DW_TAG_inheritance) */ @@ -262,13 +254,11 @@ .uleb128 0x1a /* (DIE (0x44e) DW_TAG_structure_type) */ .4byte OFFSET (76) /* DW_AT_specification */ .byte 0x18 /* DW_AT_byte_size */ - .4byte OFFSET (505) /* DW_AT_sibling */ =20 .Ldie_505: .uleb128 0x11 /* (DIE (0x505) DW_TAG_subprogram) */ .ascii "~_Vector_base\0" /* DW_AT_name */ .byte 0x1 /* DW_AT_declaration */ - .4byte OFFSET (51f) /* DW_AT_sibling */ =20 .Ldie_512: .uleb128 0xe /* (DIE (0x512) DW_TAG_formal_parameter) */ @@ -286,13 +276,11 @@ .ascii "_M_allocate\0" /* DW_AT_name */ .4byte OFFSET (277) /* DW_AT_type */ .byte 0x1 /* DW_AT_declaration */ - .4byte OFFSET (540) /* DW_AT_sibling */ =20 .Ldie_540: .uleb128 0x11 /* (DIE (0x540) DW_TAG_subprogram) */ .ascii "_M_deallocate\0" /* DW_AT_name */ .byte 0x1 /* DW_AT_declaration */ - .4byte OFFSET (562) /* DW_AT_sibling */ =20 .Ldie_551: .uleb128 0xe /* (DIE (0x551) DW_TAG_formal_parameter) */ @@ -327,7 +315,6 @@ .uleb128 0x20 /* (DIE (0x59d) DW_TAG_class_type) */ .4byte OFFSET (f7) /* DW_AT_specification */ .byte 0x18 /* DW_AT_byte_size */ - .4byte OFFSET (b44) /* DW_AT_sibling */ =20 .Ldie_5a9: .uleb128 0xb /* (DIE (0x5a9) DW_TAG_inheritance) */ @@ -390,8 +377,6 @@ .byte 0x1 /* DW_children_yes */ .uleb128 0x3 /* (DW_AT_name) */ .uleb128 0x8 /* (DW_FORM_string) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -420,8 +405,6 @@ .uleb128 0x8 /* (DW_FORM_string) */ .uleb128 0x3c /* (DW_AT_declaration) */ .uleb128 0xc /* (DW_FORM_flag) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -472,8 +455,6 @@ .uleb128 0x8 /* (DW_FORM_string) */ .uleb128 0x3c /* (DW_AT_declaration) */ .uleb128 0xc /* (DW_FORM_flag) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -518,8 +499,6 @@ .uleb128 0x13 /* (DW_FORM_ref4) */ .uleb128 0xb /* (DW_AT_byte_size) */ .uleb128 0xb /* (DW_FORM_data1) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -530,8 +509,6 @@ .uleb128 0x8 /* (DW_FORM_string) */ .uleb128 0xb /* (DW_AT_byte_size) */ .uleb128 0xb /* (DW_FORM_data1) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -572,8 +549,6 @@ .uleb128 0xc /* (DW_FORM_flag) */ .uleb128 0x3c /* (DW_AT_declaration) */ .uleb128 0xc /* (DW_FORM_flag) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -598,8 +573,6 @@ .uleb128 0x13 /* (DW_FORM_ref4) */ .uleb128 0xb /* (DW_AT_byte_size) */ .uleb128 0xb /* (DW_FORM_data1) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -614,8 +587,6 @@ .uleb128 0x13 /* (DW_FORM_ref4) */ .uleb128 0x3c /* (DW_AT_declaration) */ .uleb128 0xc /* (DW_FORM_flag) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0 =20 @@ -640,8 +611,6 @@ .uleb128 0x13 /* (DW_FORM_ref4) */ .uleb128 0x3c /* (DW_AT_declaration) */ .uleb128 0xc /* (DW_FORM_flag) */ - .uleb128 0x1 /* (DW_AT_sibling) */ - .uleb128 0x13 /* (DW_FORM_ref4) */ .byte 0x0 .byte 0x0