Skip to content

<util/zxf.h>

ZXF, zuzu's executable container: header, segment table and optional blocks.

#include <util/zxf.h>

Constants

Name Value Description
ZXF_R 1 Segment flag: readable.
ZXF_W 2 Segment flag: writable.
ZXF_X 4 Segment flag: executable.

Enumerations

ZXFArch

Target architecture of an image.

Name Value Description
ARM32 1 32-bit ARM.
ARM64 2 64-bit ARM.
X86_64 3 x86-64.
RISCV 4 RISC-V.
POWPC 5 PowerPC.

ZXFBlockType

Kind of an optional block.

Name Value Description
DYNLINK 1 A zuzu common library (ZCL).
HINTS 2 Loader hints.
DEBUGINFO 3 Debug symbols.
SIGNATURE 4 Signature.

ZXFBlockFlag

Whether a loader may ignore a block it does not understand.

Name Value Description
OPTIONAL 0 Safe to ignore.
REQUIRED 1 Must be understood, or the image is rejected.

Structures

ZXFHeader

ZXF file header (64 bytes, at offset 0).

Field Type Description
magic uint8_t File magic.
version uint8_t Format version.
arch uint8_t Target architecture, a ZXFArch.
flags uint8_t Image flags.
reserved uint8_t Must be zero.
entry uint64_t Entry point address.
load_base uint64_t Lowest load address.
image_size uint32_t Total file size in bytes.
seg_count uint16_t Entries in the segment table.
block_count uint16_t Entries in the block table.
seg_table_offset uint32_t File offset of the segment table.
block_table_offset uint32_t File offset of the block table.
checksum uint32_t Image checksum.
build_id uint8_t Build identifier.
reserved2 uint8_t Must be zero.

ZXFSegment

One loadable segment (24 bytes).

Field Type Description
file_offset uint32_t Offset of the segment's bytes in the file.
file_size uint32_t Bytes present in the file.
vaddr uint64_t Load address.
mem_size uint32_t Size in memory; the part beyond file_size is zero-filled.
flags uint8_t ZXF_R / ZXF_W / ZXF_X.
align uint8_t Alignment, as a power of two.
reserved uint16_t Must be zero.

ZXFImage

A parsed ZXF image, pointing into the caller's buffer.

Field Type Description
base const uint8_t * Start of the image bytes.
size size_t Image size in bytes.
entry uint32_t Entry point address.
seg_count uint16_t Number of segments.
segs const ZXFSegment * The segment table, inside the image.

ZXFBlock

Entry in the block table (12 bytes).

Field Type Description
type uint16_t A ZXFBlockType.
flags uint16_t A ZXFBlockFlag.
offset uint32_t File offset of the block.
size uint32_t Block size in bytes.

Functions

ZxfParse

bool ZxfParse(const void *data, size_t size, ZXFImage *out);

Validates a ZXF image and describes it.

Parameter Direction Description
data in Image bytes.
size in Image size in bytes.
out out Filled on success; points into data.

Returns: true if data is a valid ZXF image.