Possible need for CRelocate (CREL? CRLC? CRELOC?)
Opened this issue · 0 comments
One area that is currently awkward is handling the CHERI equivalent of R_RISCV_RELATIVE relocations. On non-CHERI that means adding the library load base address to the integer pointers in question. On CHERI we need to build a full capability with both base and address increased by the library load base address. It is believed that a sensible scheme to make this work is to have the run-time linker emit the raw (without tag) bits of the capability as if the library were linked at address 0, mirroring how addresses are already handled for non-CHERI, and adding a new CRelocate instruction in order to "slide" up the address and bounds together before a CBuildCap (CBLD). See CTSRD-CHERI/sail-cheri-riscv#62 for a proposed implementation against the old capability format. Currently we instead have a rather inefficient __cap_relocs
table which requires manual capability derivation. Morello packs this data down, but cannot represent all possible bounds combinations as a result (in particular, whole-address-space capabilities), and still requires the same manual derivation code once the fields are extracted out.