Compare commits

..

1 commit

Author SHA1 Message Date
Slendi
796640e329
Merge 06a79a1a06 into b7d5f81b35 2024-08-23 15:51:17 +02:00
2 changed files with 30 additions and 32 deletions

View file

@ -1,40 +1,43 @@
# Nuke built-in rules and variables.
MAKEFLAGS += -rR
.SUFFIXES:
override MAKEFLAGS += -rR
# This is the name that our final executable will have.
# Change as needed.
override OUTPUT := kernel
# Convenience macro to reliably declare user overridable variables.
override USER_VARIABLE = $(if $(filter $(origin $(1)),default undefined),$(eval override $(1) := $(2)))
define DEFAULT_VAR =
ifeq ($(origin $1),default)
override $(1) := $(2)
endif
ifeq ($(origin $1),undefined)
override $(1) := $(2)
endif
endef
# User controllable C compiler command.
$(call USER_VARIABLE,KCC,cc)
override DEFAULT_KCC := cc
$(eval $(call DEFAULT_VAR,KCC,$(DEFAULT_KCC)))
# User controllable linker command.
$(call USER_VARIABLE,KLD,ld)
override DEFAULT_KLD := ld
$(eval $(call DEFAULT_VAR,KLD,$(DEFAULT_KLD)))
# User controllable C flags.
$(call USER_VARIABLE,KCFLAGS,-g -O2 -pipe)
override DEFAULT_KCFLAGS := -g -O2 -pipe
$(eval $(call DEFAULT_VAR,KCFLAGS,$(DEFAULT_KCFLAGS)))
# User controllable C preprocessor flags. We set none by default.
$(call USER_VARIABLE,KCPPFLAGS,)
override DEFAULT_KCPPFLAGS :=
$(eval $(call DEFAULT_VAR,KCPPFLAGS,$(DEFAULT_KCPPFLAGS)))
# User controllable nasm flags.
$(call USER_VARIABLE,KNASMFLAGS,-F dwarf -g)
override DEFAULT_KNASMFLAGS := -F dwarf -g
$(eval $(call DEFAULT_VAR,KNASMFLAGS,$(DEFAULT_KNASMFLAGS)))
# User controllable linker flags. We set none by default.
$(call USER_VARIABLE,KLDFLAGS,)
# Check if KCC is Clang.
override KCC_IS_CLANG := $(shell ! $(KCC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?)
# If the C compiler is Clang, set the target as needed.
ifeq ($(KCC_IS_CLANG),1)
override KCC += \
-target x86_64-unknown-none
endif
override DEFAULT_KLDFLAGS :=
$(eval $(call DEFAULT_VAR,KLDFLAGS,$(DEFAULT_KLDFLAGS)))
# Internal C flags that should not be changed by the user.
override KCFLAGS += \

View file

@ -9,7 +9,6 @@ ENTRY(kmain)
/* process. */
PHDRS
{
requests PT_LOAD;
text PT_LOAD;
rodata PT_LOAD;
data PT_LOAD;
@ -23,16 +22,6 @@ SECTIONS
/* that is the beginning of the region. */
. = 0xffffffff80000000;
/* Define a section to contain the Limine requests and assign it to its own PHDR */
.requests : {
KEEP(*(.requests_start_marker))
KEEP(*(.requests))
KEEP(*(.requests_end_marker))
} :requests
/* Move to the next memory page for .text */
. = ALIGN(CONSTANT(MAXPAGESIZE));
.text : {
*(.text .text.*)
} :text
@ -49,6 +38,12 @@ SECTIONS
.data : {
*(.data .data.*)
/* Place the sections that contain the Limine requests as part of the .data */
/* output section. */
KEEP(*(.requests_start_marker))
KEEP(*(.requests))
KEEP(*(.requests_end_marker))
} :data
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */