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 |
| 208, 209, 210 | EXT_DEXT32COMMON, EXT_DEXT16COMMON, EXT_DEXT8COMMON | a common size, then a count and offsets (vbcc’s data-relative common symbols; named in vlink’s amigahunks.h as “vbcc extensions”, and skipped by its block reader like the other common types) |
| 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, the amitools constants and vlink’s amigahunks.h (all three agree; the AROS dos/doshunks.h has the same list without EXT_RES, 208 to 210 and 229). 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 |
The other tags, as the amiga-dev wiki describes them (all begin with the count of longs N, a base offset and the four letters; none of these layouts is decoded by the viewer):
HCLN(Devpac, “Hisoft Compressed Line Numbers”): base offset,HCLN, the source file name (a count of longs and the text), then packed line data: a long with the number of lines, then for each line two numbers, the increase of the line number and the increase of the offset (starting from the base offset). A number is one byte; a byte 0 is followed by a word, and a word 0 by a long. The table is padded to a long. The wiki warns that other variations of the compression may exist.HEAD(Devpac, when a line-debug option is selected): base offset,HEAD, the eight charactersDBGV01plus padding, then data whose meaning the wiki lists as unknown, with sample values for four option settings. The realHEADblock in the Thanks program of the test files has N = 12: base offset 1,HEAD,DBGV01followed by two zero bytes (the wiki prints a space where this file has zeros), then eight longs.ODEFandSDEF(Basm, “Barfly full source debug information”, option -od+): the wiki gives N as always 3, thenODEF, a count of line entries (a word 0, a long offset in the joined source text and a long offset in the hunk), padding to a long,SDEF, the number of source bytes, a long 0, a word$FFFF, the source text, padding and a long 0. The wiki’s count N and its own reader code do not agree (the reader reads past three longs), and no real file with this block was found here, so this layout is unverified.OPTS(SAS/C 6.5 object files such aslibinit.o): N is always 3: a long 0,OPTS, a long holding the recorded options (meaning unknown; the wiki says how to make the block is unknown too).ZMAGIC(GNU tools of adtools): the count N, the longZMAGIC= 0413 (267), the size of the symbol table in bytes, the size of the string table in bytes, then the symbol table and the string table, “supposedly a.out format”.
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 unknown parts of
HEADandOPTS(undocumented anywhere that was found), theODEF/SDEFlayout beyond the wiki’s own inconsistent description, whetherHCLNhas more compression variants, the byte layout ofSRC6(a tag on none of the sources’ lists), 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