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 AFFEA3857800 for ; Mon, 14 Sep 2020 10:24:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AFFEA3857800 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=mark@tarox.wildebeest.org Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 59CE6300BC89; Mon, 14 Sep 2020 12:24:25 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 50FAF4000CBE; Mon, 14 Sep 2020 12:24:25 +0200 (CEST) From: Mark Wielaard To: dwz@sourceware.org Cc: Mark Wielaard Subject: [PATCH 3/4] Handle new DWARF5 attributes. Date: Mon, 14 Sep 2020 12:23:54 +0200 Message-Id: <20200914102355.8137-4-mark@klomp.org> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200914102355.8137-1-mark@klomp.org> References: <20200914102355.8137-1-mark@klomp.org> X-Spam-Status: No, score=-36.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, 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: Mon, 14 Sep 2020 10:24:30 -0000 There are various new attributes that can hold exprlocs (DW_AT_rank, DW_AT_call_value, DW_AT_call_target, DW_AT_call_target_clobbered, DW_AT_call_data_location, DW_AT_call_data_value) or hold addresses (DW_AT_call_return_pc, DW_AT_call_pc). Note that DW_AT_call_origin is listed as also holding exprlocs, but that seems to be a bug in the spec: http://dwarfstd.org/ShowIssue.php?issue=171103.1 There is a new DW_AT_macros that should work the same as DW_AT_GNU_macros. Currently unhandled are DW_AT_dwo_name, DW_AT_str_offsets_base, DW_AT_addr_base, DW_AT_rnglists_base and DW_AT_loclists_base which GCC only emits when generating split-dwarf. All other new attributes don't seem to need any special handling. * dwz.c (add_locexpr_dummy_dies): Handle DW_AT_rank, DW_AT_call_value, DW_AT_call_target, DW_AT_call_target_clobbered, DW_AT_call_data_location and DW_AT_call_data_value. (checksum_die): Handle DW_AT_call_return_pc, DW_AT_call_pc, DW_AT_macros, DW_AT_rank, DW_AT_call_value, DW_AT_call_target, DW_AT_call_target_clobbered, DW_AT_call_data_location, DW_AT_call_data_value, DW_AT_call_return_pc and DW_AT_call_pc. (die_eq_1): Handle DW_AT_call_return_pc and DW_AT_call_pc. (read_debug_info): Recognize all new DWARF5 attributes. (build_abbrevs_for_die): Deal with DW_AT_macros. (write_die): Likewise. And handle DW_AT_rank, DW_AT_call_value, DW_AT_call_target, DW_AT_call_target_clobbered, DW_AT_call_data_location and DW_AT_call_data_value. --- dwz.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/dwz.c b/dwz.c index 5d4b004..b497c5f 100644 --- a/dwz.c +++ b/dwz.c @@ -2370,6 +2370,7 @@ 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: @@ -2392,6 +2393,12 @@ add_locexpr_dummy_dies (DSO *dso, dw_cu_ref cu, dw_die_ref die, 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: @@ -2748,6 +2755,8 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die) case DW_AT_high_pc: case DW_AT_entry_pc: case DW_AT_ranges: + case DW_AT_call_return_pc: + case DW_AT_call_pc: die->die_ck_state = CK_BAD; break; case DW_AT_start_scope: @@ -2758,6 +2767,7 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die) can't be moved to other files easily. */ case DW_AT_stmt_list: case DW_AT_macro_info: + case DW_AT_macros: case DW_AT_GNU_macros: if (!die->die_root) die->die_no_multifile = 1; @@ -3068,6 +3078,7 @@ 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: @@ -3090,6 +3101,12 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die) 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: @@ -4020,6 +4037,10 @@ die_eq_1 (dw_cu_ref cu1, dw_cu_ref cu2, case DW_AT_high_pc: case DW_AT_entry_pc: case DW_AT_ranges: + case DW_AT_call_return_pc: + case DW_AT_call_pc: + /* We shouldn't be hitting DIEs with attributes referencing + addresses and we should have removed DW_AT_subling. */ abort (); case DW_AT_decl_file: case DW_AT_call_file: @@ -6298,7 +6319,7 @@ read_debug_info (DSO *dso, int kind, unsigned int *die_count) goto fail; } - if (t->attr[i].attr > DW_AT_linkage_name + if (t->attr[i].attr > DW_AT_loclists_base && (t->attr[i].attr < DW_AT_MIPS_fde || t->attr[i].attr > DW_AT_MIPS_has_inlines) && (t->attr[i].attr < DW_AT_sf_names @@ -9731,7 +9752,8 @@ build_abbrevs_for_die (htab_t h, dw_cu_ref cu, dw_die_ref die, } if (unlikely (fi_multifile) - && reft->attr[i].attr == DW_AT_GNU_macros + && (reft->attr[i].attr == DW_AT_GNU_macros + || reft->attr[i].attr == DW_AT_macros) && alt_macro_htab != NULL) { struct macro_entry me, *m; @@ -9743,8 +9765,9 @@ build_abbrevs_for_die (htab_t h, dw_cu_ref cu, dw_die_ref die, value = read_32 (ptr); break; default: - error (0, 0, "Unhandled %s for DW_AT_GNU_macros", - get_DW_FORM_str (form)); + error (0, 0, "Unhandled %s for %s", + get_DW_FORM_str (form), + get_DW_AT_str (reft->attr[i].attr)); return 1; } me.ptr = debug_sections[DEBUG_MACRO].data + value; @@ -9752,8 +9775,8 @@ build_abbrevs_for_die (htab_t h, dw_cu_ref cu, dw_die_ref die, htab_find_with_hash (macro_htab, &me, value); if (m->len) { - error (0, 0, "DW_AT_GNU_macros referencing " - "transparent include"); + error (0, 0, "%s referencing transparent include", + get_DW_AT_str (reft->attr[i].attr)); return 1; } ptr -= 4; @@ -11278,7 +11301,8 @@ write_die (unsigned char *ptr, dw_cu_ref cu, dw_die_ref die, } if (unlikely (fi_multifile) - && reft->attr[i].attr == DW_AT_GNU_macros + && (reft->attr[i].attr == DW_AT_GNU_macros + || reft->attr[i].attr == DW_AT_macros) && alt_macro_htab != NULL) { struct macro_entry me, *m; @@ -11539,6 +11563,7 @@ write_die (unsigned char *ptr, dw_cu_ref cu, dw_die_ref die, memcpy (ptr, orig_ptr, inptr - orig_ptr); ptr += inptr - orig_ptr; + /* Old DWARF uses blocks instead of exprlocs. */ if (form == DW_FORM_block1) switch (reft->attr[i].attr) { @@ -11562,6 +11587,12 @@ write_die (unsigned char *ptr, dw_cu_ref cu, dw_die_ref die, 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: -- 2.18.4