Skip to content

Commit 0a9cacb

Browse files
committed
[CHERIoT] Make the captable read-only on CHERIoT.
1 parent 8b43c5e commit 0a9cacb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lld/ELF/Arch/Cheri.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ void CheriCapRelocsSection::addCapReloc(CheriCapRelocLocation loc,
341341
"\n>>> Target: " + target.verboseToString(ctx));
342342

343343
bool canWriteLoc = (loc.section->flags & SHF_WRITE) || !ctx.arg.zText;
344-
if (!canWriteLoc) {
344+
if (!canWriteLoc &&
345+
!(ctx.arg.isCheriot && loc.section->name == ".captable")) {
345346
readOnlyCapRelocsError(ctx, *target.sym(),
346347
"\n>>> referenced by " + sourceMsg());
347348
return;
@@ -595,7 +596,9 @@ void CheriCapRelocsSection::writeTo(uint8_t *buf) {
595596
CheriCapTableSection::CheriCapTableSection(Ctx &ctx)
596597
: SyntheticSection(
597598
ctx, ".captable", SHT_PROGBITS,
598-
SHF_ALLOC | SHF_WRITE, /* XXX: actually RELRO for BIND_NOW*/
599+
SHF_ALLOC | (ctx.arg.isCheriot
600+
? 0
601+
: SHF_WRITE), /* XXX: actually RELRO for BIND_NOW*/
599602
ctx.arg.capabilitySize) {
600603
assert(ctx.arg.capabilitySize > 0);
601604
this->entsize = ctx.arg.capabilitySize;

0 commit comments

Comments
 (0)