https://sourceware.org/bugzilla/show_bug.cgi?id=34234
Bug ID: 34234
Summary: [RISC-V] GNU ld.bfd atomic abi attribute ignored
Product: binutils
Version: 2.45
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: l784896635 at gmail dot com
Target Milestone: ---
I ran into this while reducing a RISC-V linker testcase. The reproducer is
already quite small, and I have been seeing the same result consistently across
three reruns.
Summary
=======
GNU ld.bfd 2.45 treats attribute tag 14 as unknown. It returns success for
incompatible A6C+A7 RV32/RV64 ET_EXEC/shared links with `unknown RISCV ABI
object attribute 14` warnings, and it emits empty `.riscv.attributes` output
for both invalid A6C+A7 links and legal A6C+A6S links. ld.lld 22.1.0 rejects
A6C+A7 with `atomic abi mismatch for .riscv.attributes` and preserves
`atomic_abi=1` for A6C+A6S.
Expected behavior
=================
Link RISC-V objects carrying standard psABI `Tag_RISCV_atomic_abi` values A6C,
A6S, and A7. The linker should reject incompatible A6C+A7 objects and should
preserve the merged A6C value for a compatible A6C+A6S link.
Environment
===========
- product: binutils
- component: ld
- toolchain route: llvm-mc 22 plus current GNU ld.bfd 2.45 with ld.lld 22.1.0
semantic control
- march: rv32 and rv64
- mabi: ELF32/ELF64 RISC-V default object ABI from llvm-mc
- first failing stage: link
Reduced testcase
================
--- a6c.s ---
.attribute atomic_abi, 1
.text
.globl _start
.type _start, @function
_start:
ret
.size _start, .-_start
--- a6s.s ---
.attribute atomic_abi, 2
.text
.globl a6s_func
.type a6s_func, @function
a6s_func:
ret
.size a6s_func, .-a6s_func
--- a7.s ---
.attribute atomic_abi, 3
.text
.globl a7_func
.type a7_func, @function
a7_func:
ret
.size a7_func, .-a7_func
Reproduction notes
==================
- This packaged root does not have a single canonical `run.ps1` wrapper.
- Use the reduced inputs under `case/` and follow the commands documented in
`case/README.md`.
- Stable witness outputs, when present, are preserved under
`verify/run1..run3/`.
What I checked
==============
- Reduced inputs are preserved under case/.
- Stable witness outputs are preserved under verify/run1..run3/.
- The strict recheck says stable normalized run signatures across three runs:
True.
- Tracker guidance link:
https://sourceware.org/binutils/docs/ld/Bug-Reporting.html
- evidence summary: 3 clean reproductions under
hunt/verify/bfd_riscv_atomic_abi_attribute_ignored/run1..run3 show stable
llvm-mc assembly success for A6C, A6S, and A7 objects, stable ld.lld RV32/RV64
ET_EXEC/shared rejection of incompatible A6C+A7, stable GNU ld.bfd RV32/RV64
ET_EXEC/shared wrong-success on the same incompatible pair, stable ld.lld
preservation of `atomic_abi=1` for compatible A6C+A6S outputs, and stable GNU
ld.bfd empty `BuildAttributes {}` for both invalid and valid merge outputs.
Stable object hashes across all runs are
`1c8665c15607de8540a1577f0d1777e6ab7c75739e8585b40d6acaa989ccd82f` for
`a6c.32.o`, `7c7c8cf062ec0192136c3ba70b766e3df3932a1be5d7b8e915164bd3634f445e`
for `a7.32.o`,
`1733b3a56ba9cd4c520991a54f5c814b5a12129f631195d87608977ad0e7b8b7` for
`a6s.32.o`, `8a393832802147ea816a5682a98dd355ca774d773b72aa17184ce44d020c8a2a`
for `a6c.64.o`,
`da9772948a5492a66bdf26ecefd062d1386d7e0b1e8bf9f2a32031a451015b35` for
`a7.64.o`, and
`846c6b0432136741598630ff149b7e1bd5d6cb35786be63d63c8692e9541f8ad` for
`a6s.64.o`; stable lld compatible-output hashes are
`1785bea44f5850cb89412b826b2604b46a4f5bb1f993d55afbb1c2a6468391e4`,
`d13208d2d0b3cbf3c9705da5bf06a6338b4b46eb8dee2d591146efaf85ce6e22`,
`60b021a59319072a1399f9ae3f0d74b7a27c220b328da597cb0b53d7729c61ce`, and
`58779492a76bc061f706c2480f1f8c53caa7750d505605e280fa2d6cd4ac6ff6`. GNU ld.bfd
output hashes are path-dependent, but the semantic evidence is stable. Local
`rg` over current binutils-gdb and the local binutils 2.45 build found no
`Tag_RISCV_atomic_abi` or `atomic_abi` implementation; the RISC-V attribute
enum stops at `Tag_RISCV_priv_spec_revision = 12`. Web searches covering
Sourceware Bugzilla, Sourceware binutils lists, GitHub, `Tag_RISCV_atomic_abi`,
and `unknown RISCV ABI object attribute 14` found LLVM/lld support references
but no direct current Sourceware bug report for GNU ld.bfd's missing tag 14
link semantics.
Notes
=====
upstream/llvm-project/lld/test/ELF/riscv-attributes.s is the LLVM/lld semantic
seed; local binutils source evidence is
`upstream/binutils-gdb-full/include/elf/riscv.h`,
`upstream/binutils-gdb-full/bfd`, `upstream/binutils-gdb-full/gas`, and
`build/binutils-2.45-riscv64-linux-gnu-ld`.
Root key: bfd.riscv.atomic_abi_attribute_ignored
Case id: 20260604-bfd-riscv-atomic-abi-attribute-ignored
--
You are receiving this mail because:
You are on the CC list for the bug.