Page 1 of 1

exporting nasm code as win64 causes it to add extra junk

Posted: Fri May 08, 2020 10:57 am
by CalebKeatts
I have created a custom bootloader and created the kernel in c++ following the osdev wiki. When I try to compile the assembly with

Code: Select all

nasm.exe -f win64 boot.asm -o boot.obj
, compile the kernel.cpp to kernel.obj, and link it with

Code: Select all

~\tdm-gcc64\c++.exe -T linker.ld -o Boot.img -ffreestanding -nostdlib boot.obj kernel.obj
it will have extra "This program cannot be run in DOS mode" I also don't know how to set it to start at 0x7c00 as

Code: Select all

org 0x7c00
doesn't work unless in binary format. Any help will be appreciated.

Re: exporting nasm code as win64 causes it to add extra junk

Posted: Fri May 15, 2020 2:45 am
by Octocontrabass
You're using a compiler targeted towards Windows, so it creates Windows EXE files by default. Does your linker script tell it you want a flat binary?

I strongly recommend using a cross-compiler. It's much easier to get help with your compiler when you're using the same compiler that everyone else is using.