[binutils-gdb] RISC-V: riscv_set_arch() can fail
Jan Beulich
jbeulich@sourceware.org
Fri Jun 5 09:13:42 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aa04700525c30e140cdab646b72e31faa1608077
commit aa04700525c30e140cdab646b72e31faa1608077
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Jun 5 11:09:55 2026 +0200
RISC-V: riscv_set_arch() can fail
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>
Diff:
---
gas/config/tc-riscv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 75e5542eb9b..22d002a3309 100644
--- 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-cvs
mailing list