From 55ac8fa5b3d0bc1f7baef122bd855d99f2ddc1a6 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 5 Dec 2024 22:32:40 -0700 Subject: [PATCH] [kernel] Change heap and stack overflow kernel error messages, cleanup --- elks/arch/i86/kernel/process.c | 4 ++-- elks/arch/i86/mm/malloc.c | 4 ++-- elks/tools/.gitignore | 1 + elks/tools/objtools/Makefile | 7 +++++-- elks/tools/{bin => objtools}/ecc | 0 elks/tools/objtools/ewcc | 3 +-- 6 files changed, 11 insertions(+), 8 deletions(-) rename elks/tools/{bin => objtools}/ecc (100%) diff --git a/elks/arch/i86/kernel/process.c b/elks/arch/i86/kernel/process.c index aafe16bfd..a3695dd7c 100644 --- a/elks/arch/i86/kernel/process.c +++ b/elks/arch/i86/kernel/process.c @@ -61,7 +61,7 @@ void stack_check(void) /* optional: check stack over min stack*/ if (current->t_regs.sp < current->t_begstack - current->t_minstack) { if (current->t_minstack) /* display if protected stack*/ - printk("(%P)STACK OVER MINSTACK by %u BYTES\n", + printk("(%P)STACK OUTSIDE PROTECTED LIMIT by %u\n", current->t_begstack - current->t_minstack - current->t_regs.sp); } @@ -69,7 +69,7 @@ void stack_check(void) if (current->t_regs.sp > end) return; } - printk("(%P)STACK OVERFLOW BY %u BYTES\n", end - current->t_regs.sp); + printk("(%P)STACK OVERFLOW by %u\n", end - current->t_regs.sp); do_exit(SIGSEGV); } diff --git a/elks/arch/i86/mm/malloc.c b/elks/arch/i86/mm/malloc.c index 090cf38ed..0e638fef3 100644 --- a/elks/arch/i86/mm/malloc.c +++ b/elks/arch/i86/mm/malloc.c @@ -244,8 +244,8 @@ int sys_brk(segoff_t newbrk) if (current->t_begstack > current->t_endbrk) { /* stack above heap?*/ if (newbrk > current->t_begstack - current->t_minstack) { - printk("sys_brk(%d) fail: brk %x over by %u bytes\n", - current->pid, newbrk, newbrk - (current->t_begstack - current->t_minstack)); + printk("(%d)CAN'T EXPAND HEAP by %u\n", + current->pid, newbrk - (current->t_begstack - current->t_minstack)); return -ENOMEM; } } diff --git a/elks/tools/.gitignore b/elks/tools/.gitignore index 612d17d4c..3740d8780 100644 --- a/elks/tools/.gitignore +++ b/elks/tools/.gitignore @@ -13,6 +13,7 @@ bin/exomizer bin/eman bin/ewcc bin/ewlink +bin/ecc bin/fixomf elftoolchain-0.7.1 bin/mattrib diff --git a/elks/tools/objtools/Makefile b/elks/tools/objtools/Makefile index 6abcfe989..84e95a71a 100644 --- a/elks/tools/objtools/Makefile +++ b/elks/tools/objtools/Makefile @@ -21,7 +21,7 @@ CLEANDEP = CLEANME = ../bin/objdump86 ../bin/omfdump ../bin/omf2elf \ ../bin/os2toelks ../bin/os2dump \ - ../bin/ewcc ../bin/ewlink + ../bin/ewcc ../bin/ewlink ../bin/ecc DEPEND = @@ -42,7 +42,7 @@ include $(BASEDIR)/Makefile-rules CFLAGS += -Wall -Wextra -O3 -all: ../bin/objdump86 ../bin/omf2elf ../bin/omfdump ../bin/os2toelks ../bin/os2dump ../bin/ewcc ../bin/ewlink +all: ../bin/objdump86 ../bin/omf2elf ../bin/omfdump ../bin/os2toelks ../bin/os2dump ../bin/ewcc ../bin/ewlink ../bin/ecc ../bin/objdump86: objdump86.o $(CC) -o ../bin/objdump86 $(CFLAGS) $^ @@ -65,5 +65,8 @@ all: ../bin/objdump86 ../bin/omf2elf ../bin/omfdump ../bin/os2toelks ../bin/os2d ../bin/ewlink: ewlink cp -p ewlink ../bin +../bin/ecc: ecc + cp -p ecc ../bin + ######################################################################### ### Dependencies: diff --git a/elks/tools/bin/ecc b/elks/tools/objtools/ecc similarity index 100% rename from elks/tools/bin/ecc rename to elks/tools/objtools/ecc diff --git a/elks/tools/objtools/ewcc b/elks/tools/objtools/ewcc index e537b8c31..ef00d60e7 100755 --- a/elks/tools/objtools/ewcc +++ b/elks/tools/objtools/ewcc @@ -37,9 +37,9 @@ WATCINCLUDE=$WATCOM/h # -Wc,-wcd=N # disable warning N # -Wc,-fpi87 # inline 8087 fp # -Wc,-x # ignore INCLUDE environment variable -# -fno-stack-check # don't generate stack check code # -fnostdlib # don't refere standard libraries # unused: +# -fno-stack-check # don't generate stack check code # -ztNum # specify far data threshold (default 32767, or 256 if no Num) # -mhard-emu-float # -Wc,-fpi (inline 8087 w/emulation) # -msoft-float # -Wc,-fpc @@ -61,7 +61,6 @@ CCFLAGS="\ -Wc,-zev \ -Wc,-zls \ -Wc,-x \ - -fno-stack-check \ -fnostdlib \ -Wall -Wextra \ -Wc,-wcd=303 \