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 B4DB43861001 for ; Sat, 29 Aug 2020 12:24:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B4DB43861001 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 9F98B30278CD; Sat, 29 Aug 2020 14:24:19 +0200 (CEST) Received: by librem (Postfix, from userid 1000) id 9D845C1A59; Sat, 29 Aug 2020 14:23:37 +0200 (CEST) Date: Sat, 29 Aug 2020 14:23:37 +0200 From: Mark Wielaard To: "H.J. Lu" Cc: GCC Patches , Jakub Jelinek , Binutils Subject: Re: Duplicate .debug_lines (Was: [PATCH 5/5] Add --gdwarf-5 to ASM_SPEC) Message-ID: <20200829122337.GA3051@wildebeest.org> References: <20200824125658.22526-1-mark@klomp.org> <20200824125658.22526-6-mark@klomp.org> <20200826213729.GG3062@wildebeest.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.2 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2020 12:24:22 -0000 Hi, On Wed, Aug 26, 2020 at 04:38:21PM -0700, H.J. Lu wrote: > On Wed, Aug 26, 2020 at 2:38 PM Mark Wielaard wrote: > > Would it be possible to have something like the following in gas, so > > that it doesn't try generating a .debug_line section if there already > > is one, even when -gdwarf-N is given (unless the assembly also > > contains .loc directives because that shows the user is really > > confused)? > > > > diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c > > index e4ba56d82ba..c0c09f4e9d0 100644 > > --- a/gas/dwarf2dbg.c > > +++ b/gas/dwarf2dbg.c > > @@ -2626,7 +2626,7 @@ dwarf2_init (void) > > > > > > /* Finish the dwarf2 debug sections. We emit .debug.line if there > > - were any .file/.loc directives, or --gdwarf2 was given, or if the > > + were any .file/.loc directives, or --gdwarf2 was given, and if the > > file has a non-empty .debug_info section and an empty .debug_line > > section. If we emit .debug_line, and the .debug_info section is > > empty, we also emit .debug_info, .debug_aranges and .debug_abbrev. > > @@ -2650,9 +2650,16 @@ dwarf2_finish (void) > > empty_debug_line = line_seg == NULL || !seg_not_empty_p (line_seg); > > > > /* We can't construct a new debug_line section if we already have one. > > - Give an error. */ > > + Give an error if we have seen any .loc, otherwise trust the user > > + knows what they are doing and want to generate the .debug_line > > + (and all other debug sections) themselves. */ > > if (all_segs && !empty_debug_line) > > - as_fatal ("duplicate .debug_line sections"); > > + { > > + if (dwarf2_loc_directive_seen) > > + as_fatal ("duplicate .debug_line sections"); > > + else > > + return; > > + } > > > > if ((!all_segs && emit_other_sections) > > || (!emit_other_sections && !empty_debug_line)) > > > > I have run into this issue before. "as -g" shouldn't silently > generate incorrect debug info when input assembly codes already > contain debug directives. AS should either issue an error or > ignore -g. Right, that is what this patch does for .debug_line. gas already doesn't generate .debug_info, .debug_aranges and .debug_abbrev if .debug_info is non-empty, even if -g is given. > In either case, we need a testcase to verify it. Right, and the documentation needs to be update. But first we have to know whether the gas maintainers think this is the right approach. Cheers, Mark