add cheri article
This commit is contained in:
22
articles/morello/code/Makefile
Normal file
22
articles/morello/code/Makefile
Normal 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
BIN
articles/morello/code/membug
Executable file
Binary file not shown.
5305
articles/morello/code/membug-cheri.asm
Normal file
5305
articles/morello/code/membug-cheri.asm
Normal file
File diff suppressed because it is too large
Load Diff
BIN
articles/morello/code/membug-cheribsd
Executable file
BIN
articles/morello/code/membug-cheribsd
Executable file
Binary file not shown.
13
articles/morello/code/membug.c
Normal file
13
articles/morello/code/membug.c
Normal 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;
|
||||
}
|
BIN
articles/morello/code/ptrs_as_numbers
Executable file
BIN
articles/morello/code/ptrs_as_numbers
Executable file
Binary file not shown.
BIN
articles/morello/code/ptrs_as_numbers-cheribsd
Executable file
BIN
articles/morello/code/ptrs_as_numbers-cheribsd
Executable file
Binary file not shown.
21
articles/morello/code/ptrs_as_numbers.c
Normal file
21
articles/morello/code/ptrs_as_numbers.c
Normal 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
BIN
articles/morello/code/sizes
Executable file
Binary file not shown.
BIN
articles/morello/code/sizes-cheribsd
Executable file
BIN
articles/morello/code/sizes-cheribsd
Executable file
Binary file not shown.
7
articles/morello/code/sizes.c
Normal file
7
articles/morello/code/sizes.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main () {
|
||||
printf("void *: %lu, size_t: %lu\n", sizeof(void *), sizeof(size_t));
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user