https://sourceware.org/bugzilla/show_bug.cgi?id=34173

            Bug ID: 34173
           Summary: [RISC-V ld] call relax skipped across output sections
           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

GNU ld.bfd preserves auipc+jalr for an in-range R_RISCV_CALL_PLT +
R_RISCV_RELAX relocation when the callee is placed in a different output
section, while ld.lld relaxes the same legal input to jal.

## 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 startup stub calls a helper in another output section at
0x110000 from a call site at 0x10004, which is within the legal RV64 JAL range
and should be relaxable under --relax.

## Target and route

- Target tracker: GNU binutils / ld
- Target ISA / ABI: `rv64im` / `lp64`
- First failing stage: link
- Toolchain route used in reduction: gas+ld.bfd with gas+ld.lld control

## Reproduction evidence

main.o contains R_RISCV_CALL_PLT and R_RISCV_RELAX at offset 0x4; helper at
0x110000 is 0xFFFFC bytes from the call site at 0x10004, which is within JAL
range; 3 clean reproductions in packaged run1..run3 evidence show stable ld.bfd
auipc+jalr vs ld.lld jal behavior.

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_002_call_relax_skipped_across_output_sections_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.

Reply via email to