summaryrefslogtreecommitdiff
path: root/doc/boot/image_format.md
diff options
context:
space:
mode:
authorArseney300 <Arseney300@gmail.com>2026-03-29 02:07:17 +0700
committerArseney300 <Arseney300@gmail.com>2026-04-08 01:19:07 +0700
commit4912796d2e88c6eb5d02fbf0fb9c39f8c9f7cd4c (patch)
tree9ee8110e2c090c888f23797cda56c7e2df531695 /doc/boot/image_format.md
bastion: initial implementation
ready project skeleton dual-arch build system with Linux-config style configuration UEFI EFI stub loader (PE32+) for x86_64 and AArch64 ELF64 kernel parser Temporary framebuffer console freestanding string and c++ abi stubs For now, kernel boots, prints banner, memory map and go halt
Diffstat (limited to 'doc/boot/image_format.md')
-rw-r--r--doc/boot/image_format.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/boot/image_format.md b/doc/boot/image_format.md
new file mode 100644
index 0000000..a286811
--- /dev/null
+++ b/doc/boot/image_format.md
@@ -0,0 +1,32 @@
+# Final Image format
+
+The main binary is bastion.elf (in some cases it calls kernel.elf).
+It has format of ELF64
+
+## Why ELF64?
+ELF is the basic executable format for unix-like, and this format is very easy for understandable.
+Also elf is what Clang/GCC emit by default when targeting Linux or bare-metal.
+And GDB/LLDB has great understanding of ELF format.
+
+## What format is Linux image
+Linux has its own format for each architecture.
+For example for x86:
+bzImage layout:
+┌──────────────────────┐
+│ Real-mode boot header│ "Boot protocol" setup header
+│ (struct boot_params) │ at offset 0x1F1
+├──────────────────────┤
+│ PE/COFF header │ Grafted on if CONFIG_EFI_STUB=y
+│ (optional) │ so UEFI can load it directly
+├──────────────────────┤
+│ Compressed kernel │ The actual vmlinux (ELF), compressed
+│ (gzip/lz4/zstd) │ with a small decompressor stub
+├──────────────────────┤
+│ Decompressor code │ Runs in protected/long mode,
+│ │ decompresses → real vmlinux
+└──────────────────────┘
+
+for aarch64, kernel Image is a flat binary with 64-byte header defined by the ARM64 boot protocol (with efi_stub config it also can have PE header).
+
+
+