Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Linux x86 boot image (bzImage)

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

The x86 Linux boot image (bzImage, vmlinuz): a real-mode setup header with magic HdrS at 0x202 and a boot protocol version (2.00 to 2.15), followed by the protected-mode kernel whose payload is a compressed vmlinux.

Identification

  • File offset 0x1FE holds 55 AA (boot_flag 0xAA55), offset 0x202 the ASCII HdrS (0x53726448), offset 0x206 the 16-bit boot protocol version (0x020F = 2.15). Without HdrS the image is a pre-2.00 zImage/Image.
  • setup_sects (0x1F1; 0 means 4) gives the real-mode size: the protected-mode kernel starts at (setup_sects + 1) * 512.
  • EFI-stub kernels start with a DOS header (MZ) and are also PE files; the setup header still sits at 0x1F1-0x268.
  • kernel_version (0x20E) holds an offset (add 0x200 to it, from the file start) to the version string, e.g. 6.1.0 (builder) #1 SMP ....

Layout

Fields: Fact:Linux x86 boot image (bzImage)/struct/setup header. Versions: Fact:Linux x86 boot image (bzImage)/enum/boot protocol versions. Flags: Fact:Linux x86 boot image (bzImage)/enum/loadflags and xloadflags. payload_offset and payload_length (0x248, protocol 2.08+) locate the compressed vmlinux inside the protected-mode part. kernel_info (protocol 2.15), at kernel_info_offset, starts with LToP (0x506F544C) and holds header size, total size and setup_type_max. setup_data (2.09+) is a physical-address linked list of {next u64, type u32, len u32, data} nodes; 2.15 adds SETUP_INDIRECT.

Compressed payload

After the setup code come the decompressor stub (arch/x86/boot/compressed) and the compressed vmlinux. A scanner looks for these magics, as scripts/extract-vmlinux does: Fact:Linux x86 boot image (bzImage)/identification/Compressed payload signatures. Each hit is decompressed and accepted only if the output reads as ELF, because false hits are common. See Format:LZ4 (legacy frame, with the appended size pitfall), Format:Zstandard, Format:XZ, Format:LZMA.

After decompressing

The result is a vmlinux ELF, or on embedded builds a raw binary without symbols: recover names with Format:kallsyms. Other containers (per the vmlinux-to-elf unpacker): ARM zImage (magic 0x016F2818 near offset 0x24), U-Boot uImage (27 05 19 56), Android boot.img (ANDROID!).

Code & repositories

  • https://github.com/marin-m/vmlinux-to-elf @ 2d094bc9c220b6b50f8215cbc3c9e581210ce1a6 · license: GPL-3.0
    Recovers kallsyms and rebuilds an ELF from raw or compressed kernel images (GPL-3.0); vmlinux_to_elf/core/kallsyms.py documents the heuristics
    Tested on: source read, not run: not run; source read at the pinned commit · checked 2026-10-18; last activity 2026-10-16
  • https://github.com/torvalds/linux @ 32c52ec87d6245ee2d12ed5dd509e40062939b50 · license: GPL-2.0 WITH Linux-syscall-note (read from COPYING; GitHub's detector did not classify it)
    Linux kernel sources (GPL-2.0): Documentation/arch/x86/boot.rst, include/uapi/linux/btf.h, include/linux/module.h, vermagic.h, export.h, scripts/kallsyms.c, scripts/mod/modpost.c, scripts/extract-vmlinux
    Tested on: source read, not run: not run; source read at the pinned commit · checked 2026-10-18; last activity 2026-10-18

See also

Platform:Linux kernel, Format:ELF (Executable and Linkable Format).