Amiga Hunk
The Amiga Hunk format is the native file format of AmigaOS for loadable files (including all executable files), object code and link libraries.
Identification
Loadable files begin with the magic ID 00 00 03 F3
. "Loadable" includes all directly executable files, as well as shared libraries, device drivers, filesystem handlers, datatypes and other "plugins".
Object code and link libraries begin with the magic ID 00 00 03 E7
. These files have to be combined into a loadable file using a linker to get an executable program.
Structure
The format begins with a fixed header, followed by a series of hunks which can contain different types of data, such as code, data, uninitialised memory reservations (BSS), code relocations, debug symbols and so on.
All Amiga programs share the same address space and are loaded to wherever there is free memory. They cannot be loaded to specific absolute addresses. This means code must either be written in a position-independent fashion, or it can use relocation hunks to specify where the loader has to fix up absolute address references to other parts of the code.
Amiga programs do their own dynamic linking with OS functions such as OpenLibrary, which loads and returns a pointer to a shared library, whose functions can then be executed by jumping to specific offsets from the pointer. This is unlike Windows and UNIX where the loader is expected to fetch and link in other libraries while loading the program.
Format specification
- Commodore-Amiga Inc. "Amiga Binary File Structure" The AmigaDOS Manual, Bantam Books, 1986, ISBN 0-553-34294-0, p243-262
- Ralph Babel. "The Format of Load and Object Modules" The Amiga Guru Book, self-published, 1993, p657-682
- http://amiga-dev.wikidot.com/file-format:hunk