Introduction
An assembler or compiler writes an object file; a linker joins object files, and the units of link libraries, into a load file. The blocks are the ones in a load file, with a few
more: a unit has a name, its hunks have names, and HUNK_EXT lists the symbols it defines and the ones it needs. There is no HUNK_HEADER. A load file that contains
HUNK_UNIT, HUNK_EXT, HUNK_LIB or HUNK_INDEX is refused by the loader (amiga-dev wiki).
HUNK_UNIT and HUNK_NAME
HUNK_UNIT ($3E7) starts a unit: a count of longs, then the unit’s name. The unit’s hunks follow, numbered from 0 within the unit. A file can hold several units one after another.
HUNK_NAME ($3E8), with the same layout, comes before a hunk’s own block and gives that hunk its section name. In the object file made by vasm for the tests, the one unit is named demo.s (the source file) and its
four hunks are named code, datahunk, chipdata and variables, of 76, 40, 8 and 68 bytes, the sizes vasm printed.
Each hunk is: its HUNK_NAME, the code, data or BSS block, the relocation blocks, HUNK_EXT, HUNK_SYMBOL, HUNK_DEBUG and
HUNK_END. The memory type of a hunk is in the top bits of its block id (see the header page); the chip-memory section in the test file shows as chip.
The viewer lists the external symbols per hunk (the types), and a name defined with EXT_DEF becomes a label at its offset in the disassembly.
HUNK_LIB
HUNK_LIB ($3FA) starts a link library: a size long, then the library’s units, each as an object file starting with HUNK_UNIT, and finally a
HUNK_INDEX. The size is the amount of unit data the block covers (the amitools reader uses it to know which hunks belong to the library); the viewer reads the units in order and
does not depend on it. Whether the size counts longs or bytes is not stated in the sources read, and no real library file was available, so the viewer shows the number as stored.
HUNK_INDEX
The index lets a linker find a symbol without reading every unit. It is a size in longs, then the body in words, as the amitools reader reads it:
| Part | Layout |
|---|---|
| String table | a word with its size in bytes, then those bytes; names are given as offsets into it |
| Per unit | the offset of its name, the number of its first hunk and its hunk count (three words) |
| Per hunk of the unit | the offset of its name, its size and a type word (three words); a count of references and that many name offsets; a count of definitions and, for each, a name offset, a value and a type (three words) |
The viewer lists, for every unit and hunk, the symbols the hunk defines. This layout rests on one summary of one reader; it was checked on a built index only, because there is no assembler or archiver on this machine that writes a library (vasm writes object files and executables only), so it is the least certain part of the format here.
Not described
Known, not yet covered
- Reference: the unit of the
HUNK_LIBsize, the type words of an index, how a linker resolves references (the order of units, common symbols), the data-relative blocks of the small-data model, and the PowerPC object-file extensions. - Viewer: object files and libraries were checked on assembler output and built files, not on real third-party objects or libraries; the index is listed but not used to look up anything.
Links
Reference
- amitools hunk reader – HUNK_UNIT, HUNK_EXT, HUNK_LIB and HUNK_INDEX as it reads them
- vasm –
output_hunk.cwrites the object form - Hunk file format – amiga-dev wiki: which blocks a load file may not contain