[lld] [LLD][RISCV] Error on PCREL_LO referencing other Section (PR #107558)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 02:02:52 PDT 2024


================
@@ -671,6 +671,15 @@ void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
       errorOrWarn(sec.getLocation(rel.offset) +
                   ": R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128");
       return;
+    case R_RISCV_PC_INDIRECT:
----------------
lenary wrote:

https://github.com/llvm/llvm-project/pull/107558#issuecomment-2333777946:

> The function which does the other validation of `PCREL_LO` relocations is `getRISCVPCRelHi20` - but it, and where it is called from (`InputSectionBase::getRelocTargetVA`) do not have access to the input section, for comparison with the section of the symbol referenced by the relocation. Changing this seems quite an invasive change (likely needing to make `getRelocTargetVA` non-static, changing quite a few call sites).

If you want me to make this change, I'm happy to, but this was the reason I haven't so far.

https://github.com/llvm/llvm-project/pull/107558


More information about the llvm-commits mailing list