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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
angods
Member
Member
Posts: 26
Joined: Sat Oct 23, 2021 5:36 am

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

Post 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
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.
angods
Member
Member
Posts: 26
Joined: Sat Oct 23, 2021 5:36 am

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

Post 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
Post Reply