[PATCH 1/1] RISC-V: Correct as --dump-config output for --target=rv64*

Jan Beulich jbeulich@suse.com
Mon Jan 6 09:29:57 GMT 2025


On 06.01.2025 02:15, Xiao Zeng wrote:
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -734,6 +734,18 @@ riscv_check_mapping_symbols (bfd *abfd ATTRIBUTE_UNUSED,
>  const char *
>  riscv_target_format (void)
>  {
> +  /* When as --dump-config is used, xlen is not initialized, resulting in
> +     bfd-target being set to elf32-*riscv even with --target=rv64*.  */
> +  if (xlen == 0)
> +    {
> +      if (strcmp (default_arch, "riscv32") == 0)
> +	xlen = 32;
> +      else if (strcmp (default_arch, "riscv64") == 0)
> +	xlen = 64;
> +      else
> +	as_bad ("unknown default architecture `%s'", default_arch);

My take is that as_bad() is inappropriate here. The function is used to
signal user mistakes. Whereas here we'd really deal with a bug in the
implementation. I expect you want to use e.g. as_abort() instead.

Jan


More information about the Binutils mailing list