[v2,2/3] gas: Handle --compress-debug-sections=subopt1,subopt2
Checks
Commit Message
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(-)
@@ -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