Format:AmigaOS Hunk executable
| Magic | 00 00 03 F3 (load file) or 00 00 03 E7 (object file) |
|---|---|
| Extensions | none usual (executables), .o .obj .lib (objects) |
| Endianness | big endian |
| On this wiki | Facts · Code · Notes · Topics |
The AmigaOS Hunk format: big-endian files made of 32-bit hunk ID blocks. Load files start with HUNK_HEADER (0x3F3) and a hunk size table whose top two bits select chip/fast memory; object files start with HUNK_UNIT (0x3E7). Covers hunk IDs, relocation blocks, symbols, debug hunks and overlays.
Block IDs
Every block starts with a 32-bit ID; only the low 30 bits are the ID, the top two bits are memory flags in hunk-size words and in ID words of some tools (HUNK_VALUE(id) = id & 0x3fffffff). See Fact:AmigaOS Hunk executable/enum/Hunk block IDs (999 HUNK_UNIT, 1000 NAME, 1001 CODE, 1002 DATA, 1003 BSS, 1004 RELOC32, 1005 RELOC16, 1006 RELOC8, 1007 EXT, 1008 SYMBOL, 1009 DEBUG, 1010 END, 1011 HEADER, 1013 OVERLAY, 1014 BREAK, 1015-1017 DREL32/16/8, 1018 LIB, 1019 INDEX, 1020 RELOC32SHORT, 1021 RELRELOC32, 1022 ABSRELOC16; 1257 HUNK_PPC_CODE and 1260 RELRELOC26 are PowerPC extensions). In hex: 0x3E9 CODE, 0x3EA DATA, 0x3EB BSS, 0x3EC RELOC32, 0x3F0 SYMBOL, 0x3F1 DEBUG, 0x3F2 END, 0x3F3 HEADER.
Load files (executables)
HUNK_HEADER: a list of resident library names (each a length-in-longs, then the text; a zero length ends the list; obsolete, AmigaOS 1.x only, binutils refuses files that use it), then the table size, the first and last hunk number to load, and one size longword per hunk from first to last. For an ordinary executable first = 0 and last = table size - 1. The size is in longwords in the low 30 bits; bits 31..30: 01 = MEMF_CHIP, 10 = MEMF_FAST, 11 = a further longword with the full memory flags follows; bit 29 is HUNKF_ADVISORY. See Fact:AmigaOS Hunk executable/struct/HUNK_HEADER.
Then for each hunk, in order: HUNK_CODE, HUNK_DATA or HUNK_BSS (a size in longs, then the contents; none for BSS), optional relocation blocks, optional HUNK_SYMBOL and HUNK_DEBUG, and HUNK_END. Hunk numbers in relocations refer to this table; Unverified: the AmigaDOS loader allocates each hunk separately, so hunks are not contiguous in memory.
Relocation
HUNK_RELOC32: repeat { count; target hunk number; count offsets } until a count of 0; each offset is a position in the current hunk of a longword to which the base of the target hunk is added. HUNK_RELOC32SHORT is the same with 16-bit words, padded to a longword boundary at the end (so offsets are limited to 64 KiB). See Fact:AmigaOS Hunk executable/behavior/Relocation blocks. Other IDs (RELRELOC16, DREL32 for base-relative data, ...) mostly occur in object files.
Symbols and debug
HUNK_SYMBOL: repeat { name (length in longs, then bytes zero padded); value } ended by a zero length. AmigaOS dislikes names above 124 characters (binutils MAX_NAME_SIZE). HUNK_DEBUG: a longword count of longwords, then an opaque payload: SAS/C writes base_offset, the tag LINE, a file name and (line, offset) pairs; other compilers use tag HEAD with DBGV01; GNU toolchains write a block starting with a ZMAGIC word for stabs (or a merged DWARF2 block). See Fact:AmigaOS Hunk executable/behavior/HUNK_SYMBOL and HUNK_DEBUG.
Object files
HUNK_UNIT (name), then per section HUNK_NAME, HUNK_CODE/DATA/BSS, relocation blocks and HUNK_EXT: each entry is one longword with the type in the top byte and the name length in longs in the low 24 bits, then the name, then a value (definitions: EXT_SYMB 0, EXT_DEF 1, EXT_ABS 2, EXT_RES 3) or a reference list (EXT_ABSREF32 129, EXT_ABSCOMMON 130, EXT_RELREF16 131, EXT_RELREF8 132, EXT_DEXT32/16/8 133-135, EXT_RELREF32 136, EXT_RELCOMMON 137, EXT_ABSREF16 138, EXT_ABSREF8 139; vbcc adds 208-210, PowerPC 229). See Fact:AmigaOS Hunk executable/enum/HUNK_EXT subtypes.
Overlays
An overlay executable has HUNK_OVERLAY after the root hunks: a longword count and then that many longwords of overlay table (read by the overlay manager), followed by the overlay hunks; HUNK_BREAK has no payload (amitools reads nothing after its ID); Unverified: it ends one overlay level. amitools treats both generically. GNU binutils only accepts load files whose last hunk number equals table size - 1 and reports "Overlay loadfiles are not supported". Unverified: the exact layout of the overlay table and how the header's first/last hunk numbers describe the overlay root.
Related
Platform:Amiga, Format:Amiga FD file, Technique:Executable packing. Amiga ELF (AmigaOS 4 / MorphOS PowerPC) is a normal ELF32 big-endian PowerPC file. Unverified: no source for the AmigaOS 4 / MorphOS ELF conventions was read in this round.
Code & repositories
- https://github.com/AmigaPorts/binutils-gdb @
e9ab8a4a62fc6fc6b486ff77040cafe00229c847· license: GPL-3.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
Amiga port of GNU binutils (branch amiga, commit e9ab8a4): bfd/amigaos.c reads and writes Hunk load and object files, bfd/libamiga.h holds the HUNK_* and EXT_* numbers and memory flag bits.
Tested on: source read, not run: source reading only · checked 2026-10-19 - https://github.com/cnvogelg/amitools @
3b57f2052ee76c28bbc5e4256227f62dca7b1c9f· license: unknown
amitools (Python): amitools/binfmt/hunk parses every Hunk block type, amitools/data/fd holds the NDK .fd files, amitools/vamos/libstructs the exec structures.
Tested on: source read, not run: source reading only · checked 2026-10-19