From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 42C7C387084D for ; Sat, 13 Feb 2021 22:47:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 42C7C387084D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark@klomp.org Received: from librem (deer0x15.wildebeest.org [172.31.17.151]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 8D75B3032F95; Sat, 13 Feb 2021 23:47:56 +0100 (CET) Received: by librem (Postfix, from userid 1000) id 4BAE3C0A3C; Sat, 13 Feb 2021 23:46:46 +0100 (CET) From: Mark Wielaard To: dwz@sourceware.org Cc: Mark Wielaard Subject: [PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher. Date: Sat, 13 Feb 2021 23:46:22 +0100 Message-Id: <20210213224622.16521-1-mark@klomp.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sat, 13 Feb 2021 22:48:00 -0000 Since DWARF version 4 blocks just contain bytes, trying to interpret them as exprlocs will most likely fail. * dwz.c (add_locexpr_dummy_dies): Only handle block as exprloc for cu_version < 4. (checksum_die): Likewise. (write_die): Likewise. https://sourceware.org/bugzilla/show_bug.cgi?id=26987 --- dwz.c | 166 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 84 insertions(+), 82 deletions(-) diff --git a/dwz.c b/dwz.c index d6b9df0..02fcd8c 100644 --- a/dwz.c +++ b/dwz.c @@ -2913,43 +2913,44 @@ add_locexpr_dummy_dies (DSO *dso, dw_cu_ref cu, dw_die_ref die, if (form == DW_FORM_block1) { /* Old DWARF uses blocks instead of exprlocs. */ - switch (attr) - { - case DW_AT_frame_base: - case DW_AT_location: - case DW_AT_data_member_location: - case DW_AT_vtable_elem_location: - case DW_AT_byte_size: - case DW_AT_bit_offset: - case DW_AT_bit_size: - case DW_AT_string_length: - case DW_AT_lower_bound: - case DW_AT_return_addr: - case DW_AT_bit_stride: - case DW_AT_upper_bound: - case DW_AT_count: - case DW_AT_segment: - case DW_AT_static_link: - case DW_AT_use_location: - case DW_AT_allocated: - case DW_AT_associated: - case DW_AT_data_location: - case DW_AT_byte_stride: - case DW_AT_rank: - case DW_AT_call_value: - case DW_AT_call_target: - case DW_AT_call_target_clobbered: - case DW_AT_call_data_location: - case DW_AT_call_data_value: - case DW_AT_GNU_call_site_value: - case DW_AT_GNU_call_site_data_value: - case DW_AT_GNU_call_site_target: - case DW_AT_GNU_call_site_target_clobbered: - if (read_exprloc_low_mem_phase1 (dso, die, ptr, len)) - return 1; - default: - break; - } + if (cu->cu_version < 4) + switch (attr) + { + case DW_AT_frame_base: + case DW_AT_location: + case DW_AT_data_member_location: + case DW_AT_vtable_elem_location: + case DW_AT_byte_size: + case DW_AT_bit_offset: + case DW_AT_bit_size: + case DW_AT_string_length: + case DW_AT_lower_bound: + case DW_AT_return_addr: + case DW_AT_bit_stride: + case DW_AT_upper_bound: + case DW_AT_count: + case DW_AT_segment: + case DW_AT_static_link: + case DW_AT_use_location: + case DW_AT_allocated: + case DW_AT_associated: + case DW_AT_data_location: + case DW_AT_byte_stride: + case DW_AT_rank: + case DW_AT_call_value: + case DW_AT_call_target: + case DW_AT_call_target_clobbered: + case DW_AT_call_data_location: + case DW_AT_call_data_value: + case DW_AT_GNU_call_site_value: + case DW_AT_GNU_call_site_data_value: + case DW_AT_GNU_call_site_target: + case DW_AT_GNU_call_site_target_clobbered: + if (read_exprloc_low_mem_phase1 (dso, die, ptr, len)) + return 1; + default: + break; + } return 0; } @@ -3736,50 +3737,51 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die) if (form == DW_FORM_block1) { /* Old DWARF uses blocks instead of exprlocs. */ - switch (t->attr[i].attr) - { - case DW_AT_frame_base: - case DW_AT_location: - case DW_AT_data_member_location: - case DW_AT_vtable_elem_location: - case DW_AT_byte_size: - case DW_AT_bit_offset: - case DW_AT_bit_size: - case DW_AT_string_length: - case DW_AT_lower_bound: - case DW_AT_return_addr: - case DW_AT_bit_stride: - case DW_AT_upper_bound: - case DW_AT_count: - case DW_AT_segment: - case DW_AT_static_link: - case DW_AT_use_location: - case DW_AT_allocated: - case DW_AT_associated: - case DW_AT_data_location: - case DW_AT_byte_stride: - case DW_AT_rank: - case DW_AT_call_value: - case DW_AT_call_target: - case DW_AT_call_target_clobbered: - case DW_AT_call_data_location: - case DW_AT_call_data_value: - case DW_AT_GNU_call_site_value: - case DW_AT_GNU_call_site_data_value: - case DW_AT_GNU_call_site_target: - case DW_AT_GNU_call_site_target_clobbered: - if (die->die_ck_state != CK_BAD) - { - s = t->attr[i].attr; - die->u.p1.die_hash - = iterative_hash_object (s, die->u.p1.die_hash); - } - if (read_exprloc (dso, die, ptr, len, NULL)) - return 1; - handled = true; - default: - break; - } + if (cu->cu_version < 4) + switch (t->attr[i].attr) + { + case DW_AT_frame_base: + case DW_AT_location: + case DW_AT_data_member_location: + case DW_AT_vtable_elem_location: + case DW_AT_byte_size: + case DW_AT_bit_offset: + case DW_AT_bit_size: + case DW_AT_string_length: + case DW_AT_lower_bound: + case DW_AT_return_addr: + case DW_AT_bit_stride: + case DW_AT_upper_bound: + case DW_AT_count: + case DW_AT_segment: + case DW_AT_static_link: + case DW_AT_use_location: + case DW_AT_allocated: + case DW_AT_associated: + case DW_AT_data_location: + case DW_AT_byte_stride: + case DW_AT_rank: + case DW_AT_call_value: + case DW_AT_call_target: + case DW_AT_call_target_clobbered: + case DW_AT_call_data_location: + case DW_AT_call_data_value: + case DW_AT_GNU_call_site_value: + case DW_AT_GNU_call_site_data_value: + case DW_AT_GNU_call_site_target: + case DW_AT_GNU_call_site_target_clobbered: + if (die->die_ck_state != CK_BAD) + { + s = t->attr[i].attr; + die->u.p1.die_hash + = iterative_hash_object (s, die->u.p1.die_hash); + } + if (read_exprloc (dso, die, ptr, len, NULL)) + return 1; + handled = true; + default: + break; + } ptr += len; } else if (form == DW_FORM_exprloc) @@ -12392,7 +12394,7 @@ write_die (unsigned char *ptr, dw_cu_ref cu, dw_die_ref die, ptr += inptr - orig_ptr; /* Old DWARF uses blocks instead of exprlocs. */ - if (form == DW_FORM_block1) + if (form == DW_FORM_block1 && cu->cu_version < 4) switch (reft->attr[i].attr) { case DW_AT_frame_base: -- 2.20.1