I don't think there's any way to "link" multiple flat binary files (Nasm's -f bin
output). If we were forced to use (G)as, there's no -f bin
output. ld
will create a flat binary from an ELF linkable object. I think the command line is something like ld -oformat binary -T.text=0x7C00 -o boot.bin boot.o
. I don't know if MinGW's ld
will do it, and I don't know if it will handle multiple files. Something to try, at least...
Linking won't do you any good with your bootsector, in any case. When your computer (or VM?) boots, only the first sector is loaded - 512 bytes exactly. You'll have to provide code to load your "kernel.bin" (or "stage2.bin" from disk (or .vfd?) to a known location in memory. In order to easily find this further code, it is convenient to have it located immediately after the boot sector. You can use cat
or copy
(I think you'll want the /b
option) to combine "boot.bin" and "kernel.bin" to a single file - then dd
it to floppy (or .vfd?).
"kernel.bin" is more flexible. It can be larger than 512 bytes, and could be built from multiple object files. You'll want a flat binary, or you could provide a loader for some executable format - probably MZ, since you're still in 16-bit mode. Once you've switched to 32- (or 64-) bit Pmode, you'll probably want to arrange to load PE or ELF or whatever executable format...
Best source of information I know for this kind of thing is http://www.osdev.org - check it out, if you haven't. Happy bootin'!