acccidiccc wrote:
I just realized that the cause for my problem was that the .text section was placed first in the binary.
With a linker script, you're in full control of which section comes after another.
acccidiccc wrote:
However the .text section is the section that is called after the jump to the higher half.
Bad idea. Use the entry point, that's what it is for.
acccidiccc wrote:
/* Add a symbol that indicates the start address of the kernel. */
I see no symbol here. (Maybe not needed, just make sure you have an Assembly function called "_start"). Whereever it goes in the text segment, its VMA will be saved in the elf_hdr->e_entry field, use that when you pass control over.
acccidiccc wrote:
putting the header and bootstrap trampoline code into the higher half is obviously a bad idea.
As I've said, it doesn't matter. For the header only the file offset counts, not the link address, VMA is totally indifferent. (There's no such thing, higher half file offset.) When you use "readelf -l", you'll see both, for example:
Code:
LOAD 0x0000000000000e10 0x0000000000600e10 0x0000000000600e10
^file offset ^Virtual Memory Address
As you can see here 0xe10 != 0x600e10. Furthermore, Multiboot header can be outside of loadable segments, and not loaded into memory in run-time at all.
acccidiccc wrote:
Is there any way to make the .multiboot.data section to be first in terms of offset?
Yes, as I've already said, use the KEEP() pseudo function in the linker script. Also make sure you put it in the first segment (that's probably the text segment and not the data segment), and read about
section placement, you'll find useful information there.
Cheers,
bzt