Page 1 of 1

Annoyed by the Multiboot spec...

Posted: Sun Nov 13, 2005 5:19 pm
by Colonel Kernel
<rant>
The last thing the world needs is another ambiguous spec. >:(
</rant>

Now that that's over with, I have a question about this part of the spec (in reference to the mod_start and mod_end fields of the module info structure):
The first two fields contain the start and end addresses of the boot module itself.
The meaning of the start address is pretty clear. However, the meaning of end address is ambiguous and could lead to some off-by-one errors. Does it mean the address of the last byte of the module, or the address of the first byte after the module?

I'm wondering what the answer is based on people's actual experience...

Re:Annoyed by the Multiboot spec...

Posted: Sun Nov 13, 2005 6:30 pm
by kernel64
In this situation, I'd write a module and ask ld in the linker script to export a symbol like _end_mod and compare to the end module address reported by GRUB, and print it out. Then send a patch to the documentation to the GRUB folks, or whoever maintains the multiboot spec, to make it clear what's happening.

By convention, the end of the address is the first address off the end. For example, a module's image might occupy 0x10000 to 0x12000, i.e. it's 0x2000 bytes long. This means the last byte in the image is 0x12000-1, and the address 0x12000 is not part of the image, but one off the end, and something else can start at that address.

Edit: I could have said that better. What I meant to say in those tortured paragraphs was that if grub reports the start address as 0x10000 and the end address as 0x12000, then the image size is 0x2000 bytes and 0x12000 is not part of the image but the first byte off the end, i.e. 0x11FFC is the address of the last 32-bit doubleword.

Re:Annoyed by the Multiboot spec...

Posted: Mon Nov 14, 2005 12:05 pm
by df
my understanding was subtracting the end from the start gives the module size in bytes.... so it should point to the byte AFTER the end...