andrewrk / andrewrk/HellOS

Multiboot is broken on Fast and Small modes

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Zig
Stars
339
Forks
40
PR merge metrics
No merged PRs in 30d

Description

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
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.