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 35EB63858C52 for ; Tue, 28 Feb 2023 00:16:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35EB63858C52 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 6CA3821A3D for ; Tue, 28 Feb 2023 00:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1677543386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WlbxrzzUMoTfXOFm/I402mUnHFtTN/OJyB6e0BZtABs=; b=d188Cbjlj6EXR5eVD+Aj8vIoZ4l5adDxzGDwrQas8HBTfET7Si6fqrM1Z++D67XprvHo08 fLDqR8hDQlcgCYlISKrHxzce4og89BLPc/6b3pj4iZg2qhwhZPFEC9WJzh6/5yNWvYVo6/ uSqYcUZp1LB3QGkJNTG1nR3qOhoVxeA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1677543386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WlbxrzzUMoTfXOFm/I402mUnHFtTN/OJyB6e0BZtABs=; b=0IA+lgX+Kfrop62b8PC8T0asPeRPZbuKO/+oLcblbKK3qK/X7GacbV7hgIkWjzAzv5e8sa NEndWMUiKC5wpTBQ== 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 57C6513912 for ; Tue, 28 Feb 2023 00:16:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SCxPFNpH/WPNdgAAMHmgww (envelope-from ) for ; Tue, 28 Feb 2023 00:16:26 +0000 From: Tom de Vries To: binutils@sourceware.org Subject: [PATCH v2 2/3] gas: Handle --compress-debug-sections=subopt1,subopt2 Date: Tue, 28 Feb 2023 01:16:32 +0100 Message-Id: <20230228001633.3602-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230228001633.3602-1-tdevries@suse.de> References: <20230228001633.3602-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,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: Add the possibility to specify more than one --compress-debug-sections subopt at a time, using a comma separator. Using --compress-debug-sections=subopt1,subopt2 is equivalent to using --compress-debug-sections=subopt1 --compress-debug-sections=subopt2. --- gas/as.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/gas/as.c b/gas/as.c index 40742b13511..c159c5d0d0a 100644 --- a/gas/as.c +++ b/gas/as.c @@ -419,13 +419,8 @@ Options:\n\ } static void -parse_compress_debug_optarg (const char *optarg) +parse_compress_debug_optarg_1 (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 @@ -444,6 +439,45 @@ parse_compress_debug_optarg (const char *optarg) flag_compress_debug = tmp; } +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); + + /* Tokenize subopts pass to parse_compress_debug_optarg_1. */ + char sep = ','; + while (true) + { + const char *idx = optarg; + while (*idx != '\0' && *idx != sep) + idx++; + + size_t len = idx - optarg; + if (len == 0) + { + /* Generate error. */ + parse_compress_debug_optarg_1 (""); + break; + } + + char *tmp = xstrndup (optarg, len); + parse_compress_debug_optarg_1 (tmp); + free (tmp); + + if (*idx == '\0') + break; + + /* Step over separator and continue tokenizing. */ + gas_assert (*idx == sep); + optarg = idx + 1; + } +} + /* 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 -- 2.35.3