<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/202188>202188</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][lld] ld.lld gnu property no copy on protected dropped from output
</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
ld.lld links successfully but drops `.note.gnu.property` entirely from both executable and shared outputs when the only input GNU property is `GNU_PROPERTY_NO_COPY_ON_PROTECTED`. GNU ld.bfd preserves the same note in both output kinds, while plain controls without the input note remain note-free on both linkers.
### Expected behavior
Link valid RISC-V regular input objects that carry a `.note.gnu.property` entry for `GNU_PROPERTY_NO_COPY_ON_PROTECTED`. A correct final link should preserve that property in executable and shared outputs.
### Environment
- linker route: GNU as 2.45 input, current ld.lld 22.1.0 and GNU ld.bfd 2.45 final links, RV32/RV64 executables and shared objects built from a single regular input object carrying only the property note plus simple code; plain no-note controls show no spurious output note.
- march: rv32gc and rv64gc
- mabi: ilp32 and lp64
- first failing stage: link
- local stability check: True
### Reduced testcase
These are the reduced input files from the minimized reproducer I used locally:
#### `input_note_rv64.s`
```asm
.section ".note.gnu.property","a"
.balign 8
.4byte 4
.4byte note_end - note_desc
.4byte 5
.asciz "GNU"
note_desc:
.balign 8
.4byte 2
.4byte 0
.balign 8
note_end:
.text
.globl _start
.type _start,@function
_start:
ret
.globl foo
.type foo,@function
foo:
ret
```
#### `input_plain_rv64.s`
```asm
.text
.globl _start
.type _start,@function
_start:
ret
.globl foo
.type foo,@function
foo:
ret
```
### Reproduction notes
- Reproduction command from the packaged case directory:
`powershell -ExecutionPolicy Bypass -File ./case/run.ps1`
- The reduced inputs live under `case/` and the stable witness outputs live 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_riscv_gnu_property_no_copy_on_protected_dropped_from_output/run1..run3` are stable: each run reports 4 ld.lld rows as `wrong_drop_note`, 4 GNU ld.bfd rows as `ok_preserve_note`, and 8 plain controls as `ok_no_note`. Representative run1 RV64 `rv64_shared_note/out.bfd.notes.txt` shows `Properties: no copy on protected` and `out.bfd.sections.txt` contains a `.note.gnu.property` section, while the matching `out.lld.notes.txt` is empty and `out.lld.sections.txt` has no `.note.gnu.property` section at all. The canonical RV64 repro in `hunt/cases/confirmed/lld_riscv_gnu_property_no_copy_on_protected_dropped_from_output` reproduces the same executable and shared-object note drop with `run.ps1`, along with a plain no-note ld.lld control. Local lld tests cover PT_GNU_PROPERTY generation and target-specific RISC-V property-note output, but local and web searches found no direct current LLVM issue or test covering `GNU_PROPERTY_NO_COPY_ON_PROTECTED` passthrough on RISC-V final links.
### Notes
upstream/binutils-gdb-full/include/elf/common.h`. Local lld test `upstream/llvm-project/lld/test/ELF/pt-gnu-property.s` asserts that final links emit a `.note.gnu.property`/`PT_GNU_PROPERTY` view when a GNU property note is present, and `gnu-property-align.s` plus `gnu-property-align-32.s` cover final output section layout for GNU property notes. Local RISC-V lld tests `upstream/llvm-project/lld/test/ELF/riscv-feature-zicfiss.s`, `riscv-feature-zicfilp-unlabeled.s`, and `riscv-feature-zicfilp-func-sig.s` show current lld does preserve and synthesize target-specific RISC-V property notes. By contrast, the current probe shows property type 2 being dropped entirely from RISC-V final outputs, and web searches across LLVM GitHub issues/PRs did not find a direct current report for that behavior.
Root key: `lld.riscv.gnu_property_no_copy_on_protected_dropped_from_output`
Case id: `20260605-lld-riscv-gnu-property-no-copy-on-protected-dropped-from-output`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUWElv3DzS_jXypSBBV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