Example multiboot info struct doesn't account for padding for alignment?
Posted: Fri Sep 13, 2024 11:49 pm
Hi everyone,
consider the following example from gnu's official documentation about multiboot: https://www.gnu.org/software/grub/manua ... le-OS-code
In particular, look at the definition `struct multiboot_info` in `multiboot.h` and at the first table under "3.3 Boot information format".
Seemingly they fit well together and indeed, I was able to correctly draw some pixels on screen with the framebuffer for example. But isn't the struct automatically padded for alignment? If it's padded, then the addresses in the table won't match the offsets inside the struct, so if I do `mbi->framebuffer_addr` it will point to a higher address than where the framebuffer address actually resides. As far as I can see, the struct neither has the __attribute__((packed)) nor are the fields arranged in a way that wouldn't require padding.
What am I missing? I'm hoping I have a fundamental misunderstanding somewhere so I can learn about it.
Thanks in advance!
consider the following example from gnu's official documentation about multiboot: https://www.gnu.org/software/grub/manua ... le-OS-code
In particular, look at the definition `struct multiboot_info` in `multiboot.h` and at the first table under "3.3 Boot information format".
Seemingly they fit well together and indeed, I was able to correctly draw some pixels on screen with the framebuffer for example. But isn't the struct automatically padded for alignment? If it's padded, then the addresses in the table won't match the offsets inside the struct, so if I do `mbi->framebuffer_addr` it will point to a higher address than where the framebuffer address actually resides. As far as I can see, the struct neither has the __attribute__((packed)) nor are the fields arranged in a way that wouldn't require padding.
What am I missing? I'm hoping I have a fundamental misunderstanding somewhere so I can learn about it.
Thanks in advance!