Page 1 of 1

mbcheck says my multiboot header has bad checksum

Posted: Sun Jan 13, 2013 2:37 pm
by gsingh2011
After following the bare bones tutorial, I ran mbcheck on loader.o and kernel.bin. I also modified the mbcheck.c file to print out the magic and the flags so I could see what was causing the problem. The output is very strange:

Code: Select all

$ mbcheck loader.o
loader.o: The Multiboot header is found at the offset 564.
magic: 0x1badb002
flags: 0x30fff10000
loader.o: Bad checksum (0xe4524ffb).
$ mbcheck kernel.bin 
kernel.bin: The Multiboot header is found at the offset 4560.
magic: 0x1badb002
flags: 0x2afff10000
kernel.bin: Bad checksum (0xe4524ffb).
As you can see, the issue is with the flags. The hex value should be 0x03 in the bare bones tutorial, and yet it's not in the hex. After inspecting both files with hexdump, I see something very strange:

Code: Select all

00000160  02 b0 ad 1b 03 00 00 00  fb 4f 52 e4 bc 00 40 00  |.........OR...@.|
This multiboot header looks fine, and is not what mbcheck said. But looking further down the hexdump I see:

Code: Select all

00000230  2a 00 00 00 02 b0 ad 1b  00 00 00 00 00 00 f1 ff  |*...............|
00000240  30 00 00 00 fb 4f 52 e4  00 00 00 00 00 00 f1 ff  |0....OR.........|
And this is what mbcheck told me. Running hexdump on the other file gives a similar output.

So my question is this: Why do I see the multiboot header multiple times in hexdump? Why is it wrong the second time? And will grub use the first correct version or the second incorrect version (my kernel does not boot, so I think it may be using the incorrect version).

Re: mbcheck says my multiboot header has bad checksum

Posted: Mon Jan 14, 2013 10:21 am
by gsingh2011
So turns out my kernel boots fine, even though mbcheck says the checksum is off.

Could this be a bug with mbcheck?

Re: mbcheck says my multiboot header has bad checksum

Posted: Tue Jan 15, 2013 12:28 pm
by dozniak
Is your mbcheck compiled as a 32-bits app?

Re: mbcheck says my multiboot header has bad checksum

Posted: Tue Jan 15, 2013 12:34 pm
by gsingh2011
dozniak wrote:Is your mbcheck compiled as a 32-bits app?
Nope, it was compiled as 64 bit and compiling as 32 bit fixed the problem. Thanks :)