Skip to content

Commit 39d3b70

Browse files
committed
Fix large immediate displacements for AUICGP / AUIPCC.
This is the same displacement check as used elsewhere, but I'm not sure that it's actually right. The previous one was nonsense because it was ignoring the shift.
1 parent b50aa39 commit 39d3b70

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lld/ELF/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
699699
warn("R_RISCV_CHERIOT_COMPARTMENT_HI relocation applied to instruction "
700700
"with unexpected opcode " +
701701
Twine(existingOpcode));
702-
checkInt(loc, val, 20, rel);
702+
checkInt(loc, SignExtend64(val + 0x800, bits) >> 12, 20, rel);
703703
// Preserve the target register. We will rewrite the opcode (source
704704
// register) to either AUICGP or AUIPCC and set the immediate field.
705705
uint32_t insn = read32le(loc) & 0x00000f80;

0 commit comments

Comments
 (0)