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

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V][lld] ld.lld shared local abs HI20 LO12 false PIC rejection
        </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 18.1.8 and 20.1.8 reject the legal shared-image input with relocation R_RISCV_HI20/LO12_I cannot be used against local symbol; recompile with -fPIC, while ld.lld 21.1.3 links the same object and emits the expected lui/addi sequence for abs=0x200001.

### Expected behavior
A shared RISC-V image materializes a linker-defined absolute address abs using the standard lui %hi(abs) / addi %lo(abs) sequence. That is a meaningful low-level pattern for fixed constants or linker-script-defined absolute addresses inside a shared image.

### Environment
- linker route: clang integrated assembler + ld.lld version replay
- march: rv64g
- 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
.globl abs
abs = 0x200001

.globl _start
_start:
  lui a0, %hi(abs)
  addi a0, a0, %lo(abs)
```

### 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_shared_abs_hi20_lo12_false_pic_rejection/run1..run3 show stable old-version link-time rejection with R_RISCV_HI20 and R_RISCV_LO12_I cannot be used against local symbol against the same case.o, and stable 21.1.3 success with final disassembly lui a0,0x200; addi a0,a0,0x1 from the same object and linker script.

### Notes
upstream///llvm-project/lld/test/ELF/riscv-relax-hi20-lo12-pie.s

Root key: `lld.riscv.shared_local_abs_hi20_lo12_false_pic_rejection`
Case id: `20260526-lld-shared-abs-hi20-lo12-false-pic-rejection`

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVl1v67gR_TXyy8CCTNmK8-CH3OQa18C2XeSm274ZlDiW2EuRKod0rvfXF0NJdrKboAsYhs2P-Thz5gwlkW4t4i7bfMk2TwsZQ-f87t9aulrb9puLK7G6X9ROXXYH8NKCtsFB6DTBa6cNgkcVG21bkPB8-P64_A2Mtj_QQ0AKjSTM4aXjY4N3KjboQRNQL43JxCNIq-AAnTwj1IgWCJFthQ6BZM_XKJoAjbOkKaAN5gKy8Y4IQueRD_hoKc-Kp6x4mL5FOX7ge-x76S_jslG5MQpW23yVb5NjUaSfHv-DTUg-DbbSAHXSo1rqXrYI2g4xwKsOHXg0rpFBOwvPR072t-O3gygysf_lHytxPEAjrXUBaoRIqEC2UlsKwLcM0KWvncnKL-Cxcf3A4CWzy9Ovh0cGYwR0ilOs8lVeJjDphoerU6wcPfY6jDv4c8AmoAITdSb2UikNhP-NaBuEk_Mga8rKp-KnKIqiWH0C1tfZSo2dPGvnxwMPExxzdUdUehnQa2n070ggp5IvFZ605cRrciYGBKmURyJegEjXygZplfQpXsjEptOZ2HKM4h4ysYeUQCY2xt3W53yYTTIwhyT0KK227SkaMO51afCMBgYZAnqb8j7pn6gSeYK0gcD5OVJqvB7CpwEjgbakFYKc0095fwadPWvvbI82jFvLuQm8iwGz8gEaI23LzYOtl4yyJMK-NughE1_mop_RE9PL42DkZbbVS990bMSfq3V7W601L5qhWs9rJ-0pwElqw1hTkG1yzsFcAxvJGGStjQ4XaDpsfvChFx_x4_SeucVRXTt63H_pkBCkx1RTP50Z2-WkDRKcvOvTZq-t7vXvqN7KwGFskhSPuWTlw4fO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