Annoyed by the Multiboot spec...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Annoyed by the Multiboot spec...

Post 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...
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
kernel64

Re:Annoyed by the Multiboot spec...

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Annoyed by the Multiboot spec...

Post 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...
-- Stu --
Post Reply