[PATCH 12/19] RISC-V: riscv_set_arch() can fail
Jiawei
jiawei@iscas.ac.cn
Wed Apr 29 12:08:35 GMT 2026
> In that case neither riscv_rps_as.subset_list nor file_arch_str would be
> set, yet the NULL pointers would be happily passed into functions not
> expecting such.
>
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -345,7 +345,9 @@ riscv_set_arch (const char *s)
> {
> as_bad (_("the architecture string of -march and elf architecture "
> "attributes cannot be empty"));
> - return;
> + if (file_arch_str != NULL)
> + return;
> + s = DEFAULT_RISCV_ARCH_WITH_EXT;
> }
>
> if (riscv_rps_as.subset_list == NULL)
>
LGTM.
So this should still catch cases like a frontend failing to provide the
archstring, while avoiding a follow-up crash.
Reviewed-by: Jiawei <jiawei@iscas.ac.cn>
More information about the Binutils
mailing list