home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI09.ARJ / ictari.09 / MISC / EXEC_INF / EXEC_STR.TXT next >
Text File  |  1994-04-14  |  4KB  |  101 lines

  1. * EXECUTABLE FILE STRUCTURE
  2. ***************************
  3.  
  4. OFFSET  SIZE    DESCRIPTION
  5. ------  ----    -----------
  6. $00     WORD    $601A - MAGIC WORD TO MAKE IT EXECUTABLE
  7. $02     LONG    SIZE OF TEXT SEGMENT
  8. $06     LONG    SIZE OF DATA SEGMENT
  9. $0A     LONG    SIZE OF BSS  SEGMENT
  10. $0E     LONG    SIZE OF SYMBOL TABLE
  11. $12     LONG    RESERVED
  12. $16     LONG    PRGFLAGS was reserved before GEMDOS 0.15
  13. $1A     WORD    ABSFLAG  was reserved before GEMDOS 0.15
  14. $1C             TEXT SEGMENT
  15. $1C+($02)               DATA SEGMENT
  16. $1C+($02)+($06)         OPTIONAL SYMBOL TABLE
  17. $1C+($02)+($06)+($0E)   FIXUP OFFSET
  18.                 OPTIONAL FIXUP RECORDS (FIXUP OFFSET >0)
  19.                  FIXUP RECORDS ENDS WITH ZERO BYTE
  20.  
  21.         PRGFLAGS
  22.         ========
  23. Bit 0   If set, Zero only the programs BSS
  24.         If Clear, Zero all memory from end of program to stack start
  25. Bit 1   If Set, Load into Alternate (Fast) RAM if possible
  26.         If Clear, Load into normal RAM only.
  27. Bit 2   If Set, Malloc will try to use Alternative (Fast) RAM
  28.         If Clear, Malloc will only use normal RAM
  29.  
  30. DO NOT USE ALTERNATIVE  RAM  FOR  ANYTHING  THAT  HAS  SCREENS  IN OR FOR
  31. ANYTHING
  32. THAT USES DMA IN THAT MEMORY (e.g. STE Sound)
  33.  
  34. Bits 28-31      Used with Pexec() modes 0,3
  35.         mode 7 has you passing PRGFLAGS to child as 2nd argument
  36.         i.e. does not use its own PRGFLAGS
  37.         see PEXEC.TXT
  38.  
  39. STANDARD SYMBOL TABLE consists of a number of records of the format:
  40. ---------------------
  41. symbol_name     8 BYTES
  42. symbol_type     WORD
  43. symbol_value    LONG
  44.  
  45. SYMBOL TYPEs are defined as follows:
  46. Defined         $8000
  47. Equated         $4000
  48. Global          $2000
  49. Equated Register        $1000
  50. External Reference      $800
  51. Data Based Relocatable  $400
  52. Text Based Relocatable  $200
  53. BSS Based Relocatable   $100
  54.  
  55. NOTE:
  56.     Symbol tables are free format and may differ from above.
  57.     Alcyon use Alcyon Format symbols (as above)
  58.     Mark Williams 2 use an empty segment  and put symbols after the fixup
  59. info
  60.     Mark Williams 3 put id  header  and  debug  info into symbol table as
  61. well
  62.  
  63. FIXUP OFFSET IS OFFSET OF FIRST LONGWORD THAT NEEDS ALTERING.
  64. IF ABSFLAG>0 and/OR FIXUP OFFSET=0 THEN NO FIXUP TABLE
  65. It is altered by adding the text segment start address to each longword.
  66. OPTIONAL FIXUP RECORDS consist of bytes:
  67.             0 marks the end of the fixup information
  68.             1 add 254 to offset and get next offset byte
  69.         2-254 add to offset and fix longword at that address
  70.         NB:   odd bytes should not be used as all longwords
  71.               should start on even boundary.
  72.  
  73. HOW TO RELOCATE A FILE LOADED INTO MEMORY!
  74. ==========================================
  75. * need to clear BSS segment and make enough room etc.
  76. relocate        move.l  #file_addr,a2   ;start of file to relocate
  77.         cmp.w   #$601a,(a2)     ;magic number - executable
  78.         bne     rel_fail        ;otherwise not
  79.         lea     $1c(a2),a1      ;start of text segment
  80.         move.l  a1,d1
  81.         move.l  a1,a0
  82.         add.l   2(a2),a1        ;add text size
  83.         add.l   6(a2),a1        ;add data size
  84.         add.l   $a(a2),a1       ;add symbol size
  85.         clr.l   d0      ;zero if o.k.
  86.         tst.l   (a1)    ;fixup offset null?
  87.         beq     rel_end ;finished fixup!
  88.         add.l   (a1)+,a0        ;first fixup pointer
  89. rel_add add.l   d1,(a0) ;fixup long
  90. rel_lp1 move.b  (a1)+,d0
  91.         beq     rel_end ;zero marks finish
  92.         cmp.b   #1,d0
  93.         bne     add_ptr
  94.         add.w   #$00fe,a0       ;add 254 to pointer if 1
  95.         bra     rel_lp1
  96. add_ptr add.w   d0,a0   ;add offset
  97.         bra     rel_add
  98. rel_fail        move.l  #-1,d0  ;fail
  99. rel_end rts             ;d0=already at zero if o.k.
  100.  
  101.