<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/202145>202145</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][lld] ld.lld EH frame FDE encoding wrong (before LLVM 16)
</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 15.0.7 emits malformed `.eh_frame` output with an extra trailing zero CIE and wrong FDE header bytes, producing `.eh_frame` sizes `0x34/0xb4` where 16.0.6 and 22.1.0 produce the expected `0x2c/0xac` layouts on the same legal inputs.
### Expected behavior
Link a tiny RV64 function with normal CFI data under linker scripts that place `.eh_frame` at zero and at a non-zero offset.
### Environment
- linker route: llvm-mc 22 plus ld.lld version replay
- 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:
#### `a.s`
```asm
.section .text.01, "ax",%progbits
.global f1
.type f1, %function
f1:
.cfi_startproc
.space 4
.cfi_endproc
```
### 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_eh_frame_fde_encoding_wrong_before_16/run1..run3 show stable assembly success for a.o; stable 15.0.7 nonzero.15.readelf.txt and zero.15.readelf.txt with `__eh_frame_end` at `0xbc/0x34` and an extra zero-length CIE tail; and stable 16.0.6/22.1.0 readelf outputs with `__eh_frame_end` at `0xb4/0x2c` and the compact expected CIE+FDE layout.
### Notes
upstream////llvm-project//lld//test//ELF//eh-frame-nonzero-offset-riscv.s
Root key: `lld.riscv.eh_frame_fde_encoding_wrong_before_16`
Case id: `20260527-lld-eh-frame-fde-encoding-wrong`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVktv4zgS_jXypWBBpix1cvAhL6MD9Owhne3dm1EiSxI3FCnw4dj96xekJLt7JsEMEAQWWY-vHl8V0TnZaaJdVt1n1eMKg--N3f1Xommk7r6asGGb21VjxHn3DBY1SO0N-F46eO-lIrAkApe6A4SX5-8P6x-gpH4jC56c5-goh9c-io3WiMDJgnTgBlQqYw-AWsAz9HgkaIg0OKJoy_cEDoeo5oLywI120nnSXp0BuTXOge8tRQEbtMuz4jEr7ub_rJz-4HsYBrTn6ViJXCkBmyov8i9Ag_QOBlStsQMJyOoip_7QWhwoqwswwY_Bw7v0PaAGOnmL4C1KFfH9JGvg4fkp4X-3Rnewf3yCnlCQhebsycXoppCjwp_NO_mTXDwtTuU2Y_vi1Gzj-XtPlmBT50VeJ-OM5Zu8mC1RSgydRuJ-wlycGE_qyKO6wrMJ3oHR1xQq6lCB1GPwn-XpabHYUI9Haewk8E3qN0DwUp_h5Ue9hTZo7qXRU1q0sQMqeNg_g0CPEHQMfq6-41aOPlYJPYwKOf0lB-inPMYw0QOCNnqdTkzbOvKfgdVHaY0eSPvpar34tCZ4yso7UOo4rAcOjMGogoO59EeyLqK3NCo8L8oDWt5HLXust_J62shkaqy3y1krrfPQzj3gPHaTN6nfLkgMRxWvGqmkPwPvib9FoVcb6ON4XiKBSFz4Mt2_9uQI0E4lt7NMqiK0UpGD1pohXQ5Sy0H-JPEryZ4hOBITHnXOyrsPnUf_WV1g7rK6mO_qYvpDN0wnuaOp6rmnk8-LTWztjDE8ZYxl7CFj1WhN10jvZoVOmQYVtJv5259Hil9Jr1q6aLpsNxdwOW_lwXm0frSGL87H2DvbXyRIi-v9Be5nyZ0ykvB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