blob: a286811d1edc2284d1fdf033e64e3de439365305 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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).
|