https://sourceware.org/bugzilla/show_bug.cgi?id=34180
Bug ID: 34180
Summary: [RISC-V ld] emit rel ro output leaks internal relax
relocations
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 links successfully with --relax --emit-relocs but
writes GNU linker-internal RISC-V relaxation relocations into the final
executable: readelf -r shows unrecognized relocation types 43 and 44, and
objdump -dr names them R_RISCV_RVC_LUI and R_RISCV_GPREL_I in .rela.text.
## 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 tiny RV32IC program materializes the address of a nearby label with the
ordinary absolute lui/addi sequence. After layout, the high part becomes zero
and relaxation can legally shrink the first instruction to c.li while
preserving standard relocation semantics under --emit-relocs.
## Target and route
- Target tracker: GNU binutils / ld
- Target ISA / ABI: `rv32ic` / `ilp32`
- First failing stage: link
- Toolchain route used in reduction: gas + ld.bfd
## Reproduction evidence
3 clean reproductions in packaged run1..run3 evidence show stable assembly
success, stable link success, stable final code c.li x10,0 plus addi
x10,x0,2046, and stable emitted relocation leakage into the executable. This is
a link-stage output defect: the bad relocation records do not exist before
linking and appear only when ld.bfd emits final ELF relocations under
--emit-relocs.
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_015_emit_rel_ro_output_leaks_internal_relax_relocations_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.