https://sourceware.org/bugzilla/show_bug.cgi?id=34181
Bug ID: 34181
Summary: [RISC-V ld] false truncated JAL at positive limit
after relax
Product: binutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: l784896635 at gmail dot com
Target Milestone: ---
During RISC-V linker regression/conformance testing, I reduced this
linker-stage issue.
## Actual behavior
riscv64-unknown-elf-ld 2.45 --relax rejects the legal link with relocation
truncated to fit: R_RISCV_JAL against baz, while ld.lld 21.1.3 links the same
object and keeps the final foo to baz call as auipc ra,0x100 plus jalr
ra,0x0(ra).
## Expected behavior
The linker should produce the semantically correct RISC-V output for this
reduced testcase, or issue a controlled diagnostic when the input is outside
the supported semantics. It should not silently emit a wrong output, lose
required metadata/relocations/attributes, miss a required relaxation, report a
false range/non-PIC/non-convergence error, or crash.
## Test input and intent
A fixed-layout image performs many short direct calls to a nearby helper bar,
then makes one final far call from foo to baz. The last call sits exactly at
the positive jal overflow boundary, so a correct linker must keep it as auipc
plus jalr instead of forcing a jal relaxation.
## Target and route
- Target tracker: GNU binutils / ld
- Target ISA / ABI: `rv64i` / `lp64`
- First failing stage: link
- Toolchain route used in reduction: gas+ld.bfd with ld.lld control
## Reproduction evidence
3 clean reproductions in packaged run1..run3 evidence show stable gas assembly
success, stable ld.bfd link-time failure at .text.a+0x400 with relocation
truncated to fit: R_RISCV_JAL against baz, and stable ld.lld success with final
disassembly keeping foo at 0x400 and baz at 0x100400 connected by auipc plus
jalr rather than jal.
The reproducer bundle contains the reduced testcase plus three local
reproduction runs. The evidence is text-only: linker outputs, disassembly,
relocation dumps, symbol dumps, and short summaries where available.
Reproducer bundle:
https://github.com/anonymous25989/riscv-linker-48-reproducers/raw/main/r48-v2/attachments/gnu_016_false_truncated_jal_at_positive_limit_after_relax_reproducer.zip
## Notes
This is reported as a linker-stage behavior defect found during RISC-V linker
regression/conformance testing. The reduced testcase is intentionally small so
that the failure mode is easy to inspect. The attached evidence is already
reproduced; no additional local path or private workspace is required.
--
You are receiving this mail because:
You are on the CC list for the bug.