Page 1 of 1

How to force linker to include kernel entry point before C?

Posted: Mon Oct 25, 2021 12:16 pm
by angods
I can't really find a definite answer anywhere and I'd like to know.

I made my own bootloader and a mini-kernel in assembly for learning purposes and I'd like to continue in C (though I need minimal amount assembly for the entry point).
The "Bare Bones" tutorial shows how to use GRUB and I think steps outlined by it aren't relevant for a custom bootloader.

Thanks in advance :D

Re: How to force linker to include kernel entry point before

Posted: Mon Oct 25, 2021 12:21 pm
by Octocontrabass
Add ELF support to your custom bootloader. :P

...Or, if you really want to use a flat binary, put the entry point code in a separate section and then use your linker script to put that section first in the binary. The Bare Bones tutorial already does this with the multiboot header, so you can use that as an example.

Re: How to force linker to include kernel entry point before

Posted: Mon Oct 25, 2021 12:58 pm
by angods
Octocontrabass wrote:Add ELF support to your custom bootloader. :P

...Or, if you really want to use a flat binary, put the entry point code in a separate section and then use your linker script to put that section first in the binary. The Bare Bones tutorial already does this with the multiboot header, so you can use that as an example.
I thought of doing that, but I want the bootloader to be as simple as possible.

The second approach sounds better to me, I'll look into it. Thanks! :D