public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
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	[thread overview]
Message-ID: <20230228001633.3602-2-tdevries@suse.de> (raw)
In-Reply-To: <20230228001633.3602-1-tdevries@suse.de>

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


  reply	other threads:[~2023-02-28  0:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28  0:16 [PATCH v2 1/3] gas: Unify parsing of --compress-debug-sections Tom de Vries
2023-02-28  0:16 ` Tom de Vries [this message]
2023-02-28  0:16 ` [PATCH v2 3/3] gas: Add --compress-debug-sections={heuristic-always,heuristic-sizewin} Tom de Vries
2023-03-09 15:33 ` [PING] [PATCH v2 1/3] gas: Unify parsing of --compress-debug-sections Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230228001633.3602-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).