Amiga Hunk
(→Identification) |
|||
Line 10: | Line 10: | ||
Object code and link libraries begin with the magic ID {{magic|00 00 03 E7}}. These files have to be combined into a loadable file using a linker to get an executable program. | Object code and link libraries begin with the magic ID {{magic|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. Once loaded, they cannot be relocated again, only unloaded and reloaded. | ||
+ | |||
+ | 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 at loading the program, and programs have "import" and "export" symbols. Amiga programs do not have to list any symbols or name any other libraries, even if they depend on them to run. Amiga programs can include a list of their own "symbols" for use by debuggers, but aren't required to do so. | ||
== Format specification == | == Format specification == |
Revision as of 12:49, 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 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. Once loaded, they cannot be relocated again, only unloaded and reloaded.
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 at loading the program, and programs have "import" and "export" symbols. Amiga programs do not have to list any symbols or name any other libraries, even if they depend on them to run. Amiga programs can include a list of their own "symbols" for use by debuggers, but aren't required to do so.
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