diff --git a/Makefile b/Makefile index 1ebe675..6af38e5 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,9 @@ CPPFLAGS = -MMD AS=nasm ASFLAGS += -f elf32 LDFLAGS += -m elf_i386 -CFLAGS += -m32 -pipe -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector -fno-tree-vectorize -D__KERNEL__ +CFLAGS += -m32 -pipe -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-tree-vectorize -D__KERNEL__ -fstack-protector-all -mstack-protector-guard=global #keep .i and .s -#CFLAGS += -save-temps +#CFLAGS += -save-temps -fverbose-asm #CFLAGS += -fanalyzer -Wno-analyzer-malloc-leak -Wno-analyzer-out-of-bounds CXXFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie DEBUG_FLAGS += -g -Og -DDEBUG -fno-omit-frame-pointer -fno-inline diff --git a/core/assert.h b/core/assert.h index 5bafdd8..d42c602 100644 --- a/core/assert.h +++ b/core/assert.h @@ -22,3 +22,14 @@ } \ } \ } while (0) + +#define panic(fmt, args...) \ + do { \ + asm volatile("cli"); \ + printf("PANIC at %s:%d\n " fmt "", __FILE__, __LINE__); \ + printf("PANIC: " fmt "\n", ##args); \ + printStackTrace(3); \ + while (1) \ + asm volatile("hlt"); \ + __builtin_unreachable(); \ + } while (0)