diff options
-rw-r--r-- | kernel/Makefile | 6 | ||||
-rw-r--r-- | kernel/features/load.c | 7 | ||||
-rw-r--r-- | kernel/link.ld | 3 | ||||
-rw-r--r-- | libs/libc/inc/mem.h | 4 | ||||
-rwxr-xr-x | run | 9 |
5 files changed, 14 insertions, 15 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 8970c1b..e4b181c 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -8,6 +8,7 @@ COBJS = main.o \ drivers/keyboard.o \ drivers/mouse.o \ drivers/pci.o \ + drivers/rtc.o \ drivers/ide.o \ drivers/fb.o \ drivers/timer.o \ @@ -34,6 +35,5 @@ all: compile @$(AS) $(ASFLAGS) $< -o $@ compile: $(COBJS) - @mkdir -p ../build/ - @$(LD) -N -z undefs -ekernel_main -Ttext 0x00009000 -o ../build/kernel.elf -L../build/ $+ -lk - @$(LD) -N -z max-page-size=0x1000 -Tlink.ld -o ../build/kernel.bin -L../build/ $+ -lk + @mkdir -p ../build/apps/ + @$(LD) -N -z max-page-size=0x1000 -ekernel_main -Tlink.ld -o ../build/apps/kernel -L../build/ $+ -lk diff --git a/kernel/features/load.c b/kernel/features/load.c index 3dff831..d87bb94 100644 --- a/kernel/features/load.c +++ b/kernel/features/load.c @@ -9,8 +9,6 @@ #include <random.h> #include <str.h> -#define PROC_STACK_SIZE 0x4000 - res elf_load(const char *path, struct proc *proc) { if (!memory_valid(path)) @@ -50,8 +48,11 @@ res elf_load(const char *path, struct proc *proc) header.version != 1 || header.machine != ELF_MACHINE_386) return -ENOEXEC; + if (!memory_valid((void *)header.entry)) + return -ENOEXEC; + // ASLR - u32 rand_off = (rand() & 0xffff) * PAGE_SIZE; + u32 rand_off = header.type == ELF_ETYPE_DYN ? (rand() & 0xffff) * PAGE_SIZE : 0; // Loop through programs for (u32 i = 0; i < header.phnum; i++) { diff --git a/kernel/link.ld b/kernel/link.ld index 3b92e82..d213070 100644 --- a/kernel/link.ld +++ b/kernel/link.ld @@ -1,7 +1,6 @@ -OUTPUT_FORMAT("binary") OUTPUT_ARCH(i386) ENTRY(kernel_main) -phys = 0x00009000; +phys = 0x00100000; SECTIONS { diff --git a/libs/libc/inc/mem.h b/libs/libc/inc/mem.h index 7318c25..de2a84f 100644 --- a/libs/libc/inc/mem.h +++ b/libs/libc/inc/mem.h @@ -13,8 +13,8 @@ void *realloc(void *ptr, u32 size); void *zalloc(u32 size); #ifdef KERNEL -#define STACK_START 0x00500000 // Defined it bootloader -#define STACK_SIZE 0x1000 // idk +#define STACK_START 0x00500000 // Defined in bootloader +#define STACK_SIZE (1 << 20) // 1MiB #elif defined(USER) #endif @@ -180,7 +180,6 @@ make_build() { $SUDO chmod -R 0 mnt/conf/ $SUDO cp -r build/apps/ mnt/bin/ $SUDO cp build/load.bin mnt/ - $SUDO cp build/kernel.bin mnt/ $SUDO umount mnt/ rm -rf mnt/ @@ -208,20 +207,20 @@ make_debug() { make_disasm() { if [ -z "$1" ]; then - echo "Usage: './run disasm {kernel.elf, apps/wm, ...} [-S]'" + echo "Usage: './run disasm {kernel, wm, ...} [-S]'" exit 1 fi - objdump -drwC "$2" -Mintel build/"$1" | less -R + objdump -drwC "$2" -Mintel build/apps/"$1" | less -R #hexdump -C build/kernel.bin | less -R } make_addr() { printf "Info: Make sure that you've turned the debug build on (e.g. with MELVIX_DEBUG=1)\n\n" if [ -z "$2" ]; then - echo "Usage: './run addr kernel.elf 0x50042'" + echo "Usage: './run addr kernel 0x50042'" exit 1 fi - addr2line -e build/"$1" -f -p "$2" + addr2line -e build/apps/"$1" -f -p "$2" } make_cloc() { |