<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/202146>202146</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V][lld] ld.lld emit relocs EH frame reloc offset unadjusted (before LLVM 15)
        </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 14.0.6 emits `.rela.eh_frame` with relocation offset `0x1013c`, four bytes before the FDE `initial_location` field in its own emitted `.eh_frame`, while 15.0.7 and later adjust the relocation to the correct `0x10140` field location.

### Expected behavior
Emit a final RV64 executable with `--emit-relocs` from a single CFI-bearing function.

### 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:

#### `case.s`
```asm
.text
.globl foo
.type foo, %function
foo:
.cfi_startproc
  addi a0, zero, 0
.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_emit_relocs_eh_frame_reloc_offset_unadjusted_before_15/run1..run3 show stable assembly success for case.o, stable 14.0.6 `relocs.14.txt` entries with relocation offset `0x1013C`, matching `ehframe.14.txt` where the FDE `initial_location` bytes start at `0x10140`, and stable 15.0.7/22.1.0 outputs whose relocation tables point at `0x10140`.

### Notes
LLVM 15.0.0 lld release notes and local RISC-V CFI reduction

Root key: `lld.riscv.emit_relocs_eh_frame_reloc_offset_unadjusted_before_15`
Case id: `20260527-lld-emit-relocs-eh-frame-offset-unadjusted`

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVk1v27oS_TXyZmBCom05WXiRJjEaoH2LJK_v7QyKHFlsKFLghx3311-QlOykN7kFLhA4EDmcOZyZc4bMObnXiJti9aVY3c1Y8J2xm_9LZhqp919NqGh1PWuMOG0ewDINUnsDvpMOjp1UCBZF4FLvgcHjw9Pt_AcoqV_QgkfnOXNI4LmLZoM1InC0IB24nilV0FtgWsADdOyA0CBqcIjRl-8QHOvjMReUB260k86j9uoEjFvjHPjOYjSwQTtSlHdFeTP-0kX-g6fQ98ye8rISRCkB1ZKUpAbspXdQ1CWxqBjBbtda1mNRl3CUvgOLynDmpdFg2tahj7bla1VWC17UZcTemmChOXl00GBrLCbY27v7aCq19JKp3eQlOm4lKgFSQwxtjjqB8CgSjDcIovOc3GpFSrJOWVLMowUmfgbnU6A3CFNFELixFvkF6bK8RJ1sP8nU_euAPEJpsGMHaWw2uO-lBwat1EzB4496CfiKPHjWKMx5KupyPo_3mCc8LkW0pgcGTuq9QrjdPswbZDbWtQ2a_xMKfZDW6B61z1vzqZmsCR6LxQ0odejnPQdKYVDBwVjVA1oXM2FxUOw0He6Z5V08ZQ_1Ul5WG5lcDfVyWmuldR5aJlWE6Tzb52hSv5yRGM5U3Gqkkv4EvEP-Eo2ebcCP7_MYuYHiTIW8_9yhQ2Bjv9jRRuoheGilQpcTGDd7qWUvf6F4y58HCA5zRZU6FYubD4PH-EVdJgbGqozbdZn_mOvzCvH4Omab7JVpFLTGTFunAdMnvYWCrqbq5d24PsUmvJU755n1gzU8rwEwISSw1M6_0CYv5Rt71OJifQb2WSbz9VO7a-PRTWV5jlI0MP7C9jFNxngQBl00yrpybkTOtNEyFrGoSxs0GVyV-G7ZMKAlk8f_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