I'm having issues in specifying the entry point for my hobby OS kernel.
There is a simple bootloader that loads the kernel code to 0x6400000
address and jumps there.
Then I have this linker command which outputs kernel with the starting address:
ld --Ttext 0x6400000 -m elf_i386 --oformat binary -e kmain main.o -o main.bin
There's main.cc
with the entry point function:
void kmain() { // ... }
Everything works fine as long as kmain()
is the very first defined function.
If it's not:
void do_smth() { // ... }
void kmain()
{
do_smth();
}
Then ld
(and lld
) ignores the -e kmain
argument, and makes the do_smth()
an entry point.
How could I force ld
to make kmain()
an entry point with an address of 0x6400000
?