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

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V][lld] ld.lld missing relro padding (before LLVM 18)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </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/15.0.7/16.0.6/17.0.6 omit the synthetic .relro_padding section entirely, while 18.1.8 and 22.1.0 insert it on the same legal input and layout flags.

### Expected behavior
Link a normal RV64 executable against a small shared library with -z separate-code, forcing ordinary RELRO layout decisions.

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

#### `lib.s`
```asm
.globl bar, weak
.type bar,@function
.type weak,@function
bar: weak:
```

#### `main.s`
```asm
.global _start, foo, bar
.weak weak
_start:
  call foo
  call bar
 call bar@plt
  call weak
foo:
  ret
```

### 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_missing_relro_padding_before_18/run1..run3 show stable assembly success for lib.o and main.o, stable 17 outputs whose out.17.readelf.txt have no .relro_padding section, and stable 18/22 outputs whose readelf files contain a NOBITS .relro_padding section between the RELRO region and .got.plt. The same before/after split was also observed earlier on the independent section-layout control.

### Notes
hunt//tmp//probe60_misc//plt and hunt//tmp//probe60_misc//section_layout

Root key: `lld.riscv.missing_relro_padding_before_18`
Case id: `20260527-lld-missing-relro-padding`

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVttu2zwSfhr5ZmBCkm3ZufCF08T4A6Qt4GS7exeMyJHEDUUKPNh1n35BHeykSLYFDEsi5_DNgd8QnZO1Jtomq9tkdTfD4Btjt_-RaEqp639MyPLsZlYacd4-gEUNUnsDvpEOTo1UBJZE4FLXgHB4ePoy_wFK6ley4Ml5jo4YPDdRrLNGBE4WpAPXolJJ_gVQC3iABo8EJZEGRxRt-YbAYRvVXFAeuNFOOk_aqzMgt8Y58I2lKGCDdixJ75J0N_7ni-EHT6Ft0Z6HZSWYUgKyJUtZkeT7bMVSto4vxbSyji9gWukHBGftG_KSA7OkrHnpUIgIzxH30mgg7aUldY6RDNnINixjmz6sPGcZS0FqR9aD9GD0NS5FNSqQugu-F1Z4NsFDpbD-LJj7nx1xTwJKavAojR0EHqV-BQRtbIsKDj-KJdBP4sFjqQiwRqmdBxxSDq5BSwKULC3aM5ykb2D-Cxx1aNHTnBtBMZrK2L6oxgqpo-Th_vHwfYIpiEsnzad5v9dHaY1uSfthaz41hTXBU7LYgVLHdt5yyHPoVHAwVudINhqO7aLwPCm3aHkTteyxWMrrail7U12xnNYqaZ2HCqXq6-SxHrxJ_XpBYjiquFVKJf0ZeEP8NQo920Afx3OIPU7i0tLD_nNDjgAt9WW1o8xQ00oqclBZ0_abrdSylb9IvD0HDxBcrEXEo87JYveh8-g_KVIlS-aSIh13i3T4oWuHFVYrUyoo0fbNSDjGy_y5o3E5WaZV0H3rvt3shT_YjUqL3bB9ATc5_n9YW5T6z2BRwYvzaP3QbyY-ostBInp9E8YoOcEAiDnrtd5-X9Svn8u0U_6d0NVoVL9atOT_JkY4jBXsGUAbT27qrOfIih3yV6xjpY3xIAy5KDRQHIKTulYEHLXRMvZhUqQ2aNa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