summaryrefslogtreecommitdiffstats
path: root/makefile
diff options
context:
space:
mode:
authorAlexey Gavrilov <alexey.gavrilov@mail.com>2025-12-20 19:39:05 +0700
committerAlexey Gavrilov <alexey.gavrilov@mail.com>2025-12-20 19:39:05 +0700
commita4dea4148157a94a9143dbbd92fdd88b4358676c (patch)
tree5d36a0adf4e9f38cee297da6f10e84944d226014 /makefile
parenta72c27d948ee8cf542f8d38c7026876af4875e6b (diff)
Global variables initialization implementationlinker_script
User implementation of C runtime library objects (`crti.s` and `crtn.s`) for initialization (termination functionality are ignored). Changing files order passed to the linker. Rough order is: boot.s crti.o crtbegin.o other-link-objects.o crtend.o crtn.o Signed-off-by: Alexey Gavrilov <alexey.gavrilov@mail.com>
Diffstat (limited to 'makefile')
-rw-r--r--makefile10
1 files changed, 9 insertions, 1 deletions
diff --git a/makefile b/makefile
index 051eb0e..79152f8 100644
--- a/makefile
+++ b/makefile
@@ -25,13 +25,21 @@ endif
OS_BINARY = $(BDIR)/kernel.bin
BDIR = ./build
+BOOTOBJ = $(filter %boot.o, $(OBJ_FILES))
+CRTIOBJ = $(filter %crti.o, $(OBJ_FILES))
+CRTNOBJ = $(filter %crtn.o, $(OBJ_FILES))
+OBJ_REORDERING = $(filter-out $(BOOTOBJ), $(filter-out $(CRTIOBJ), $(filter-out $(CRTNOBJ), $(OBJ_FILES))))
+
+
.PHONY: install $(SOURCE_FILES)
build: startbuild $(SOURCE_FILES)
+ @echo "Bootfile: " $(BOOTOBJ) $(CRTIOBJ) $(CRTNOBJ)
+ @echo $(OBJ_FILES)
echo $(AFLAGS)
echo $(CFLAGS)
@echo "Link object files..."
- $(LD) -o $(OS_BINARY) -L$(ARCHDIR) -T$(LDFILE) $(OBJ_FILES) $(LDFLAGS)
+ $(LD) -o $(OS_BINARY) -L$(ARCHDIR) -T$(LDFILE) $(BOOTOBJ) $(CRTIOBJ) $(LIBS_PATH)crtbegin.o $(OBJ_REORDERING) $(LIBS_PATH)crtend.o $(CRTNOBJ) $(LDFLAGS)
@echo "Project was built"
$(CFILES):