Skip to content

Commit 46ef828

Browse files
qwattashveselypeta
authored andcommitted
[CHERI-RISC-V] Handle __CHERI_CAP_PERMISSION* changes in cheri_init_globals.h
This sets the correct CHERI-RISC-V standard permission bits for relocations.
1 parent f2613d0 commit 46ef828

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

clang/lib/Headers/cheri_init_globals.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ struct capreloc {
4949
};
5050
static const __SIZE_TYPE__ function_reloc_flag = (__SIZE_TYPE__)1
5151
<< (__SIZE_WIDTH__ - 1);
52+
static const __SIZE_TYPE__ constant_reloc_flag = (__SIZE_TYPE__)1
53+
<< (__SIZE_WIDTH__ - 2);
54+
#ifdef __riscv_xcheri
5255
static const __SIZE_TYPE__ function_pointer_permissions_mask =
5356
~(__SIZE_TYPE__)(__CHERI_CAP_PERMISSION_PERMIT_SEAL__ |
5457
__CHERI_CAP_PERMISSION_PERMIT_STORE_CAPABILITY__ |
5558
__CHERI_CAP_PERMISSION_PERMIT_STORE__);
56-
static const __SIZE_TYPE__ constant_reloc_flag = (__SIZE_TYPE__)1
57-
<< (__SIZE_WIDTH__ - 2);
5859
static const __SIZE_TYPE__ constant_pointer_permissions_mask =
5960
~(__SIZE_TYPE__)(__CHERI_CAP_PERMISSION_PERMIT_SEAL__ |
6061
__CHERI_CAP_PERMISSION_PERMIT_STORE_CAPABILITY__ |
@@ -64,6 +65,18 @@ static const __SIZE_TYPE__ constant_pointer_permissions_mask =
6465
static const __SIZE_TYPE__ global_pointer_permissions_mask =
6566
~(__SIZE_TYPE__)(__CHERI_CAP_PERMISSION_PERMIT_SEAL__ |
6667
__CHERI_CAP_PERMISSION_PERMIT_EXECUTE__);
68+
#else
69+
static const __SIZE_TYPE__ function_pointer_permissions_mask =
70+
~(__SIZE_TYPE__)(__CHERI_CAP_PERMISSION_WRITE__);
71+
static const __SIZE_TYPE__ constant_pointer_permissions_mask =
72+
~(__SIZE_TYPE__)(__CHERI_CAP_PERMISSION_WRITE__ |
73+
#ifdef __riscv_zcherilevels
74+
__CHERI_CAP_PERMISSION_STORE_LEVEL__ |
75+
#endif
76+
__CHERI_CAP_PERMISSION_EXECUTE__);
77+
static const __SIZE_TYPE__ global_pointer_permissions_mask =
78+
~(__SIZE_TYPE__)(__CHERI_CAP_PERMISSION_EXECUTE__);
79+
#endif
6780

6881
__attribute__((weak)) extern struct capreloc __start___cap_relocs;
6982
__attribute__((weak)) extern struct capreloc __stop___cap_relocs;

0 commit comments

Comments
 (0)