[llvm] [ELF/RISCV] Add definitions for XCHERIOT1 non-standard relocations on RISCV. (PR #172414)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 15 21:39:49 PST 2025
================
@@ -30,3 +30,9 @@ ELF_RISCV_NONSTANDARD_RELOC(QUALCOMM, R_RISCV_QC_E_CALL_PLT, 195)
// Andes Nonstandard Relocations
// Calculation: S + A - P (10-bit PC-relative branch offset)
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_BRANCH_10, 241)
+
+// CHERIoT Nonstandard Relocations
+ELF_RISCV_NONSTANDARD_RELOC(XCHERIOT1, R_RISCV_CHERIOT_COMPARTMENT_HI, 220)
----------------
lenary wrote:
Ok, well, I rather dropped the ball on this implementation-wise, didn't I.
Originally, I intended that we could have two vendors failing to coordinate and using the same name (hence the slightly more complex macros, but also why the nonstandard.def was a separate file with separate x-macro), but while we didn't have conflicting names, I evidently did the simplest possible implementation.
This is probably resolvable if conflicts arise, given that `RISCVAsmBackend::getFixupKind` has access to the subtarget, but I didn't add that complexity.
The numbers in `ELF.h` are used in `RISCVELFObjectWriter::getRelocType` (and the emission of the preceding vendor relocation is done based on the same fixup that method is called with, iirc), so it's not the end of the world if we lose them? They are also used in `lld/ELF/Arch/RISCVInternalRelocations.h`, but I think those can be refactored to use the x-macro in `_nonstandard.def`.
https://github.com/llvm/llvm-project/pull/172414
More information about the llvm-commits
mailing list