Executable Format
Thru executable programs follow a specific binary format that includes a header, program bytecode, and trailer.
Program Structure
Section titled “Program Structure”A Thru executable consists of three main components:
| Component | Size | Description |
|---|---|---|
| Header | 8 bytes | Version and metadata |
| Program | Variable | Executable bytecode |
| Trailer | 8 bytes | Zero terminator |
Header Format
Section titled “Header Format”The header is exactly 8 bytes long and contains version information.
Header Layout
Section titled “Header Layout”| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 1 | Version | Program format version (0x01) |
| 1-7 | 7 | Reserved | Reserved for future use |
Version Field
Section titled “Version Field”Currently, only version 0x01 is supported.
01 00 00 00 00 00 00 00^^ Version (0x01) ^^^^^^^^^^^^^^^ Reserved (7 bytes, typically zero)Program Bytecode
Section titled “Program Bytecode”The program bytecode section contains the executable instructions:
- Starts immediately after the 8-byte header
- Variable length depending on the program size
- Contains the actual program instructions
- Minimum size is 0 bytes (empty programs are valid)
Trailer Format
Section titled “Trailer Format”The trailer is exactly 8 bytes long and serves as a terminator.
Trailer Layout
Section titled “Trailer Layout”| Offset | Size | Field | Description |
|---|---|---|---|
| -8 | 8 | Terminator | Must be zero (0x0000000000000000) |
The last 8 bytes of the executable must be set to zero.
00 00 00 00 00 00 00 00^^^^^^^^^^^^^^^^^^^^^^^ All bytes must be zeroSize Constraints
Section titled “Size Constraints”- Total minimum size: 16 bytes (8-byte header + 8-byte trailer)
- Header size: Exactly 8 bytes
- Trailer size: Exactly 8 bytes
- Program size: Variable (minimum 0 bytes)
Complete Example
Section titled “Complete Example”Here’s a minimal valid Thru executable:
01 00 00 00 00 00 00 00 // Header: version 0x01 + 7 reserved bytes95 00 00 00 00 00 00 00 // Program: 8 bytes of instructions00 00 00 00 00 00 00 00 // Trailer: 8 zero bytesIn this example:
- Total size: 24 bytes
- Header size: 8 bytes
- Program size: 8 bytes
- Trailer size: 8 bytes