From: Tom de Vries <tdevries@suse.de>
To: binutils@sourceware.org
Subject: [PING] [PATCH v2 1/3] gas: Unify parsing of --compress-debug-sections
Date: Thu, 9 Mar 2023 16:33:31 +0100 [thread overview]
Message-ID: <7314d867-9a52-647c-a770-1635ae7f3f0a@suse.de> (raw)
In-Reply-To: <20230228001633.3602-1-tdevries@suse.de>
On 2/28/23 01:16, Tom de Vries via Binutils wrote:
> There are three related option forms:
> * --compress-debug-sections=<none|zlib|zlib-gnu|zlib-gabi>
> * --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
prev parent reply other threads:[~2023-03-09 15:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 0:16 Tom de Vries
2023-02-28 0:16 ` [PATCH v2 2/3] gas: Handle --compress-debug-sections=subopt1,subopt2 Tom de Vries
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 ` Tom de Vries [this message]
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=7314d867-9a52-647c-a770-1635ae7f3f0a@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).