HellOS icon indicating copy to clipboard operation
HellOS copied to clipboard

Multiboot is broken on Fast and Small modes

Open sagehane opened this issue 3 years ago • 0 comments

The OS currently fails to build with a proper multiboot section on ReleaseFast and Small builds.

For the header to be valid, the entire multiboot header must apparently be in the first 8KB of the OS image, and also be 32-bit aligned. (And ideally should be included as early as possible)

As of 0.8.0-dev.2193+fe14270f4, building in Debug and Safe seems to put the header in the 4096th byte. Building as Fast, Small, and Safe without the panic function seems to place the header at the 8192th byte.

It seems like removing the ALIGN(4K) for .text from the linker.ld makes the image valid on Fast, Small, and Safe + panic.

diff --git a/linker.ld b/linker.ld
index 035bae7..c203a5b 100644
--- a/linker.ld
+++ b/linker.ld
@@ -3,7 +3,7 @@ ENTRY(_start)
 SECTIONS {
        . = 1M;

-       .text : ALIGN(4K) {
+       .text : {
                KEEP(*(.multiboot))
                *(.text)
        }

This changes the location of the header for the following build modes:

  • Debug/Safe: No change, 0x1000 (or 4096)
  • Fast: 0x1030
  • Small: 0x1024
  • Safe without the panic function: 0x1030

Since I don't really get the reason behind this - and hence I'm not sure what the best way to deal with the problem - I'm not going to make a PR. Well, at least for now.

sagehane avatar May 11 '21 15:05 sagehane