https://sourceware.org/bugzilla/show_bug.cgi?id=34219
Bug ID: 34219
Summary: [RISC-V] GNU ld.bfd missing second pass relax to cjal
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 leaves the critical call as a 32-bit jal ra even though the
final resolved displacement is within c.jal range; ld.lld on the same object
emits c.jal for the critical call.
Expected behavior
=================
A sequence of RV32C calls shrinks in the first pass from auipc+jalr to jal.
That shrink should bring one critical call within c.jal range, so the linker
should run a second compression pass and emit c.jal for the critical call.
Environment
===========
- product: binutils
- component: ld
- toolchain route: gas+ld.bfd with gas+ld.lld control
- march: rv32imac
- mabi: ilp32
- first failing stage: link
Reduced testcase
================
--- jal_to_cjal.s ---
.text
.globl _start
_start:
call f1
call f2
call f3
call f4
call f5
call f6
call f7
call f8
call f9
call f10
critical:
call target
.option norvc
.rept 505
nop
.endr
.option rvc
f1: ret
f2: ret
f3: ret
f4: ret
f5: ret
f6: ret
f7: ret
f8: ret
f9: ret
f10: ret
target:
ret
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_second_pass_cjal_relax/run1..run3 show stable ld.bfd critical
output jal ra,target and stable ld.lld control output c.jal target from the
same jal_to_cjal.o object.
Notes
=====
upstream///binutils-gdb/ld/testsuite/ld-riscv-elf/jal-to-cjal.s
Root key: bfd.riscv.missing_second_pass_relax_to_cjal
Case id: 20260525-bfd-second-pass-cjal
--
You are receiving this mail because:
You are on the CC list for the bug.