[SOLVED] Use ld to output flat binary for real mode
Posted: Sun Jul 22, 2018 12:28 am
I basically want to use ld to output as a flat binary that I can use in real mode. I mostly want to do this so that I can use C for my second stage bootloader. Here is my linker script heavily based off of(mostly copied) it's page on the OsDev Wiki:
My biggest issue here is that I don't know what I should put as the output format. If i use "binary", it gives me this:
Note that bootldr_s2.s was compiled with
and that it's currently
I'm not really sure where to go from here, and would really appreciate some help.
Code: Select all
ENTRY(start)
STARTUP(bootldr_s2.s.o)
OUTPUT_FORMAT("binary_i386?") /* Biggest isue here */
SECTIONS
{
.text.start (_KERNEL_BASE_) : { /* I change this to 0x0000, right? */
bootldr_s2.s.o( .text )
}
.text : ALIGN(0x1000) {
_TEXT_START_ = .;
*(.text)
_TEXT_END_ = .;
}
.data : ALIGN(0x1000) {
_DATA_START_ = .;
*(.data)
_DATA_END_ = .;
}
.bss : ALIGN(0x1000) {
_BSS_START_ = .;
*(.bss)
_BSS_END_ = .;
}
}
Code: Select all
ld: skipping incompatible bootldr_s2.s.o when searching for bootldr_s2.s.o
ld: cannot find bootldr_s2.s.o
Code: Select all
nasm -f elf -o bootldr_s2.s.o
Code: Select all
BITS 16
start:
mov eax, 0xBCAF ;If this is in eax, then the code loaded
jmp $