DEV Community

Jaipal001
Jaipal001

Posted on

64-bit bootloader from scratch in AT&T assembly, Part-8

Repo link

os-scratch

Makefile

# $@ = target file
# $< = first dependency
# $^ = all dependencies

LDFLAGS =  --oformat binary -N

CFLAGS = -ffreestanding -fno-pie

all: run

out/%.o: %.asm
    as -o $@ $<

bin/kernel: out/kernel.o
    ld -o $@ -T../link.ld  $(LDFLAGS) $^

bin/bootsect: out/bootloader.o
    ld -o $@ -Ttext 0x7c00 $(LDFLAGS) $<

os-img.bin: bin/bootsect bin/kernel
    cat $^ > $@
    truncate -s 10240 $@

run: os-img.bin
    qemu-system-x86_64 -drive format=raw,file=$<
Enter fullscreen mode Exit fullscreen mode

Top comments (0)