https://sourceware.org/bugzilla/show_bug.cgi?id=34215
Bug ID: 34215
Summary: [RISC-V] GNU ld.bfd intra section boundary misses cj
relax
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 leaves the final tail call as a 32-bit jal zero even though the
resolved displacement is 0x7fe, which is inside the c.j range, while ld.lld
emits c.j on the same object.
Expected behavior
=================
A same-section tail call sits exactly near the c.j boundary and should use the
16-bit compressed form once the exact post-relax displacement is known.
Environment
===========
- product: binutils
- component: ld
- toolchain route: gas+ld.bfd with gas+ld.lld control
- march: rv64imac
- mabi: lp64
- first failing stage: link
Reduced testcase
================
--- a.s ---
.global _start
_start:
call _start
call _start
a:
ret
b:
.space 2048
## Relaxed to jal. If we don't compute the precise value of a, we may consider
## a reachable by c.j.
tail a
## Relaxed to jal. c.j is unreachable.
tail c # c.j
## Relaxed to c.j. If we don't compute the precise value of c, we may consider
## c.j unreachable.
tail c # c.j
.space 2042
c:
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_call_intra_sec_boundary/run1..run3 show stable ld.bfd output at
0x10812: jal zero, 0x11010 /<c/>; the ld.lld control on the same a.o emits c.j
to c instead.
Notes
=====
upstream///llvm-project/lld/test/ELF/riscv-relax-call-intra-sec.s
Root key: bfd.riscv.intra_section_boundary_misses_cj_relax
Case id: 20260525-bfd-call-intra-sec-boundary
--
You are receiving this mail because:
You are on the CC list for the bug.