forked from capablevms/cheri-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setjmp.c
33 lines (29 loc) · 821 Bytes
/
setjmp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "include/common.h"
#include <cheri/cheric.h>
#include <setjmp.h>
#include <stdint.h>
#include <stdio.h>
int main()
{
jmp_buf buffer;
int res = setjmp(buffer);
uint32_t length = cheri_getlength(buffer);
// buffer[0] == _JB_MAGIC_SETJMP == 0xbe87fd8a2910af01
// buffer[1] == $csp
// buffer[2] == $cfp
// buffer[3..13] == $cs1..11
// buffer[14..31] = ???
for (uint32_t idx; idx < (length / 16); idx++)
{
if (cheri_gettag(((void **) buffer)[idx]))
{
void *csp = cheri_getcsp();
uint64_t address = cheri_getaddress(((void **) buffer)[idx]);
if (cheri_is_address_inbounds(csp, address))
{
printf("[STACK POINTER] ");
}
pp_cap(((void **) buffer)[idx]);
}
}
}