* EXECUTABLE FILE STRUCTURE
***************************

OFFSET  SIZE    DESCRIPTION
------  ----    -----------
$00     WORD    $601A - MAGIC WORD TO MAKE IT EXECUTABLE
$02     LONG    SIZE OF TEXT SEGMENT
$06     LONG    SIZE OF DATA SEGMENT
$0A     LONG    SIZE OF BSS  SEGMENT
$0E     LONG    SIZE OF SYMBOL TABLE
$12     LONG    RESERVED
$16     LONG    PRGFLAGS was reserved before GEMDOS 0.15
$1A     WORD    ABSFLAG  was reserved before GEMDOS 0.15
$1C             TEXT SEGMENT
$1C+($02)               DATA SEGMENT
$1C+($02)+($06)         OPTIONAL SYMBOL TABLE
$1C+($02)+($06)+($0E)   FIXUP OFFSET
                OPTIONAL FIXUP RECORDS (FIXUP OFFSET >0)
                 FIXUP RECORDS ENDS WITH ZERO BYTE

        PRGFLAGS
        ========
Bit 0   If set, Zero only the programs BSS
        If Clear, Zero all memory from end of program to stack start
Bit 1   If Set, Load into Alternate (Fast) RAM if possible
        If Clear, Load into normal RAM only.
Bit 2   If Set, Malloc will try to use Alternative (Fast) RAM
        If Clear, Malloc will only use normal RAM

DO NOT USE ALTERNATIVE  RAM  FOR  ANYTHING  THAT  HAS  SCREENS  IN OR FOR
ANYTHING
THAT USES DMA IN THAT MEMORY (e.g. STE Sound)

Bits 28-31      Used with Pexec() modes 0,3
        mode 7 has you passing PRGFLAGS to child as 2nd argument
        i.e. does not use its own PRGFLAGS
        see PEXEC.TXT

STANDARD SYMBOL TABLE consists of a number of records of the format:
---------------------
symbol_name     8 BYTES
symbol_type     WORD
symbol_value    LONG

SYMBOL TYPEs are defined as follows:
Defined         $8000
Equated         $4000
Global          $2000
Equated Register        $1000
External Reference      $800
Data Based Relocatable  $400
Text Based Relocatable  $200
BSS Based Relocatable   $100

NOTE:
    Symbol tables are free format and may differ from above.
    Alcyon use Alcyon Format symbols (as above)
    Mark Williams 2 use an empty segment  and put symbols after the fixup
info
    Mark Williams 3 put id  header  and  debug  info into symbol table as
well

FIXUP OFFSET IS OFFSET OF FIRST LONGWORD THAT NEEDS ALTERING.
IF ABSFLAG>0 and/OR FIXUP OFFSET=0 THEN NO FIXUP TABLE
It is altered by adding the text segment start address to each longword.
OPTIONAL FIXUP RECORDS consist of bytes:
            0 marks the end of the fixup information
            1 add 254 to offset and get next offset byte
        2-254 add to offset and fix longword at that address
        NB:   odd bytes should not be used as all longwords
              should start on even boundary.

HOW TO RELOCATE A FILE LOADED INTO MEMORY!
==========================================
* need to clear BSS segment and make enough room etc.
relocate        move.l  #file_addr,a2   ;start of file to relocate
        cmp.w   #$601a,(a2)     ;magic number - executable
        bne     rel_fail        ;otherwise not
        lea     $1c(a2),a1      ;start of text segment
        move.l  a1,d1
        move.l  a1,a0
        add.l   2(a2),a1        ;add text size
        add.l   6(a2),a1        ;add data size
        add.l   $a(a2),a1       ;add symbol size
        clr.l   d0      ;zero if o.k.
        tst.l   (a1)    ;fixup offset null?
        beq     rel_end ;finished fixup!
        add.l   (a1)+,a0        ;first fixup pointer
rel_add add.l   d1,(a0) ;fixup long
rel_lp1 move.b  (a1)+,d0
        beq     rel_end ;zero marks finish
        cmp.b   #1,d0
        bne     add_ptr
        add.w   #$00fe,a0       ;add 254 to pointer if 1
        bra     rel_lp1
add_ptr add.w   d0,a0   ;add offset
        bra     rel_add
rel_fail        move.l  #-1,d0  ;fail
rel_end rts             ;d0=already at zero if o.k.

