diff options
Diffstat (limited to 'doc/boot/image_format.md')
| -rw-r--r-- | doc/boot/image_format.md | 32 |
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). + + + |
