Grub 2 not detecting Multiboot header in kernel

后端 未结 1 914
迷失自我
迷失自我 2021-01-18 17:19

I\'m having an issue with Grub 2 (and QEMU\'s -kernel) not detecting the Multiboot v1 header in my kernel. I have the header in a separate section before

相关标签:
1条回答
  • 2021-01-18 18:19

    I ran into the very same error with my multiboot kernel. I got the same error whem the size of the .text section exceeded about 4k. The cause of my problem was that upon linking, I specified kernel.o first, and loader.o second in the ld arguments (I wrote a Makefile to make my project, based on the OSDev Wiki Bare Bones more comfortable to develop). Multiboot is supposed to look for the header in the first 4k, and as my code grew, it pushed the header out of this area (as it was located before the loader in the kernel .text section). You used a separate section for the multiboot header, which may or may not be a good idea, I don't know. Things I'd try:

    • remove the .multiboot section, and put its contents into the beginning of the loader, and make sure that the loader.o is the first argument to the linker, and kernel.o comes after.
    • use readelf -a kernel to make sure the multiboot header is indeed in the first 4k (that is, if the beginning is at 0x00100000, its offset is below 0x00101000.
    0 讨论(0)
提交回复
热议问题