Introduction
The RISC-V Image is the uncompressed Linux kernel for RISC-V, with a 64-byte header that follows the layout of the
ARM64 one. The fields are from the Linux document “Boot image header in RISC-V Linux” (read
through a page summary; the descriptions are in our own words).
Header
The document gives text_offset, image_size, flags and the magic numbers as little-endian.
| Offset | Size | Field | What it holds |
|---|---|---|---|
0x00 | 4 | code0 | Executable code. The document says it is replaced by MZ for the EFI stub. |
0x04 | 4 | code1 | Executable code. |
0x08 | 8 | text_offset | The offset at which the image is loaded. |
0x10 | 8 | image_size | The effective size of the image. Mandatory: the kernel does not boot without it. |
0x18 | 8 | flags | Kernel flags. Bit 0 is the endianness (1 big-endian); no other bit is defined. |
0x20 | 4 | version | The header version: minor in bits 0–15, major in bits 16–31. 0.2 is the current one. |
0x24 | 4 | res1 | Reserved, zero. |
0x28 | 8 | res2 | Reserved, zero. |
0x30 | 8 | magic | 0x5643534952: the characters RISCV and zero padding. Deprecated from header version 0.2. |
0x38 | 4 | magic2 | 0x05435352: RSC followed by 0x05. It replaces magic. |
0x3C | 4 | res3 | Reserved for the offset of the rest of the PE/COFF header when the image has an EFI stub. |
What the viewer shows
The header field by field, the version, the endianness flag, the EFI stub offset, and the first 1,024 bytes (an option) disassembled with the
RISC-V decoder. The file does not say whether the kernel is RV32 or RV64 or which extensions it uses, so the options
bar chooses a profile: RV64GC by default. The viewer reports an image size of zero or below the file size, flag bits other than bit 0, a header version newer
than 0.2, and a version below 0.2 without the first magic. The Linux document does not say how a boot loader starts the image; that is outside these pages.
The file is recognised by magic2 and a non-zero image_size.
Not described
Known, not yet covered
- Viewer: the kernel after the first bytes is not explained: code and data are not told apart and no function is named.
- Reference: the PE/COFF header of an EFI-stub image, and the way a boot loader hands over (the document for it is the RISC-V Linux boot requirements, which these pages do not cover).
- Viewer: no real RISC-V Image was available for these pages; the checks were made on built images.
Unknown
- Viewer: RV32 or RV64 and the extensions are not in the file: the options bar chooses, and the viewer cannot.