summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-09-28 23:03:02 +0000
committerJoursoir <chat@joursoir.net>2021-09-28 23:03:02 +0000
commit92456c92b6da38110df60785a563b30c7108190a (patch)
tree3bf7485d5b009125540ddf5c155063d1ad06e67b
parent6e52d3e6ae1d1612884d8d1533007e1d46f0c4eb (diff)
downloadmfsos-92456c92b6da38110df60785a563b30c7108190a.tar.gz
mfsos-92456c92b6da38110df60785a563b30c7108190a.tar.bz2
mfsos-92456c92b6da38110df60785a563b30c7108190a.zip
x86/boot/makefile: compile two-stage bootloader
-rw-r--r--arch/x86/boot/Makefile28
1 files changed, 20 insertions, 8 deletions
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 0501ab3..e026e24 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -1,27 +1,39 @@
# If you want run this makefile immediately, then set environment
# variables (CC, LD, AS, OBJDUMP) to path of your cross-compiler.
#
-# The best way to compile bootsect.bin is to run the corresponding
+# The best way to compile $BOOTBIN is to run the corresponding
# target in the main Makefile, which is in the root of the
# project (.../path/to/os/Makefile)
-BOOTBIN = bootsect.bin
+BOOTBIN = bootloader.bin
.PHONY: all objdump clean
all: $(BOOTBIN)
-$(BOOTBIN): bootsect.o
- $(CC) -T linker.ld -o $(BOOTBIN) \
+$(BOOTBIN): bootsect.bin setup.bin
+ cat $^ > $@
+
+bootsect.bin: bootsect.o
+ $(CC) -Wl,--oformat binary -Ttext 0x7c00 -o $@ \
+ -ffreestanding -nostdlib \
+ $^ -lgcc
+
+setup.bin: setup.o
+ $(CC) -Wl,--oformat binary -Ttext 0x0200 -o $@ \
-ffreestanding -nostdlib \
$^ -lgcc
-bootsect.o: bootsect.s
+%.o: %.s
$(AS) $< -o $@
-objdump:
+objdump-bootsect:
+ $(OBJDUMP) -D -m i386 -b binary \
+ --adjust-vma=0x7c00 -Maddr16,data16 bootsect.bin
+
+objdump-setup:
$(OBJDUMP) -D -m i386 -b binary \
- --adjust-vma=0x7c00 -Maddr16,data16 $(BOOTBIN)
+ --adjust-vma=0x2000 -Maddr16,data16 setup.bin
clean:
- rm -rf bootsect.o $(BOOTBIN)
+ rm -rf bootsect.o setup.o $(BOOTBIN)