Last active
December 20, 2022 05:51
-
-
Save ghaiklor/c9b4cfa9111c87e5e12df16f337a338e to your computer and use it in GitHub Desktop.
Script for getting all the sources and building second stage boot loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install pre-requisites | |
sudo apt-get update | |
sudo apt-get -y upgrade | |
sudo apt-get install -y build-essential | |
sudo apt-get install -y nasm | |
sudo apt-get install -y qemu | |
# Download the sources | |
curl https://gist.githubusercontent.com/ghaiklor/3ef5a07b3de1beb964555183dee18621/raw/59cb9ba42fd71631b0bc0c55e2a27c38f0e8ffaf/boot.asm > boot.asm | |
curl https://gist.githubusercontent.com/ghaiklor/d63e5183773770e07854b5d799ef3a44/raw/fcdc0652fa1c39c5e76379e1bd58ac49922feeeb/loader.asm > loader.asm | |
curl https://gist.githubusercontent.com/ghaiklor/bd41fa06d0af6af1adf59e13e12fee7a/raw/fd0446e23f102093bc348f66681614aca264eeef/loader.c > loader.c | |
# Compile first stage boot loader | |
nasm boot.asm -f bin -o boot.bin | |
# Compile second stage boot loader | |
nasm loader.asm -f elf32 -o loader_entry.o | |
gcc -O0 -g -ffreestanding -m32 -c loader.c -o loader.o | |
ld -o loader.bin -m elf_i386 -Ttext 0x1000 loader_entry.o loader.o --oformat binary | |
# Make full image | |
cat boot.bin loader.bin > image.bin | |
# Run on QEMU | |
qemu-system-i386 -fda image.bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment