Amiga Hunk
(→Structure) |
(→Structure) |
||
Line 12: | Line 12: | ||
== Structure == | == Structure == | ||
− | The format begins with a fixed header, followed by a series of ''hunks'' which can | + | The loadable format begins with a fixed header, followed by a series of ''hunks''. each one of which is considered an independent ''segment'' by AmigaDOS. These hunks can either be code, data, or uninitialised memory (BSS). |
− | 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 themselves can contain optional ''blocks'', including code relocations and debug symbols. |
+ | |||
+ | 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'' blocks 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 <tt>OpenLibrary</tt>, 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. | Amiga programs do their own dynamic linking with OS functions such as <tt>OpenLibrary</tt>, 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. |
Revision as of 13:09, 10 May 2018
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 loadable format begins with a fixed header, followed by a series of hunks. each one of which is considered an independent segment by AmigaDOS. These hunks can either be code, data, or uninitialised memory (BSS).
Hunks themselves can contain optional blocks, including code relocations and debug symbols.
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 blocks 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