flat binary c++ kernel
Posted: Sun Apr 05, 2020 2:30 pm
Hello everyone,
I'm super new to osdev so forgive me if this is a stupid question:
So I made a simple bootloader that is able to load a file from a disk and jump to it (with switching to 32bit protected mode etc).
Now I want to use this bootloader to load my kernel file and jump to its entry point. I've decided to go with c++ for my kernel. My plan is to use raw(flat) binary format, no headers.
I have read quite a few posts on how to link c++ object files into a raw binary e.g https://stackoverflow.com/questions/164 ... 6#23502466.
But i'm still confused about how this approach would handle bss (other sections?), which are supposed to be filled with zeroes by something like an elf-loader.
Would this mean that I can't use anything like static int something; in my kernel? And if I did would this point to an invalid memory address (outside of the binary file)?
Basically my question is how many things would break with this approach?
Also, I know that I would have to call global constructors myself and that there would be no exception support (possibly no virtual functions?) but is there anything else?
How would I know what offset to jump to from my bootloader to get to the entrypoint? Is it something I can control in the linker script? If so, how?
Thanks!
I'm super new to osdev so forgive me if this is a stupid question:
So I made a simple bootloader that is able to load a file from a disk and jump to it (with switching to 32bit protected mode etc).
Now I want to use this bootloader to load my kernel file and jump to its entry point. I've decided to go with c++ for my kernel. My plan is to use raw(flat) binary format, no headers.
I have read quite a few posts on how to link c++ object files into a raw binary e.g https://stackoverflow.com/questions/164 ... 6#23502466.
But i'm still confused about how this approach would handle bss (other sections?), which are supposed to be filled with zeroes by something like an elf-loader.
Would this mean that I can't use anything like static int something; in my kernel? And if I did would this point to an invalid memory address (outside of the binary file)?
Basically my question is how many things would break with this approach?
Also, I know that I would have to call global constructors myself and that there would be no exception support (possibly no virtual functions?) but is there anything else?
How would I know what offset to jump to from my bootloader to get to the entrypoint? Is it something I can control in the linker script? If so, how?
Thanks!