mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +00:00
Merge pull request #100 from Zeal-Operating-System/zealbooter-update
zealbooter: Rebase on latest limine-barebones code
This commit is contained in:
commit
d085f7b09d
3 changed files with 56 additions and 43 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -2,17 +2,17 @@
|
|||
*.bin
|
||||
*.ZXE
|
||||
*.MAP
|
||||
src/Boot/
|
||||
/src/Boot
|
||||
*.ELF
|
||||
*.elf
|
||||
*.sys
|
||||
*.SYS
|
||||
src/EFI/
|
||||
build/limine
|
||||
build/ovmf
|
||||
/src/EFI
|
||||
/build/limine
|
||||
/build/ovmf
|
||||
*.iso
|
||||
*.raw
|
||||
*.hdd
|
||||
*.o
|
||||
*.d
|
||||
zealbooter/limine.h
|
||||
/zealbooter/limine.h
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# Nuke built-in rules and variables.
|
||||
override MAKEFLAGS += -rR
|
||||
|
||||
# This is the name that our final kernel executable will have.
|
||||
# Change as needed.
|
||||
override KERNEL := zealbooter.elf
|
||||
|
||||
# Convenience macro to reliably declare overridable command variables.
|
||||
# Convenience macro to reliably declare user overridable variables.
|
||||
define DEFAULT_VAR =
|
||||
ifeq ($(origin $1),default)
|
||||
override $(1) := $(2)
|
||||
|
@ -20,49 +23,54 @@ $(eval $(call DEFAULT_VAR,CC,cc))
|
|||
# Same thing for "ld" (the linker).
|
||||
$(eval $(call DEFAULT_VAR,LD,ld))
|
||||
|
||||
# User controllable CFLAGS.
|
||||
CFLAGS ?= -g -O2 -pipe -Wall -Wextra
|
||||
# User controllable C flags.
|
||||
$(eval $(call DEFAULT_VAR,CFLAGS,-g -O2 -pipe -Wall -Wextra))
|
||||
|
||||
# User controllable preprocessor flags. We set none by default.
|
||||
CPPFLAGS ?=
|
||||
# User controllable C preprocessor flags. We set none by default.
|
||||
$(eval $(call DEFAULT_VAR,CPPFLAGS,))
|
||||
|
||||
# User controllable nasm flags.
|
||||
NASMFLAGS ?= -F dwarf -g
|
||||
$(eval $(call DEFAULT_VAR,NASMFLAGS,-F dwarf -g))
|
||||
|
||||
# User controllable linker flags. We set none by default.
|
||||
LDFLAGS ?=
|
||||
$(eval $(call DEFAULT_VAR,LDFLAGS,))
|
||||
|
||||
# Internal C flags that should not be changed by the user.
|
||||
override CFLAGS += \
|
||||
-std=gnu11 \
|
||||
-ffreestanding \
|
||||
override CFLAGS += \
|
||||
-std=gnu11 \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-fno-lto \
|
||||
-fno-pie \
|
||||
-fno-pic \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-mabi=sysv \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-mcmodel=kernel \
|
||||
-MMD \
|
||||
-I. \
|
||||
-I./lib
|
||||
-fno-stack-check \
|
||||
-fno-lto \
|
||||
-fno-pie \
|
||||
-fno-pic \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-mabi=sysv \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-mcmodel=kernel
|
||||
|
||||
# Internal C preprocessor flags that should not be changed by the user.
|
||||
override CPPFLAGS := \
|
||||
-I. \
|
||||
-I./lib \
|
||||
$(CPPFLAGS) \
|
||||
-MMD \
|
||||
-MP
|
||||
|
||||
# Internal linker flags that should not be changed by the user.
|
||||
override LDFLAGS += \
|
||||
-nostdlib \
|
||||
-static \
|
||||
-m elf_x86_64 \
|
||||
override LDFLAGS += \
|
||||
-nostdlib \
|
||||
-static \
|
||||
-m elf_x86_64 \
|
||||
-z max-page-size=0x1000 \
|
||||
-T linker.ld
|
||||
|
||||
# Check if the linker supports -no-pie and enable it if it does
|
||||
# Check if the linker supports -no-pie and enable it if it does.
|
||||
ifeq ($(shell $(LD) --help 2>&1 | grep 'no-pie' >/dev/null 2>&1; echo $$?),0)
|
||||
override LDFLAGS += -no-pie
|
||||
endif
|
||||
|
@ -71,10 +79,11 @@ endif
|
|||
override NASMFLAGS += \
|
||||
-f elf64
|
||||
|
||||
# Use find to glob all *.c, *.S, and *.asm files in the directory and extract the object names.
|
||||
override CFILES := $(shell find . -type f -name '*.c')
|
||||
override ASFILES := $(shell find . -type f -name '*.S')
|
||||
override NASMFILES := $(shell find . -type f -name '*.asm')
|
||||
# Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
|
||||
# object and header dependency file names.
|
||||
override CFILES := $(shell find -L . -type f -name '*.c')
|
||||
override ASFILES := $(shell find -L . -type f -name '*.S')
|
||||
override NASMFILES := $(shell find -L . -type f -name '*.asm')
|
||||
override OBJ := $(CFILES:.c=.o) $(ASFILES:.S=.o) $(NASMFILES:.asm=.o)
|
||||
override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
|
||||
|
||||
|
@ -83,7 +92,7 @@ override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
|
|||
all: $(KERNEL)
|
||||
|
||||
limine.h:
|
||||
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o $@ || cp ../build/limine/limine.h limine.h || echo "ERROR"
|
||||
curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h limine.h || echo "ERROR"
|
||||
|
||||
# Link rules for the final kernel executable.
|
||||
$(KERNEL): $(OBJ)
|
||||
|
@ -94,11 +103,11 @@ $(KERNEL): $(OBJ)
|
|||
|
||||
# Compilation rules for *.c files.
|
||||
%.o: %.c limine.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
# Compilation rules for *.S files.
|
||||
%.o: %.S limine.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
# Compilation rules for *.asm (nasm) files.
|
||||
%.o: %.asm
|
||||
|
|
|
@ -40,6 +40,10 @@ SECTIONS
|
|||
*(.data .data.*)
|
||||
} :data
|
||||
|
||||
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
|
||||
/* unnecessary zeros will be written to the binary. */
|
||||
/* If you need, for example, .init_array and .fini_array, those should be placed */
|
||||
/* above this. */
|
||||
.bss : {
|
||||
*(COMMON)
|
||||
*(.bss .bss.*)
|
||||
|
|
Loading…
Reference in a new issue