From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id C6C043858CDB for ; Thu, 9 Mar 2023 15:33:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6C043858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 08AD521F89 for ; Thu, 9 Mar 2023 15:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678376000; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h6g1aZ6+FQtsB6anNLeJbtk7H4A5xmHqnbcBZmDp6sk=; b=Lng6iH/6//ZbvSgqsSO7qiDtMq7ZaRw4uj2jPuyyhwIx8+uqGg9VETMYfR3o+KToAunyl9 swcsg53Hkop+DNPnsjE2jk02F5nkhyGb3cPsgJlk0Pfp5OaYs0lc8Yp6T7380KagGGXwC3 tLhpRZZIrmTdI4mt5Dj6Bm7m0yXc/Qo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678376000; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h6g1aZ6+FQtsB6anNLeJbtk7H4A5xmHqnbcBZmDp6sk=; b=F7qAbGNHaiZcJWReIaNrKiL8WpNX2nK8fxbSpJG8inJSkWEt5CIA+zORGaCktbCqJSC9No jE1rHrO/teH5J9CQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E041113A10 for ; Thu, 9 Mar 2023 15:33:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id juldNT/8CWTHXQAAMHmgww (envelope-from ) for ; Thu, 09 Mar 2023 15:33:19 +0000 Message-ID: <7314d867-9a52-647c-a770-1635ae7f3f0a@suse.de> Date: Thu, 9 Mar 2023 16:33:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PING] [PATCH v2 1/3] gas: Unify parsing of --compress-debug-sections Content-Language: en-US To: binutils@sourceware.org References: <20230228001633.3602-1-tdevries@suse.de> From: Tom de Vries In-Reply-To: <20230228001633.3602-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2/28/23 01:16, Tom de Vries via Binutils wrote: > There are three related option forms: > * --compress-debug-sections= > * --compress-debug-sections > * --nocompress-debug-sections > where the last two are documented as being equivalent to: > * --compress-debug-section=zlib-gabi > * --compress-debug-section=none > > However, the three related option forms are handled independently in > parse_args, and there are minor differences in handling. > > For instance, in case !defined OBJ_ELF && !defined OBJ_MAYBE_ELF, using > --compress-debug-section=zlib-gabi or --compress-debug-section=none will > trigger as_fatal ("--compress-debug-sections=%s is unsupported"), while that's > not the case for --compress-debug-sections and --nocompress-debug-sections. > > Fix this by: > - factoring out a new function parse_compress_debug_optarg, and > - using it to handle all three options forms. > > Also make the code easier to read by not nesting preprocessor conditionals. Ping for this series. FWIW, forgot to mention: I've dropped the doc bit in this series because it seems a better idea to update that bit once we've settled on the naming issue. Also, the v1 was a patch and the v2 is a series, my hope is that splitting it up would make it easier to review. Thanks, - Tom > --- > gas/as.c | 47 +++++++++++++++++++++++++++++------------------ > 1 file changed, 29 insertions(+), 18 deletions(-) > > diff --git a/gas/as.c b/gas/as.c > index 598bfd56cf5..40742b13511 100644 > --- a/gas/as.c > +++ b/gas/as.c > @@ -418,6 +418,32 @@ Options:\n\ > fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); > } > > +static void > +parse_compress_debug_optarg (const char *optarg) > +{ > +#if !defined OBJ_ELF && !defined OBJ_MAYBE_ELF > + as_fatal (_("--compress-debug-sections=%s is unsupported"), > + optarg); > +#endif > + > + gas_assert (optarg != NULL); > + > + enum compressed_debug_section_type tmp > + = bfd_get_compression_algorithm (optarg); > + > +#ifndef HAVE_ZSTD > + if (tmp == COMPRESS_DEBUG_ZSTD) > + as_fatal (_ ("--compress-debug-sections=zstd: gas is not " > + "built with zstd support")); > +#endif > + > + if (tmp == COMPRESS_UNKNOWN) > + as_fatal (_("Invalid --compress-debug-sections option: `%s'"), > + optarg); > + > + flag_compress_debug = tmp; > +} > + > /* Since it is easy to do here we interpret the special arg "-" > to mean "use stdin" and we set that argv[] pointing to "". > After we have munged argv[], the only things left are source file > @@ -747,28 +773,13 @@ This program has absolutely no warranty.\n")); > > case OPTION_COMPRESS_DEBUG: > if (optarg) > - { > -#if defined OBJ_ELF || defined OBJ_MAYBE_ELF > - flag_compress_debug = bfd_get_compression_algorithm (optarg); > -#ifndef HAVE_ZSTD > - if (flag_compress_debug == COMPRESS_DEBUG_ZSTD) > - as_fatal (_ ("--compress-debug-sections=zstd: gas is not " > - "built with zstd support")); > -#endif > - if (flag_compress_debug == COMPRESS_UNKNOWN) > - as_fatal (_("Invalid --compress-debug-sections option: `%s'"), > - optarg); > -#else > - as_fatal (_("--compress-debug-sections=%s is unsupported"), > - optarg); > -#endif > - } > + parse_compress_debug_optarg (optarg); > else > - flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB; > + parse_compress_debug_optarg ("zlib-gabi"); > break; > > case OPTION_NOCOMPRESS_DEBUG: > - flag_compress_debug = COMPRESS_DEBUG_NONE; > + parse_compress_debug_optarg ("none"); > break; > > case OPTION_DEBUG_PREFIX_MAP: > > base-commit: d273049e140ef324be2b018e235ae0ba8021a769