The fields
The header is 28 bytes, big-endian. Its first word is a BRA.S that jumps over the header to the first instruction of the text, so the file could in principle be run as it is.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | word | Branch | $601A: the magic. A program whose first word is anything else is not a GEMDOS executable. |
| 2 | long | Text size | The length of the text segment (the code). |
| 6 | long | Data size | The length of the data segment, which follows the text. |
| 10 | long | BSS size | The length of the BSS: zeroed memory the loader adds after the data. It is not in the file. |
| 14 | long | Symbol table size | The length of the symbol table, 0 if there is none. |
| 18 | long | Reserved | Should be 0; Pure C needs it to be 0. |
| 22 | long | Program flags | See below. |
| 26 | word | ABSFLAG | 0 means a relocation table follows the symbols. No other value is defined by the source read. |
The file then holds the text, the data, the symbol table and the relocation table, in that order; the sizes in the header give the length of each. The tests the explorer uses to
recognise a program: the first word is $601A, the text and data are not both empty, the header, text, data and symbol table fit in the file, and when ABSFLAG is 0 the
file has either nothing or at least four bytes after the symbol table for the relocation table.
Program flags
| Bits | Meaning |
|---|---|
| 0 | Fastload: the stack is not cleared, only the BSS is initialised. |
| 1 | The program may be loaded into the faster alternate RAM (TT-RAM). |
| 2 | Malloc may allocate from alternate RAM. |
| 3 | Reserved (used for the shared library). |
| 4 to 7 | Memory protection: 0 private (only the process and the system may use the memory), 1 global (unprotected), 2 super (accessible to processes in supervisor mode), 3 read-only (anyone may read; only the owner and the system may write). |
| 8 to 11 | Reserved. |
| 12 | Shared text: the text segment may be shared. Only for a program that makes no absolute accesses to its data or BSS. |
| 13 to 27 | Reserved. |
| 28 to 31 | The most alternate RAM the program may use, in steps of 128 KB (sixteen values, 128 KB to 2 MB). The explorer shows the value as (bits + 1) × 128 KB. |
The source calls bit 1 “alternate RAM”, not TT-RAM by name; on a TT and Falcon that is the faster memory outside the ST’s 14 MB.
Not described
Known, not yet covered
- Reference: the table rests on the FreeMiNT TOS documentation (
gemdos_programs.html), read through a summary. The MiNT extended header (the string “MiNT” at offset 22 in the GNU linker’s output, with a 256-byte header) is not described, and neither is the 4-bit alternate RAM limit’s exact units on each machine. - Viewer: every field is shown with its decoded meaning; the reserved bits are not flagged when they are set.
Links
Reference
- GEMDOS programs – FreeMiNT TOS documentation: the header and the flags
- prg-mint.c – BFD code for the MiNT program format: header and symbol constants