Skip to content

Commit cb7b6d2

Browse files
committed
[CHERIoT] ELF/Writer: fix import entry perm mask
The loader reserves 8, not 4, bits for permission flags; the linker should agree.
1 parent 5d99e3d commit cb7b6d2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lld/ELF/Writer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3196,7 +3196,13 @@ class CompartmentReportWriter {
31963196
imports.push_back(json::Object{
31973197
{"kind", "MMIO"},
31983198
{"start", entry.start},
3199-
{"length", entry.length & 0xfffffff},
3199+
/*
3200+
* Length and permissions are bit-stuffed into the same 32-bit
3201+
* word, with the top 8 bits reserved for permission flags and
3202+
* the bottom 24 for length. See CHERIoT-RTOS's
3203+
* sdk/core/loader/types.h ReservedPermissionsMask
3204+
*/
3205+
{"length", entry.length & 0x00ffffff},
32003206
{"permits_load", (entry.length & ImportPermitsLoad) != 0},
32013207
{"permits_store", (entry.length & ImportPermitsStore) != 0},
32023208
{"permits_load_store_capabilities",

0 commit comments

Comments
 (0)