add cheri article

This commit is contained in:
2022-11-19 11:56:01 +00:00
parent 1445574e2d
commit e3c7e0e862
15 changed files with 6406 additions and 15 deletions

View File

@ -0,0 +1,22 @@
CFLAGS += -Wall -g -fno-stack-protector
CC ?= clang
PURECAP_CC ?= ~/cheri/output/sdk/utils/cheribsd-riscv64-purecap-clang
SOURCES := $(wildcard *.c)
OBJECTS := $(patsubst %.c, %, $(SOURCES))
OBJECTS_CHERIBSD := $(patsubst %.c, %-cheribsd, $(SOURCES))
all: all-host all-cheribsd
all-host: $(OBJECTS)
all-cheribsd: $(OBJECTS_CHERIBSD)
%: %.c
$(CC) $< $(CFLAGS) -o $@
%-cheribsd: %.c
$(PURECAP_CC) $< $(CFLAGS) -o $@
clean:
rm $(OBJECTS) $(OBJECTS_CHERIBSD)

BIN
articles/morello/code/membug Executable file

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,13 @@
#include <stdio.h>
int main() {
char my_perfect_string[] = "what a beautiful string"; // so beautiful, I sure hope no-one touches it
char user_name[32];
printf("enter your name: ");
fgets(user_name, 1000, stdin); // get user's name from stdin
printf("hello %s", user_name);
printf("my_perfect_string: %s\n", my_perfect_string);
return 0;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,21 @@
#include <stdio.h>
int main() {
int magic = 9999;
(void)magic;
int arr[] = { 1234, 5678 };
int *x = &(arr[0]); // x is a pointer to first element of arr
printf("*x=%d\n", *x);
unsigned long x_addr = (size_t) x; // we're going to assume size_t = unsigned long here
x_addr += 4; // sizeof(int) == 4
x = (int *) x_addr;
printf("*x=%d\n", *x);
x_addr += 4;
x = (int *) x_addr;
printf("*x=%d\n", *x);
return 0;
}

BIN
articles/morello/code/sizes Executable file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main () {
printf("void *: %lu, size_t: %lu\n", sizeof(void *), sizeof(size_t));
return 0;
}