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

Message ID 78e9fca9-f92a-4887-98a8-c91eddde0c47@suse.com
State New
Headers
Series RISC-V: assorted fixes and (hopefully) improvements |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Jan Beulich May 15, 2026, 1:34 p.m. UTC
  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>
  

Patch

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