From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 1B75F386181F for ; Sun, 14 Feb 2021 08:52:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1B75F386181F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3B34FAD62; Sun, 14 Feb 2021 08:52:06 +0000 (UTC) Date: Sun, 14 Feb 2021 09:52:04 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Cc: Mark Wielaard Subject: [PATCH] Handle DW_FORM_implicit_const for DW_AT_decl_line Message-ID: <20210214085202.GA16780@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2021 08:52:08 -0000 Hi, When running the test-suite like this: ... $ make clean; make; make check CC="gcc -gdwarf-5" CXX="g++ -gdwarf-5" ... we run into: ... FAIL: dwz/testsuite/dwz.tests/odr-struct.sh ... The reason for the FAIL is that this DIE: ... <1><115>: Abbrev Number: 2 (DW_TAG_structure_type) <116> DW_AT_name : aaa <11a> DW_AT_byte_size : 16 <11b> DW_AT_decl_file : 2 <11c> DW_AT_decl_line : 4 <11d> DW_AT_sibling : <0x13a> ... with abbrev: ... 2 DW_TAG_structure_type [has children] DW_AT_name DW_FORM_string DW_AT_byte_size DW_FORM_data1 DW_AT_decl_file DW_FORM_data1 DW_AT_decl_line DW_FORM_data1 DW_AT_sibling DW_FORM_ref4 DW_AT value: 0 DW_FORM value: 0 ... is not recognized as a duplicate of DIE: ... <1><1b9>: Abbrev Number: 2 (DW_TAG_structure_type) <1ba> DW_AT_name : aaa <1be> DW_AT_byte_size : 16 <1bf> DW_AT_decl_file : 2 <1c0> DW_AT_decl_line : 4 <1c0> DW_AT_sibling : <0x1dd> ... with abbrev: ... 2 DW_TAG_structure_type [has children] DW_AT_name DW_FORM_string DW_AT_byte_size DW_FORM_data1 DW_AT_decl_file DW_FORM_data1 DW_AT_decl_line DW_FORM_implicit_const: 4 DW_AT_sibling DW_FORM_ref4 DW_AT value: 0 DW_FORM value: 0 ... due to the DW_AT_decl_line attribute having different forms, DW_FORM_data1 and DW_FORM_implicit_const. Fix this in checksum_die and die_eq_1 by adding dedicated handling for DW_AT_decl_line, similar to how that's done for DW_AT_decl_file. Any comments? Thanks, - Tom Handle DW_FORM_implicit_const for DW_AT_decl_line 2021-02-14 Tom de Vries PR dwz/27400 * dwz.c (checksum_die, die_eq_1): Handle DW_FORM_implicit_const for DW_AT_decl_line. --- dwz.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/dwz.c b/dwz.c index 992da77..971c402 100644 --- a/dwz.c +++ b/dwz.c @@ -3510,7 +3510,35 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die) case DW_AT_call_line: case DW_AT_call_column: if (ignore_locus) - handled = true; + { + handled = true; + break; + } + switch (form) + { + case DW_FORM_data1: value = read_8 (ptr); handled = true; break; + case DW_FORM_data2: value = read_16 (ptr); handled = true; break; + case DW_FORM_data4: value = read_32 (ptr); handled = true; break; + case DW_FORM_data8: value = read_64 (ptr); handled = true; break; + case DW_FORM_udata: + value = read_uleb128 (ptr); handled = true; break; + case DW_FORM_implicit_const: + value = t->values[i]; handled = true; break; + default: + error (0, 0, "%s: Unhandled %s for %s", + dso->filename, get_DW_FORM_str (form), + get_DW_AT_str (t->attr[i].attr)); + return 1; + } + if (handled) + { + ptr = old_ptr; + s = t->attr[i].attr; + die->u.p1.die_hash + = iterative_hash_object (s, die->u.p1.die_hash); + die->u.p1.die_hash + = iterative_hash_object (value, die->u.p1.die_hash); + } break; default: break; @@ -4797,8 +4825,35 @@ die_eq_1 (dw_cu_ref cu1, dw_cu_ref cu2, case DW_AT_call_line: case DW_AT_call_column: if (ignore_locus) - old_ptr1 = NULL; - break; + { + old_ptr1 = NULL; + break; + } + switch (form1) + { + case DW_FORM_data1: value1 = read_8 (ptr1); break; + case DW_FORM_data2: value1 = read_16 (ptr1); break; + case DW_FORM_data4: value1 = read_32 (ptr1); break; + case DW_FORM_data8: value1 = read_64 (ptr1); break; + case DW_FORM_udata: value1 = read_uleb128 (ptr1); break; + case DW_FORM_implicit_const: value1 = t1->values[i]; break; + default: abort (); + } + switch (form2) + { + case DW_FORM_data1: value2 = read_8 (ptr2); break; + case DW_FORM_data2: value2 = read_16 (ptr2); break; + case DW_FORM_data4: value2 = read_32 (ptr2); break; + case DW_FORM_data8: value2 = read_64 (ptr2); break; + case DW_FORM_udata: value2 = read_uleb128 (ptr2); break; + case DW_FORM_implicit_const: value2 = t2->values[j]; break; + default: abort (); + } + if (value1 != value2) + FAIL; + i++; + j++; + continue; default: break; }