@@ -39,6 +39,7 @@ extern "C" {
39
39
#define CHERI_INIT_GLOBALS_VERSION 5
40
40
#define CHERI_INIT_GLOBALS_NUM_ARGS 7
41
41
#define CHERI_INIT_GLOBALS_SUPPORTS_CONSTANT_FLAG 1
42
+ #define CHERI_INIT_GLOBALS_SUPPORTS_INDIRECT_FLAG 1
42
43
43
44
struct capreloc {
44
45
__SIZE_TYPE__ capability_location ;
@@ -64,6 +65,8 @@ static const __SIZE_TYPE__ constant_pointer_permissions_mask =
64
65
static const __SIZE_TYPE__ global_pointer_permissions_mask =
65
66
~(__SIZE_TYPE__ )(__CHERI_CAP_PERMISSION_PERMIT_SEAL__ |
66
67
__CHERI_CAP_PERMISSION_PERMIT_EXECUTE__ );
68
+ static const __SIZE_TYPE__ indirect_reloc_flag = (__SIZE_TYPE__ )1
69
+ << (__SIZE_WIDTH__ - 3 );
67
70
68
71
__attribute__((weak )) extern struct capreloc __start___cap_relocs [];
69
72
__attribute__((weak )) extern struct capreloc __stop___cap_relocs [];
@@ -171,6 +174,18 @@ cheri_init_globals_impl(const struct capreloc *start_relocs,
171
174
data_cap , reloc -> capability_location + base_addr );
172
175
const void * __capability base_cap ;
173
176
bool can_set_bounds = true;
177
+ if (reloc -> permissions == (function_reloc_flag | indirect_reloc_flag )) {
178
+ /*
179
+ * IRELATIVE-like caprelocs require deferred processing, with a
180
+ * target-specific set of parameters. Trap if the caller doesn't
181
+ * support that, as we can't do anything here, otherwise skip.
182
+ */
183
+ #ifdef CHERI_INIT_GLOBALS_ALLOW_IFUNCS
184
+ continue ;
185
+ #else
186
+ __builtin_trap ();
187
+ #endif
188
+ }
174
189
if (reloc -> permissions == function_reloc_flag ) {
175
190
base_cap = code_cap ; /* code pointer */
176
191
/* Do not set tight bounds for functions (unless we are in the plt ABI) */
0 commit comments