From patchwork Tue Feb 28 00:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 62206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2719622wrd; Mon, 27 Feb 2023 16:17:23 -0800 (PST) X-Google-Smtp-Source: AK7set/n9cSeZuWoBmcy52EvhJC8acS35MVHPtiVNsDkJUB7ex9OCa/ZGFenT0LuV6mD1hLCRmaK X-Received: by 2002:a05:6402:322:b0:4ac:b4f3:b8a7 with SMTP id q2-20020a056402032200b004acb4f3b8a7mr1321685edw.7.1677543443680; Mon, 27 Feb 2023 16:17:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677543443; cv=none; d=google.com; s=arc-20160816; b=DL0lZDYmf5b9JjloadK+UHZyV1Xj17NiJzux2+V2DHkJn8q8CnX6ZLdlASLh/2/Z2s f84rrRr42bQHCtzMAaR/ZydlQIsLy2rv+l5ChHve9sJFYqLsJSri93W9BZZ2K/NMbbYG ndLeA1qaP8DB9pt8t+QeCHA/v7q4Ep0aENCQI7vRjwT+icyRfuRsxDiNm5G8vE6wj3qC Xr2mGuWHWwuRHtHs7GDZWuPHHnZrdskI6n445GMf8wgsnvcZvAY8XN7S866yuPGUu114 QPH66LnoX6ws4b4n+LDz/b0h94lc+ujrg5DPcEPhypg9RB9Tz+3t6dfF+HvP7azXkxG9 /zrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=WlbxrzzUMoTfXOFm/I402mUnHFtTN/OJyB6e0BZtABs=; b=bia+eJvepSlWXvqrGBreEu/x1EfnPpuSO4WkZx/gXNSqqJazwymvanf0Fyw83Oj6NH 9+3PdvJlpMKfq6ctm4s6JU4lFdhWGz+KsxL/Gn9yc7QADDZCZeVRQc6lrrUWmBfrqvAZ IA/v0/hgVXu3ftGQKNP2fV8xdkvLBoBZLbSJbaaIYqTxw/qUDN/42E3xBD6j8X52lk8X pTQOZUpAMpny9NP1QZZtoP80LxtQ4u0vTH8W8eg0GmBk69asNZbcpsFJRE8XmhZLc8JA KJrLZkJh3yDCeeGDUrKsOnRIjpe7lDi3CU1ESakzkgaeyQk3scDJrJqu+/PDe56VkdAP RiMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OKpzQYan; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i7-20020aa7c707000000b004aef1baf38asi9905196edq.96.2023.02.27.16.17.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 16:17:23 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OKpzQYan; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8842A3858296 for ; Tue, 28 Feb 2023 00:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8842A3858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677543441; bh=WlbxrzzUMoTfXOFm/I402mUnHFtTN/OJyB6e0BZtABs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OKpzQYanvJJdtwYXAk85CD52smENV7+UdKARCH0YX4TpNo5IDfgF5DLUlkE+Pvqeh E+BLapRv4y3zbWSYao54zZaQnvGFyyFceKm6r1scKnZZ6nv8oskuTerEWdNuyq8wfl UgFD3ncaAP8DDhPz6bBA5j6Vg8pRqhEi6VK9rSF0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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) 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 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 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 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-Patchwork-Original-From: Tom de Vries via Binutils From: Tom de Vries Reply-To: Tom de Vries Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759031793930427533?= X-GMAIL-MSGID: =?utf-8?q?1759031793930427533?= 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