[PATCH 12/19] RISC-V: riscv_set_arch() can fail
Simon Richter
Simon.Richter@hogyros.de
Tue Apr 21 13:00:43 GMT 2026
Hi,
On 4/21/26 8:54 PM, Jan Beulich wrote:
> 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;
> }
Am I reading this correctly that this is still an error, but it avoids a
follow-up NULL pointer dereference?
This is the diagnostic that allowed us to find a bug in ghdl (the vhdl1
frontend does not set the arch string).
Simon
More information about the Binutils
mailing list