Last active
September 4, 2020 22:37
-
-
Save mikerowehl/ffaad752adc98a6286c6297d0a63c44b to your computer and use it in GitHub Desktop.
Compiling boot sector from assembly and C++ using a Docker cross-compile toolchain
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
# Assuming you have boot4.asm, kmain.cpp, and linker.ld from | |
# http://3zanders.co.uk/2017/10/18/writing-a-bootloader3/ | |
# already in your working directory and you have nasm and qemu | |
# installed locally | |
nasm -f elf32 boot4.asm -o boot4.o | |
docker run --rm dockcross/linux-x86 > ./dockcross | |
chmod +x dockcross | |
./dockcross g++ -m32 kmain.cpp boot4.o -o kernel.bin -nostdlib \ | |
-ffreestanding -std=c++11 -mno-red-zone -fno-exceptions \ | |
-nostdlib -fno-rtti -Wall -Wextra -Werror -fno-pie -T linker.ld | |
qemu-system-x86_64 kernel.bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment