Introduction
Three blocks carry names and line numbers. They sit after a hunk’s contents and relocations, before its HUNK_END. None of them changes what the program does; a loader
skips them. HUNK_SYMBOL names places in the hunk, HUNK_EXT (object files) lists what a unit defines and what it needs from others, and
HUNK_DEBUG holds whatever a debugger wants, most often line numbers.
HUNK_SYMBOL
Pairs of a name and a value, then a zero long. A name is a count of longs followed by that many longs of text, padded with zero bytes; the value is the long after it, an offset from the start of the hunk. A name count of 0 ends the block. The viewer lists the symbols and uses them as labels in the disassembly: the row at that address carries the name, and a jump or reference to it shows the name. In the real files tested 1,655 symbols occur in the HUNK_SYMBOL blocks of executables; almost every Workbench file is stripped.
HUNK_EXT
A list of entries and a zero long. An entry starts with a long: the symbol type in the top byte and the length of the name, in longs, in the low 24 bits. The name follows, and then, by type:
| Type | Name | What follows the name |
|---|---|---|
| 0 | EXT_SYMB | a value (the form HUNK_SYMBOL uses) |
| 1 | EXT_DEF | a value: a symbol this unit defines, as an offset in the hunk |
| 2 | EXT_ABS | a value: an absolute symbol |
| 3 | EXT_RES | a value (a resident symbol; named by the amitools reader only) |
129 ($81) | EXT_ABSREF32 | a count and that many offsets in the hunk: places that need the symbol’s 32-bit address |
| 130 | EXT_ABSCOMMON | a common size, then a count and offsets (a common symbol, absolute) |
| 131 | EXT_RELREF16 | a count and offsets: 16-bit relative references |
| 132 | EXT_RELREF8 | a count and offsets: 8-bit relative references |
| 133, 134, 135 | EXT_DEXT32, 16, 8 | a count and offsets: data-relative references |
| 136 | EXT_RELREF32 | a count and offsets: 32-bit relative references |
| 137 | EXT_RELCOMMON | a common size, then a count and offsets |
| 138, 139 | EXT_ABSREF16, EXT_ABSREF8 | a count and offsets: 16-bit and 8-bit absolute references |
| 229 | EXT_RELREF26 | a count and offsets: 26-bit relative references (PowerPC branches, extended hunk format) |
The numbers are in the vasm assembler’s header file and in the amitools constants. The vasm writer always writes the count of offsets, also after a common size, and the viewer reads it the same way (the amitools reader treats a count of 0 in a reference as 1; the viewer takes the count as written). A type not in the table stops the block and is reported.
HUNK_DEBUG
A count of longs, then that many longs of data whose meaning depends on the tool. AmigaDOS needs only the count. The data usually begins with a base offset and a four-letter tag. The tags the sources name:
| Tag | Written by | Viewer |
|---|---|---|
LINE | SAS/C, Dice C, Basm, Devpac, vasm and others | decoded: file name and line table |
HCLN | Devpac (compressed line numbers) | named, with the file name; the packed table is not decoded |
HEAD | Devpac | named |
ODEF, SDEF | Basm | named |
OPTS | SAS/C | named |
ZMAGIC | GNU tools (a.out symbols and strings) | named |
A LINE block is: the count of longs N; a base offset; the four letters LINE; the source file name (a count of longs, then the text); then pairs of a line number and an offset
from the base, N − 3 − (name longs) longs in all. The vasm writer’s linedebug_hunk writes exactly this, and the real files agree: the loose Amiga files contain two LINE blocks (a library whose source file is lib.e, with 161 pairs, and a program whose source file is Thanks.c, with 192), next to a
HEAD block and a block tagged SRC6 that the viewer names without decoding (SRC6 is on none of the lists the sources give). The viewer shows a line table (hunk, file, line,
address) for every LINE block.
A HUNK_DEBUG may come before the first block of a hunk (one real program does this); the viewer keeps it with the hunk that follows.
Not described
Known, not yet covered
- Reference: the contents of the debug formats other than
LINE(their layouts are on the amiga-dev wiki; only the tag is read here), whatSRC6is, and EXT_RES’s use. - Viewer: line numbers are listed, not linked to the disassembly rows; symbol and debug data from a.out-style
ZMAGICblocks are not read.
Links
Reference
- Hunk file format – amiga-dev wiki: HUNK_SYMBOL and the debug formats HCLN, HEAD, LINE, ODEF, OPTS, ZMAGIC
- amitools hunk reader – EXT type numbers and entry layouts
- vasm –
output_hunk.cwrites HUNK_EXT, HUNK_SYMBOL and LINE blocks