diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-25 02:55:41 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-25 21:25:16 +0100 |
commit | a2ce17753fa4a727f082bfb9bd515dc3fde56f02 (patch) | |
tree | 9b5d3c309a32c483e4d9cec34d1fe57a476da578 /x86-bare-metal/mbr-pure-zig/Makefile | |
parent | 14845124cf5d4fb42a04cb1262b32bd3d00f45f8 (diff) | |
download | zig-playground-a2ce17753fa4a727f082bfb9bd515dc3fde56f02.tar.gz zig-playground-a2ce17753fa4a727f082bfb9bd515dc3fde56f02.zip |
mbr: zig only real mode 16 bit
Diffstat (limited to 'x86-bare-metal/mbr-pure-zig/Makefile')
-rw-r--r-- | x86-bare-metal/mbr-pure-zig/Makefile | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/x86-bare-metal/mbr-pure-zig/Makefile b/x86-bare-metal/mbr-pure-zig/Makefile new file mode 100644 index 0000000..41d2653 --- /dev/null +++ b/x86-bare-metal/mbr-pure-zig/Makefile @@ -0,0 +1,29 @@ +O := BUILD + +COMMON_FLAGS := -fno-unwind-tables -fno-strip -target x86-freestanding-code16 -O ReleaseSmall + +$(O)/boot: $(O)/boot.elf | check_ep dump_info + objcopy -O binary $< $@ + +$(O)/boot.elf: mbr.ld mbr.zig | $(O) + zig build-exe -femit-bin=$@ $(COMMON_FLAGS) -fno-entry --script $^ + +clean: + $(RM) -r $(O) + +$(O): + mkdir -p $(O) + +# Check entry point is exactly at 0x7c00. +check_ep: $(O)/boot.elf + readelf -h $< | awk '/Entry point address:/ { print $$4 }' | grep 0x7c00 >& /dev/null + +# Dump some debug info (disasm, elf load segments, code size). +dump_info: $(O)/boot.elf + objdump -Mintel -m i8086 --disassemble --visualize-jumps=extended-color $< + readelf -W -l $< + size $< + size $< | awk '/$(notdir $<)/ { print "MBR utilization " $$1/512 "%" }' + +run: $(O)/boot + qemu-system-i386 -hda $< $(QEMU_ARGS) |