<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/202157>202157</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][lld] ld.lld rv64 dynamic r riscv 64 data relocations rejected
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
XiaobingHou1219
</td>
</tr>
</table>
<pre>
I ran into this while reducing a RISC-V linker testcase. The reproducer is small, and I have been seeing the same result consistently across three reruns.
### Summary
All locally tested ld.lld versions reject the legal `-shared`, `-pie`, and `-shared -Bsymbolic` links with blanket `R_RISCV_64 cannot be used ... recompile with -fPIC`, even though the official GNU ld RISC-V testsuite treats the same inputs as legal dynamic-relocation cases.
### Expected behavior
Link a legal RV64 dynamic image whose data contains addresses of a defined global symbol, a local symbol, link-time absolute symbols, and an undefined symbol.
### Environment
- linker route: GNU as plus ld.lld version replay with official GNU ld testsuite legality control
- march: rv64i
- mabi: lp64
- first failing stage: link
- local stability check: True
### Reduced testcase
These are the reduced input files from the minimized reproducer I used locally:
#### `case.s`
```asm
.macro DATA symbol
.quad \symbol
.endm
.globl addr_globl
addr_globl:
DATA addr_globl
addr_local:
DATA addr_local
.hidden abs_local
DATA abs
DATA abs_local
DATA undef
```
### 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://llvm.org/docs/HowToSubmitABug.html
- evidence summary: 3 clean reproductions under hunt/verify/lld_rv64_r_riscv_64_dynamic_data_reloc_rejected/run1..run3 show stable assembly success for case.o and stable link-time rejection on ld.lld 14.0.6, 15.0.7, 16.0.6, 18.1.8, 21.1.3, and 22.1.0 across the `pie`, `shared`, and `symbolic` modes. The official GNU ld testsuite files `data-reloc-rv64-pic.d`, `data-reloc-rv64-pie.d`, and `data-reloc-rv64-symbolic.d` classify the same RV64 inputs as legal and specify the expected `R_RISCV_64`/`R_RISCV_RELATIVE` outputs.
### Notes
upstream////binutils-gdb//ld//testsuite//ld-riscv-elf//data-reloc-rv64-pic.d; D:/search_ascii/upstream////binutils-gdb//ld//testsuite//ld-riscv-elf//data-reloc-rv64-pie.d; D:/search_ascii/upstream////binutils-gdb//ld//testsuite//ld-riscv-elf//data-reloc-rv64-symbolic.d
Root key: `lld.riscv.rv64_dynamic_r_riscv_64_data_relocations_rejected`
Case id: `20260527-lld-rv64-dynamic-r-riscv-64-data-relocs-rejected`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEV11v87oN_jXODRHDcRKnvchF-pGdAmcHQ9-ed7sLZIuJtcqSJ0rpsl8_ULKTtCfFroYDBK1NUSL1kA9JCyJ1MIjrbPmQLZ8mIvjWuvU_lLC1ModfbJiVs_tJbeVp_QJOGFDGW_CtIvholUZwKEOjzAEEvL78eJz-BK3MOzrwSL4RhDm8tazWOytDgw4UAXVC66x8BGEkvEArjgg1ogFC5LN8i0Ci420UtIfGGlLk0Xh9AtE4SwS-dcgKLhjKs-IpKzbD33KefvAjdJ1wpyTeaA3aNkLrU_QNJWiZay3hiI6UNQQO_4mNj9Y1HoSGrCqm1AqHMqsK9pcFvcLhjb2_qMD0gU5dbbVqsqqIMBB8KN9CrYV5R8-6rztG6eeuWkAjjLEeaoRAKCHPc3DY2K5nWOO-6f5vL4-DLTyiAd_acGijg3a_V40SGv7y2--g5Qg-34yC8gjeofB0gVKZPngCQcPd5MmITjVTh4yKV9YAh-s7LJ__3WPDoNXYiqOyLin8qsw7iOHI15_VYjwXVCcOCB-tJQQpvOAgeqEMgZDSIRES2D0IkLhXBiUctK2FhoRhhDfF60rCmE696hBETVYHj8MijeEQBoIZT0xr313IHJWzpkPj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