[PATCH] RISC-V: Check if the merged ISA string is conflicting

Jeffrey Law jeffrey.law@oss.qualcomm.com
Mon Jun 29 19:15:52 GMT 2026



On 1/12/2025 11:29 PM, Yu-Cheng Liang wrote:
> In the current implementation, the linker does not check if the merged
> ISA string is conflicting when attempting to merge two ISA strings.
> For instance, no error message is generated when the linker links
> objectA (rv64i_zfinx) with objectB (rv64if).
>
> Signed-off-by: Yu-Cheng Liang <yclwlcy@gmail.com>
> ---
>   bfd/elfnn-riscv.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
> index 3aba9c85b0f..0b8c7c33117 100644
> --- a/bfd/elfnn-riscv.c
> +++ b/bfd/elfnn-riscv.c
> @@ -3965,6 +3965,14 @@ riscv_merge_arch_attr_info (bfd *ibfd, char
> *in_arch, char *out_arch)
>
>     merged_arch_str = riscv_arch_str (ARCH_SIZE, &merged_subsets);
>
> +  /* Check if the merged ISA string is conflicting.  */
> +  riscv_subset_list_t subsets = {NULL, NULL, NULL};
> +  unsigned xlen;
> +  riscv_parse_subset_t riscv_rps_merged =
> +    {&subsets, _bfd_error_handler, &xlen, NULL, false};
> +  if (!riscv_parse_subset (&riscv_rps_merged, merged_arch_str))
> +    return NULL;
> +
>     /* Release the subset lists.  */
>     riscv_release_subset_list (&in_subsets);
>     riscv_release_subset_list (&out_subsets);
So this code was recently moved into elfxx-riscv.c.

The patch applies cleanly over in that context and Kito already gave 
approval around multilib questions that I think Nelson raised.

The question I have is don't we possibly leak memory for various objects 
allocated by riscv_parse_subset and its children and stored into the 
subsets and perhaps other fields of riscv_rps_merged?

Jeff



More information about the Binutils mailing list