Overview

The Amiga executable file format.

Files

There are two different types of files, load files and object files.

Hunk file header blocks

Load file

Object file

Library file

HUNK_HEADER block.

X

HUNK_UNIT block.

X

X

As of v31 of dos.library, note that any hunk blocks with ID values higher than HUNK_ABSRELOC16 (the highest value handled by it) are processed as HUNK_DEBUG blocks. An exception to this are blocks with IDs that have bit 29 set, if this is the case, loading fails.

Blocks

Files are composed of hunks, and hunks in turn are composed of blocks.

Block

Load file

Object file

Initial hunk block.

X

X

Relocatable block.

X

X

Relocation information block.

X

X

External symbol information block.

X

Symbol table block.

X

X

Debug block.

X

X

End block.

X

X

Note that with the exception of the first hunk, HUNK_HEADER, only the lower 29 bits of the leading ID are used.

File header blocks

HUNK_HEADER [0x3F3]

The hunk file header block used for load (executable) files.

Datatype

Label

Description

strings

A number of resident library names. This is simply one or more strings, one after the other. The last string in the list, which may also be the first, will simply be a zero size potentially indicating an empty list. Note: This is expected to be an empty list for load files, otherwise the file loading will error with ERROR_BAD_HUNK.

HUNK_DATA [0x3EA]

Notes

Data hunks have been observed with trailing ds.width variables present, but not contributing to the local hunk length. Presumably the OS loader takes this into account, allocating the extra space based on the load file header.

HUNK_BSS [0x3EB]

Datatype

Label

Description

uint32

The number of longwords of zeroed memory to allocate.

Relocation is not done within the block defined by this hunk, so it will not be followed by a reloc32 hunk.

Additional hunk blocks

HUNK_RELOC32 [0x3EC]

Datatype

Label

Description

uint32

N

The number of offsets for a given hunk. If this value is zero, then it indicates the immediate end of this block.

uint32

The number of the hunk the offsets are to point into.

uint32 * N

Offsets in the current CODE or DATA hunk to relocate.

A reloc32 block describes how the current hunk's data should be modified so that the addresses within it refer to the correct locations. This is done by adding the base address of the target hunk associated with each of the longword offsets.

HUNK_RELOC32SHORT [0x3FC]

The number of offsets for a given hunk. If this value is zero, then it indicates the immediate end of this block.

uint16

The number of the hunk the offsets are to point into.

uint16 * N

Offsets in the current CODE or DATA hunk to relocate.

A reloc32short block describes how the current hunk's data should be modified so that the addresses within it refer to the correct locations. This is done by adding the base address of the target hunk associated with each of the word-sized offsets.

HUNK_DEBUG [0x3F1]

The number of longwords following in the given hunk. If this value is zero, then it indicates the immediate end of this block.

AmigaDOS expects only that this hunk specify the number of longwords N which make up this hunk. The actual contents of the remaining hunk depend on the application which created it.

"HCLN" - Devpac

When the Devpac line debug option is set to "compressed", the Hisoft Compressed Line Numbers (HCLN) format is used.

Datatype

Label

Description

uint32

N

The number of longwords following in the given hunk. If this value is zero, then it indicates the immediate end of this block.

uint32

The base offset within the source file.

char[4]

"HCLN"

string

The source file name.

uint8[M]

The table of line offsets within the local code, data or bss section.

The following implementation works for basic situations. It is likely that there are variations on the compression scheme that are not yet covered, like the case where there are more lines between two lines of code than can be indicated in a byte.

Describing the packed line data results in psuedo-code, so it is best to consult the implementation.

"HEAD" - Devpac

This is output by Devpac when a line debug option other than "None" is specified. While it differs when a debug symbol option other than "None" is also specified, it does not appear without the selection of a line debug option.

Datatype

Label

Description

uint32

N

The number of longwords following in the given hunk. If this value is zero, then it indicates the immediate end of this block.

uint32

The base offset within the source file.

char[4]

"HEAD"

char[8]

"DBGV01 "

uint8[M]

Unknown.

Values of the unknown data for different selected options:

Options

Hunk Value

Line Debug="Standard", Debug Symbols="None"

0000000000000000000000010000000000000000aeafb0b1

Line Debug="Compressed", Debug Symbols="None"

0000000000000000000000010000000000000000aeafb0b1

Line Debug="Compressed", Debug Symbols="All"

000000000000000000000001000000000000000100000060b2b3b4b5

Line Debug="Compressed", Debug Symbols="Exports"

000000000000000000000001000000000000000100000060b2b3b4b5

"LINE" - Generic debug hunk format

This is the output of the SAS C debug=line option and is a simple index of which offset in the local code, data or bss section maps to which line within the given source file name. It is also supported by Basm, Dice C, Devpac, Powervisor and other programming tools.

Datatype

Label

Description

uint32

N

The number of longwords following in the given hunk. If this value is zero, then it indicates the immediate end of this block.

uint32

The base offset within the source file.

char[4]

"LINE"

string

The source file name.

line_info[M]

The table of line offsets within the local code, data or bss section.

The structure of line_info is:

Datatype

Label

Description

uint32

Line number.

uint32

Offset of line from base offset.

M = ((N - 3) - number_of_string_longwords) / 2. Note that number_of_string_longwords is the first uint32 of the source file name entry. The 3 is accounted for by the base offset unint32, the four characters of the ID and the string length uint32 mentioned in the previous sentence.