docs(amiga): complete AmigaOS 3.1/3.2 developer reference — 172 files across 17 sections
Comprehensive technical documentation covering:
- Hardware: OCS/ECS/AGA custom chip registers, Copper & Blitter deep dives
- Boot sequence: cold boot through startup-sequence
- Binary format: HUNK executable spec, relocation, debug info
- Linking & ABI: .fd files, LVO tables, register calling conventions
- Exec kernel: tasks, interrupts, memory, signals, semaphores
- AmigaDOS: file I/O, FFS/OFS layout, CLI/Shell scripting
- Graphics: planar bitmaps, Copper programming, HAM/EHB modes
- Intuition: screens, windows, IDCMP, BOOPSI
- Devices: trackdisk, SCSI, serial, timer, audio, keyboard
- Libraries: utility, expansion, IFFParse, locale, ARexx
- Networking: bsdsocket API, SANA-II, TCP/IP stack comparison
- Toolchain: GCC, vasm/vlink, SAS/C, NDK, debugging
- Reverse engineering: IDA/Ghidra setup, compiler fingerprints, case studies
- CPU & MMU: 68040/060 emulation libs, PMMU, cache management
- Driver development: SANA-II, Picasso96/RTG, AHI audio
All files include breadcrumb navigation. No local paths or proprietary content.
2026-04-23 12:16:52 -04:00
|
|
|
[← Home](../README.md)
|
|
|
|
|
|
|
|
|
|
# Executable Loader & HUNK Format
|
|
|
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
|
|
|
|
|
This section covers the complete lifecycle of an AmigaOS executable:
|
|
|
|
|
|
|
|
|
|
1. **HUNK file format** — the binary container for all AmigaOS executables, libraries, and object files
|
|
|
|
|
2. **Loader pipeline** — how `dos.library` loads and relocates an executable into memory
|
|
|
|
|
3. **Object files** — how compilers produce relocatable object files for the linker
|
|
|
|
|
4. **Overlays** — how programs larger than available memory use the overlay system
|
|
|
|
|
|
|
|
|
|
## Contents
|
|
|
|
|
|
|
|
|
|
| File | Topic |
|
|
|
|
|
|---|---|
|
03/04: deep enrichment of loader/exec format and linking/libraries
Sections 03 and 04 augmented to bootcamp quality with targeted
enrichment based on content analysis (not just file size).
03_loader_and_exec_format:
- overlay_system.md: full rewrite — tree architecture diagram,
HUNK_OVERLAY binary format, overlay manager runtime internals,
worked binary example, linker support, modern alternatives
- hunk_relocation.md: full rewrite — visual before/after diagram,
patching algorithm with code, RELOC32SHORT and DREL32 formats,
PC-relative impact comparison table, self-referencing relocs,
error scenarios, Python reloc scanner tool
04_linking_and_libraries:
- library_structure.md: full rewrite — ASCII memory layout diagram,
JMP table encoding (why 6 bytes), MakeLibrary internals with both
function array formats, complete library creation example with
.fd file, checksum verification, lifecycle state diagram
- shared_libraries_runtime.md: full rewrite — OpenLibrary 4-step
resolution path, ramlib disk loader internals, disk search path,
version negotiation table (v33-v47), CloseLibrary/Expunge deep
dive, memory-low sweep, common pitfalls table
- register_conventions.md: full rewrite — FPU register map,
inter-library A6 save/restore pattern, small-data model with
__saveds keyword, varargs/TagItem pattern deep dive,
stack-based wrapper explanation, disassembly identification
Updated indexes:
- 03_loader_and_exec_format/README.md
- 04_linking_and_libraries/README.md
- Root README.md (sections 03 and 04)
2026-04-23 18:30:45 -04:00
|
|
|
| [hunk_format.md](hunk_format.md) | Complete HUNK binary specification — all 22 hunk type codes with wire format, memory flags, advisory bits |
|
|
|
|
|
| [hunk_ext_deep_dive.md](hunk_ext_deep_dive.md) | HUNK_EXT: exports (EXT_DEF), imports (EXT_REF32), commons, linker resolution |
|
|
|
|
|
| [hunk_relocation.md](hunk_relocation.md) | Relocation mechanics: visual before/after, patching algorithm, RELOC32/SHORT/DREL32, PC-relative impact |
|
|
|
|
|
| [hunk_debug_info.md](hunk_debug_info.md) | HUNK_SYMBOL and HUNK_DEBUG: stabs format (SAS/C, GCC), debugger consumption, stripping |
|
|
|
|
|
| [exe_load_pipeline.md](exe_load_pipeline.md) | LoadSeg → AllocMem → relocation → segment chain → CreateProc → entry point |
|
|
|
|
|
| [object_file_format.md](object_file_format.md) | Compiler object files (HUNK_UNIT), multi-section layout, HUNK_LIB archives, linker operation |
|
|
|
|
|
| [overlay_system.md](overlay_system.md) | HUNK_OVERLAY: tree architecture, runtime overlay manager, worked binary example, modern alternatives |
|
03: new article — exe_crunchers.md (executable packers deep dive)
New comprehensive article on Amiga executable crunchers covering:
- Architecture: how crunched files remain valid HUNK executables
- Major crunchers: PowerPacker, Imploder, Shrinkler, ByteKiller,
Titanics, CrunchMania, PackFire, XPK framework
- PP20 format: efficiency table, decrunch info, decrunch colours
- Shrinkler internals: 1536-context adaptive probability model,
range coder, parity context flag, stack-based context table,
actual 68000 decompressor source from GitHub
- LZ77/LZSS vs context-modelling+range-coding algorithms
- Relocation handling: 3 strategies (compressed relocs, delta
table, merged single-hunk)
- Memory layout diagrams: before/during/after decompression
- Detection: magic signatures table, fake header warning,
Python scanner script
- Tools: xfdmaster modular architecture, Ancient C++ library,
debugger-based extraction (last resort)
- FPGA/emulation impact: timing, self-modifying code, cache
Based on web research: verified PP20 format spec, Shrinkler
source (askeksa/Shrinkler), Ancient library (temisu/ancient),
xfdmaster slave module architecture.
Updated indexes: 03/README.md, root README.md
2026-04-23 18:41:07 -04:00
|
|
|
| [**exe_crunchers.md**](exe_crunchers.md) | **Executable packers: PowerPacker/Imploder/Shrinkler, decrunch stubs, compression algorithms, detection** |
|
docs(amiga): complete AmigaOS 3.1/3.2 developer reference — 172 files across 17 sections
Comprehensive technical documentation covering:
- Hardware: OCS/ECS/AGA custom chip registers, Copper & Blitter deep dives
- Boot sequence: cold boot through startup-sequence
- Binary format: HUNK executable spec, relocation, debug info
- Linking & ABI: .fd files, LVO tables, register calling conventions
- Exec kernel: tasks, interrupts, memory, signals, semaphores
- AmigaDOS: file I/O, FFS/OFS layout, CLI/Shell scripting
- Graphics: planar bitmaps, Copper programming, HAM/EHB modes
- Intuition: screens, windows, IDCMP, BOOPSI
- Devices: trackdisk, SCSI, serial, timer, audio, keyboard
- Libraries: utility, expansion, IFFParse, locale, ARexx
- Networking: bsdsocket API, SANA-II, TCP/IP stack comparison
- Toolchain: GCC, vasm/vlink, SAS/C, NDK, debugging
- Reverse engineering: IDA/Ghidra setup, compiler fingerprints, case studies
- CPU & MMU: 68040/060 emulation libs, PMMU, cache management
- Driver development: SANA-II, Picasso96/RTG, AHI audio
All files include breadcrumb navigation. No local paths or proprietary content.
2026-04-23 12:16:52 -04:00
|
|
|
|
|
|
|
|
## Why HUNK?
|
|
|
|
|
|
|
|
|
|
HUNK is the native AmigaOS executable format, used from AmigaOS 1.0 through 3.x. It predates ELF/COFF and has these key properties:
|
|
|
|
|
|
|
|
|
|
- **Segmented**: separate code, data, and BSS hunks with independent memory allocation
|
|
|
|
|
- **Relocatable**: all absolute references are patched at load time (no ASLR; base address changes each run)
|
|
|
|
|
- **Typed memory**: each hunk can request `CHIP` or `FAST` memory independently
|
|
|
|
|
- **Symbol-complete**: optional HUNK_SYMBOL and HUNK_DEBUG hunks carry debugging information
|
|
|
|
|
|
|
|
|
|
## Key Concepts
|
|
|
|
|
|
|
|
|
|
| Term | Meaning |
|
|
|
|
|
|---|---|
|
|
|
|
|
| **Hunk** | One contiguous block in the binary (code, data, BSS, etc.) |
|
|
|
|
|
| **Segment** | A loaded hunk at runtime — a `BPTR`-linked list |
|
|
|
|
|
| **Segment list** | Chain of loaded hunks returned by `LoadSeg()` |
|
|
|
|
|
| **BPTR** | Amiga byte pointer — 32-bit value right-shifted by 2 (`ptr >> 2`) |
|
|
|
|
|
| **Relocation** | Patching absolute addresses based on actual load address |
|
|
|
|
|
| **LVO** | Library Vector Offset — negative offset from library base |
|
|
|
|
|
|
|
|
|
|
## References
|
|
|
|
|
|
|
|
|
|
- ADCD 2.1: `Includes_and_Autodocs_3._guide/` — dos.library LoadSeg autodoc
|
|
|
|
|
- NDK39: `dos/dos.h` — BPTR, segment handling macros
|
|
|
|
|
- *Amiga ROM Kernel Reference Manual: Libraries* — AmigaDOS chapter
|
|
|
|
|
- http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node0150.html
|