From 2f1eef9e15005d5f0106942bf31d176ae6a813d1 Mon Sep 17 00:00:00 2001 From: xamidev Date: Sun, 29 Mar 2026 09:38:24 +0200 Subject: [PATCH] UBSan conditional compilation --- Makefile | 11 ++++++++++- README.md | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aa7b486..07bf3e1 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,21 @@ BUILDDIR := build ELFFILE := pepperk SRC := src + +CC_PROBLEMATIC_FLAGS:=-Wno-unused-parameter -Wno-unused-variable + +ifeq ($(UBSAN),true) SOURCES := $(shell find src -name '*.c') +CC_PROBLEMATIC_FLAGS:= -fsanitize=undefined +else +SOURCES := $(shell find src -name '*.c') +SOURCES := $(filter-out src/security/ubsan.c, $(SOURCES)) +endif + OBJFILES := $(patsubst $(SRC)/%.c, $(BUILDDIR)/%.o, $(SOURCES)) CC := x86_64-elf-gcc CC_FLAGS=-Wall -Wextra -std=gnu99 -nostdlib -ffreestanding -fstack-protector -fno-omit-frame-pointer -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -mcmodel=kernel -CC_PROBLEMATIC_FLAGS=-Wno-unused-parameter -Wno-unused-variable -fsanitize=undefined LD := x86_64-elf-ld diff --git a/README.md b/README.md index 59ea9cb..33254bb 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,20 @@ Compile the kernel and generate an ISO image like described above, then burn the sudo dd if=pepper.iso of=/dev/sdX ``` +## Compilation options + +By default, PepperOS is compiled without the following features: + +``` +UBSAN - undefined behavior sanitization +``` + +These features can be activated by setting them to "true" at the end of the make command, for example: + +``` +make UBSAN=true +``` + ## TODO The basics that I'm targeting are: