From eb6a12e18d45879ec383921f0c7378120b71d159 Mon Sep 17 00:00:00 2001 From: Alexey Gavrilov Date: Wed, 17 Dec 2025 14:13:08 +0700 Subject: Linker script rework `memory.ld` is a architecture-dependent ld config provides some general symbols which every `memory.ld` config must assign and memory regions associated with each output section. 'linker.ld' config file presents segments configuration. Multiboot section filling move in the 'linker.ld' file. Recommendation for further patches: controlled logic implementation for multiboot version and header/entries in build configuration tool (CMake or make). For instance, multiboot version and video mode selection through variable passing in build system: `cmake ... -DMULTIBOOT_VERSION=2 -DMULTIBOOT_VIDEO_MODE=TEXT_VIDEO_MODE` or 'export MULTIBOOT_VERSION=2; export MULTIBOOT_VIDEO_MODE=TEXT_VIDEO_MODE'. Then build system do proper filling of `.multiboot` section depends on passing variables. Signed-off-by: Alexey Gavrilov --- makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index fc3286a..051eb0e 100644 --- a/makefile +++ b/makefile @@ -9,10 +9,12 @@ QEMUFLAGS = CFILES = $(shell find ./ -type f \( -name \*.cpp -o -name \*.c \)) AFILES = $(shell find ./ -type f \( -iname \*.s -o -name \*.asm \)) -LDFILE = $(shell find ./ -type f -name *.ld) +LDFILE = ./kernel/linker.ld SOURCE_FILES = $(CFILES) $(AFILES) OBJ_FILES = $(addprefix $(BDIR)/, $(addsuffix .o, $(basename $(SOURCE_FILES)))) INCLUDE = ./include +# Bad practice! +ARCHDIR = arch/x86 ifdef DEBUG CFLAGS := -g3 $(CFLAGS) @@ -29,7 +31,7 @@ build: startbuild $(SOURCE_FILES) echo $(AFLAGS) echo $(CFLAGS) @echo "Link object files..." - $(LD) -o $(OS_BINARY) -T $(LDFILE) $(OBJ_FILES) $(LDFLAGS) + $(LD) -o $(OS_BINARY) -L$(ARCHDIR) -T$(LDFILE) $(OBJ_FILES) $(LDFLAGS) @echo "Project was built" $(CFILES): -- cgit v1.2.3