nullplan wrote:
eekee wrote:
I just don't see what's so hard about prepending a header to the ELF, adding a little program to generate it and calling the program from the makefile or whatever.
ELF files must necessarily start with the ELF header. You can get a hell of a benefit from keeping the kernel file a valid ELF file, because then GDB can find things where they are expected. And for most people it is just easier to add the multiboot header to the first section. If only there weren't so many tutorials out there calling for linker scripts that way over-align all the sections, things could be so much easier.
Right. GDB can be configured to work with a different format, but writing that config is often one of those, "In the carpenter's house, all the doors are off their hinges," kind of things. I've seen it happen in 9front; some wanted an acid script (≈ GDB config) for something or other, (not the kernel,) but it was months before someone got around to writing it.
nullplan wrote:
eekee wrote:
I'd have to modify my toolchain to use either multiboot or limine; it only generates PE32.
As I said, you can use multiboot at least with whatever binary format blows your skirt up if you enable the bit they call "a.out kludge". Which essentially adds a very simple executable header (containing memory sizes and the entry point) into the multiboot header. You can even use it without any header whatsoever if you do that.
I might just do that!
nullplan wrote:
eekee wrote:
In actual fact, the dead-code elimination in my compiler means I'd have to implement extra headers in the same part of the compiler which generates the normal headers.
The normal solution for problems like these is to have some way to tell the compiler that something is used no matter what it thinks. GCC has __attribute__((used)), linker scripts have KEEP(), etc.
I'd have to implement that. I could instead take a pointer to the multiboot structure during initialization; that wouldn't hurt.
Octocontrabass wrote:
eekee wrote:
Mapping and entry point are good reasons to use ELF.
Doesn't PE have those too?
Just there, I should have written "ELF or PE," as opposed to a kernel/bootloader-specific non-executable format.
Octocontrabass wrote:
eekee wrote:
I just don't see what's so hard about prepending a header to the ELF, adding a little program to generate it and calling the program from the makefile or whatever.
That would work with Multiboot, since you can repeat all the information the bootloader would normally get from the ELF (or PE) headers in the Multiboot headers, but Limine seems to require a valid executable binary.
Right; Multiboot's a.out kludge.
Regardless of what I think is "doing it properly", Multiboot with the a.out kludge could save me a lot of time.