Inital commit: Simple POC syscall working and displaying in dmesg with tester tool

This commit is contained in:
Jolan Rathelot
2024-11-19 17:24:09 +01:00
commit 80307195d4
5 changed files with 279 additions and 0 deletions

53
Makefile Normal file
View File

@@ -0,0 +1,53 @@
KDIR ?= /lib/modules/$(shell uname -r)/build
SRC = src/process-and-memory.c
TESTER_SRC = src/tester/main.c
KERNEL_OUT ?= $(KDIR)/System.map $(KDIR)/arch/x86/boot/bzImage $(KDIR)/.config
# Folders
SRC_DIR = src
OUTS = obj
SRC = tester/main.c
SRC_PLUS_PATH = $(addprefix $(SRC_DIR)/, $(SRC))
OUT = $(subst $(SRC_DIR)/, $(OUTS)/, $(patsubst %.c, %.o, $(SRC_PLUS_PATH)))
NAME = ps_tester
$(NAME): $(OUT) src/tester/main.c
@gcc $(OUT) -o $(NAME) -Wall -Wextra -Werror
$(OUT): $(OUTS)/%.o : $(SRC_DIR)/%.c
@echo "Compiling $(basename $(notdir $*.o))"
@mkdir -p $(@D)
@gcc -Wall -Werror -Wextra -g -c $< -o $@
clean:
@echo "Cleaning object files"
@rm -rf obj
fclean: clean
@echo "Cleaning binary"
@rm -rf ps_tester
re: fclean
@$(MAKE) -C $$PWD
patch_kernel:
compile_kernel: patch_kernel
$(MAKE) -C $(KDIR) LLVM=1 -j 6
mount_boot:
mount /dev/vda1
install_kernel: mount_boot compile_kernel
$(MAKE) -C $(KDIR) LLVM=1 modules_install
cp -iv $(KDIR)/System.map /boot/System.map-6.12.0-modded
cp -iv $(KDIR)/arch/x86/boot/bzImage /boot/vmlinuz-6.12.0-jrathelo-modded
cp -iv $(KDIR)/.config /boot/config-6.12.0-modded
grub-mkconfig -o /boot/grub/grub.cfg
install: install_kernel
reboot
.PHONY: install compile_kernel install_kernel patch_kernel mount_boot