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

    <tr>
        <th>Summary</th>
        <td>
            Merge 8a31f7ddb8436fa2a8ad754eb51618139cf63415 into 17.0.X
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          brad0
      </td>
    </tr>
</table>

<pre>
    [lld][LoongArch] Support the R_LARCH_PCREL20_S2 relocation type

`R_LARCH_PCREL20_S2` is a new added relocation type in LoongArch ELF
psABI v2.10 [1] which is not corvered by D138135 except `R_LARCH_64_PCREL`.

A motivation to support `R_LARCH_PCREL20_S2` in lld is to build the
runtime of .NET core (a.k.a `CoreCLR`) in which strict PC-relative
semantics need to be guaranteed [2]. The normal `pcalau12i + addi.d`
approach doesn't work because the code will be copied to other places
with different "page" and offsets. To achieve this, we can use `pcaddi`
with explicit `R_LARCH_PCREL20_S2` reloc to address +-2MB PC-relative
range with 4-bytes aligned.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8k02vozYUhn-NszkKMgYTWLDIx41aKVON7txFd1cH-xDccWxkm2Tuv6-cpNNRR50NSICf93mPMcZozo6oZ3LH5GGFS5p86IeAmq8Grz_yC2s1kwcmdyfv3Xkb1MTkAb4s8-xDgjQRvL6ftq_7394_719fToK_fxEQyHqFyXgH6WMmxg-Mb5_Xhv-8gDUcTAQERzdArUn_FwHGwXcDeDkdH7Q5bne_w1UUJQcmd2V2u01GTRnnfALlw5UCaRg-4FBWbVlJoG-K5gQ_mDT1Q4Y1vPhRdgsXn8z1qeEhPmv_fwkH1uocnjwMi7E6j-gBC4tL5kLgRyj-eHnLagRMtFh8LTAj9z7Q_vTKGs5El1GPJjEFoxJ83q8DWUzm-uRFuqBLRkVwRPoeSHBeMKBL-QGTO8HkoYC3icD5cEGbU2aFFpdSGGBil4dtCp0j70yc5-BRTaA9RcfEJsHNh68wkMIl0n2_ldcEN2NtzlN-No9wnyYKMFtUFB-wm0kTaDOOFMglYELMeCYmBKDT4McxUooFvHlANRm6ZryJTOzhRqDQQU58GGttvjvesfRttkaZX2zF_QfKYqh1oBhz3bX4tPt5kAHdOTdKE9Tr4SNRBLT5ZOhipftKd1WHK-rLpiullGVXr6a-HbVua5I0YCVl07VDp1AooZUe2k3brkwvuKh4yztei6aqi1aONXZS8KpSG-SS1ZwuaGxh7fVS-HBemRgX6ptaSr6yOJCN_5zM0OeP1sNyjqzm1sQU_12WTLLUf6JwJmixKseN1kNbV82IAlvUG1nTIMumbMuqU2NT1aUE45KHclPw4s_VEmw_pTRHVm2ZODJxPJs0LUOh_IWJYw563tZz8H-RSkwc77KRiePd9-8AAAD__7ugWDc">