RISC-V: riscv_parse_subset_t's isa_spec is only parser input
Alan Modra
amodra@gmail.com
Sat Jun 13 07:09:48 GMT 2026
On Fri, Jun 12, 2026 at 09:12:20AM +0200, Jan Beulich wrote:
> On 08.06.2026 02:37, Alan Modra wrote:
> > check_compiler_available fails with a ld segfault linking
> > int main (void) { return 0; }
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x0000000000466a64 in riscv_parse_add_subset (rps=rps@entry=0x7fffffffd450, subset=subset@entry=0x962ca0 "zaamo", major=-1, minor=-1, implicit=implicit@entry=true) at /home/alan/src/binutils-gdb/bfd/elfxx-riscv.c:1947
> > 1947 riscv_get_default_ext_version (*rps->isa_spec, subset,
> > (gdb) p rps->isa_spec
> > $1 = (const enum riscv_spec_class *) 0x0
> >
> > This was triggered when calling riscv_merge_attributes for crti.o
> > which had
> > (gdb) p ibfd->tdata.elf_obj_data->known_obj_attributes[OBJ_ATTR_PROC][Tag_RISCV_arch]
> > $5 = {type = 2, i = 0, s = 0x97e4c0 "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0"}
> >
> > Fix the segfault by reinstating a NULL check removed with commit
> > 413cf36d8e81
>
> Thanks for fixing this. What I'm puzzled by is that my testsuite runs didn't
> hit this case.
You'd need to have a riscv64-linux-gnu toolchain installed, with a
glibc that happened to be built with the triggering attribute. And
you'd have to notice a silent segfault (apart from a log message)
that disabled all riscv64-linux-gnu tests using the target compiler.
> Jan
>
> > --- a/bfd/elfxx-riscv.c
> > +++ b/bfd/elfxx-riscv.c
> > @@ -1942,8 +1942,9 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
> > int major_version = major;
> > int minor_version = minor;
> >
> > - if (major_version == RISCV_UNKNOWN_VERSION
> > + if ((major_version == RISCV_UNKNOWN_VERSION
> > || minor_version == RISCV_UNKNOWN_VERSION)
> > + && rps->isa_spec != NULL)
> > riscv_get_default_ext_version (*rps->isa_spec, subset,
> > &major_version, &minor_version);
> >
> >
--
Alan Modra
More information about the Binutils
mailing list