From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126655 invoked by alias); 28 Apr 2018 19:01:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 126645 invoked by uid 89); 28 Apr 2018 19:01:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=dw_at_, DW_AT_ X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Apr 2018 19:01:48 +0000 Received: from librem.wildebeest.org (deer0x01.wildebeest.org [172.31.17.131]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 2ED7230008A2; Sat, 28 Apr 2018 21:01:45 +0200 (CEST) Received: by librem.wildebeest.org (Postfix, from userid 1000) id D0E6D140963; Sat, 28 Apr 2018 21:01:45 +0200 (CEST) Date: Sat, 28 Apr 2018 19:24:00 -0000 From: Mark Wielaard To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] DWARF: Add .debug_addr table header for dwarf_version >= 5. Message-ID: <20180428190145.GA8276@wildebeest.org> References: <1524928992-18156-1-git-send-email-mark@klomp.org> <20180428163602.GB8577@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180428163602.GB8577@tucnak> User-Agent: Mutt/1.9.4 (2018-02-28) X-SW-Source: 2018-04/txt/msg01284.txt.bz2 On Sat, Apr 28, 2018 at 06:36:02PM +0200, Jakub Jelinek wrote: > On Sat, Apr 28, 2018 at 05:23:12PM +0200, Mark Wielaard wrote: > > switch_to_section (debug_addr_section); > > + /* GNU DebugFission didn't have a header for .debug_addr. */ > > + if (dwarf_version >= 5) > > + { > > + unsigned long addrs_length = > > + addr_index_table->elements () * DWARF2_ADDR_SIZE + 4; > > No = at the end of line, it should be at the start of the next line, i.e. > unsigned long addrs_length > = addr_index_table->elements () * DWARF2_ADDR_SIZE + 4; Oops. Fixed. > > + if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) > > + dw2_asm_output_data (4, 0xffffffff, > > + "Escape value for 64-bit DWARF extension"); > > + dw2_asm_output_data (DWARF_OFFSET_SIZE, addrs_length, > > + "Length of Address Unit"); > > + dw2_asm_output_data (2, 5, "DWARF addr version"); > > + dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address"); > > + dw2_asm_output_data (1, 0, "Size of Segment Descriptor"); > > + } > > ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label); > > output_addr_table (); > > } > > Shouldn't we together with the addition of the .debug_addr section header > also switch to using DW_AT_addr_base rather than DW_AT_GNU_addr_base, i.e. > add DW_AT_addr_base into dwarf_AT and use dwarf_AT (DW_AT_addr_base) > instead of DW_AT_GNU_addr_base? Yes of course. I was actually checking the DWARF version of the CU, but having the correct attribute is obviously better. Updated patch: GNU DebugFission didn't add table headers for the .debug_addr tables, but DWARF5 does. The table header makes it possible for a DWARF consumer to parse the address tables without having to index all .debug_info CUs first. We can keep using the .debug_addr section label as is, because the DW_AT_[GNU_]addr_base attribute points at the actual address index, which starts right after the table header. So the label is generated at the correct location whether the header is added first or not. Add DW_AT_addr_base instead of DW_AT_GNU_addr_base to the skeleton CU DIE for DWARF5. gcc/ChangeLog * dwarf2out.c (dwarf2out_finish): Add .debug_addr table header for dwarf_version >= 5. (dwarf_AT): Handle DW_AT_addr_base. (add_top_level_skeleton_die_attrs): Use dwarf_AT for DW_AT_addr_base. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index d3d925d..c172387 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -1724,6 +1724,11 @@ dwarf_AT (enum dwarf_attribute at) return DW_AT_GNU_dwo_name; break; + case DW_AT_addr_base: + if (dwarf_version < 5) + return DW_AT_GNU_addr_base; + break; + default: break; } @@ -11106,7 +11111,7 @@ add_top_level_skeleton_die_attrs (dw_die_ref die) if (comp_dir != NULL) add_skeleton_AT_string (die, DW_AT_comp_dir, comp_dir); add_AT_pubnames (die); - add_AT_lineptr (die, DW_AT_GNU_addr_base, debug_addr_section_label); + add_AT_lineptr (die, dwarf_AT (DW_AT_addr_base), debug_addr_section_label); } /* Output skeleton debug sections that point to the dwo file. */ @@ -31293,6 +31298,21 @@ dwarf2out_finish (const char *) } switch_to_section (debug_addr_section); + /* GNU DebugFission didn't have a header for .debug_addr. */ + if (dwarf_version >= 5) + { + unsigned long addrs_length + = addr_index_table->elements () * DWARF2_ADDR_SIZE + 4; + + if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + dw2_asm_output_data (4, 0xffffffff, + "Escape value for 64-bit DWARF extension"); + dw2_asm_output_data (DWARF_OFFSET_SIZE, addrs_length, + "Length of Address Unit"); + dw2_asm_output_data (2, 5, "DWARF addr version"); + dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address"); + dw2_asm_output_data (1, 0, "Size of Segment Descriptor"); + } ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label); output_addr_table (); }