[PATCH v2 10/16] RISC-V: riscv_set_arch() can fail

Jan Beulich jbeulich@suse.com
Fri May 15 13:34:05 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.

Reviewed-by: Jiawei <jiawei@iscas.ac.cn>

--- 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)



More information about the Binutils mailing list