Skip to content

Commit eb99bc0

Browse files
committed
[CHERIoT] Fix a crash regression in R_RISCV_CHERIOT_CCALL handling.
Add a testcase to make sure we don't regress it again.
1 parent 2b6c51c commit eb99bc0

File tree

3 files changed

+1079
-8
lines changed

3 files changed

+1079
-8
lines changed

lld/ELF/Arch/RISCV.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,18 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
495495
int64_t hi = SignExtend64(val + 0x800, bits) >> 12;
496496
checkInt(ctx, loc, hi, 20, rel);
497497
if (isInt<20>(hi)) {
498-
relocateNoSym(loc,
499-
ctx.arg.isCheriot ? R_RISCV_CHERIOT_COMPARTMENT_HI
500-
: R_RISCV_PCREL_HI20,
501-
val);
502-
relocateNoSym(loc + 4,
503-
ctx.arg.isCheriot ? R_RISCV_CHERIOT_COMPARTMENT_LO_I
504-
: R_RISCV_PCREL_LO12_I,
505-
val);
498+
relocate(loc,
499+
Relocation{R_NONE,
500+
ctx.arg.isCheriot ? R_RISCV_CHERIOT_COMPARTMENT_HI
501+
: R_RISCV_PCREL_HI20,
502+
0, 0, rel.sym},
503+
val);
504+
relocate(loc + 4,
505+
Relocation{R_NONE,
506+
ctx.arg.isCheriot ? R_RISCV_CHERIOT_COMPARTMENT_LO_I
507+
: R_RISCV_PCREL_LO12_I,
508+
0, 0, rel.sym},
509+
val);
506510
}
507511
return;
508512
}

0 commit comments

Comments
 (0)