binutils Newspaper
JULY 29, 2026
risc-v Proposed

RISC-V: Check for conflicting extensions when linker merges arch attributes

Ethan Liang proposes a two-part patch series to fix memory leaks and add checks for conflicting RISC-V extensions during linker arch attribute merges.

Ethan Y. C. Liang introduces a two-patch series to address issues in the RISC-V linker’s handling of architecture attributes. The first patch cleans up memory leaks in error paths of riscv_merge_arch_attr_info. The second patch implements a crucial check: after merging input architecture strings, it re-evaluates the implicit extensions and verifies for conflicts, preventing silent failures like merging ‘rv32ic’ with ‘rv32id_zcmp’ which implies ‘zcd’ that conflicts with ‘zcmp’. The series also includes new test cases.

In the Thread 2 participants
  1. "Ethan Y. C. Liang" <ycl669@andestech.com> proposer

    Submits a two-patch series to fix memory leaks and add conflict checking for RISC-V architecture attributes during linking.

    “Patch 1 is preparatory: riscv_merge_arch_attr_info leaked the subset lists on its error paths, and the new error path added by patch 2 would make this worse, so route all error paths through a single cleanup exit first. Patch 2 adds the check: after merging the input archs, re-derive the implicit extensions on the merged arch and run the conflict checks on it, rejecting the merge if any conflict…”
  2. Nelson Chu <nelson.chu@sifive.com> reviewer

    Approves the first patch, noting that it looks okay.

In Details

This series introduces two changes to bfd/elfxx-riscv.c. Patch 1 fixes memory leaks in riscv_merge_arch_attr_info by ensuring subset lists are cleaned up on all error paths. Patch 2 adds a new check within the same function: after merging RISC-V ISA strings from multiple object files, it re-parses the merged string to detect and reject conflicting implicit extensions, a behavior previously not enforced by the linker.

For Context
arch attributes
Attributes that specify the processor architecture and supported instruction set extensions, such as Tag_RISCV_arch in ELF files.
linker
A program that combines object files and libraries into an executable. In this context, it's ld within binutils.
RISC-V ISA string
A string defining the RISC-V instruction set extensions, e.g., 'rv32ic' or 'rv64imafdc_zifencei'.
implicit extensions
Instruction set extensions that are implied by the presence of other extensions (e.g., 'zcd' might be implied by 'c' and 'd' extensions).
error paths
Branches of code execution that handle erroneous conditions or failures.
subset lists
Data structures used to manage parsed RISC-V ISA extensions.

Part of a Series

Filed Under: risc-vlinkerarchitecturememory leakconflict detection