Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (07/16/90)
Submitted-by: micke@slaka.sirius.se (Mikael Karlsson) Posting-number: Volume 90, Issue 212 Archive-name: rexx/dalf/part01 [ this was submitted with no documentation ...tad ] #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: dalf.rexx # Wrapped by tadguy@xanth on Sun Jul 15 18:46:27 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'dalf.rexx' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dalf.rexx'\" else echo shar: Extracting \"'dalf.rexx'\" \(10360 characters\) sed "s/^X//" >'dalf.rexx' <<'END_OF_FILE' X/************************************************\ X* dalf.rexx - Dumps Amiga Load Files. * X* C 1990 Mikael Karlsson (micke@slaka.sirius.se) * X\************************************************/ X Xparse arg file /* File to examine */ X Xsignal on break_c /* We want a nice clean break */ X Xpl. = "s" /* This is how to handle plurals the ince way */ Xpl.1 = "" X Xtemp = '00'x Xflagtext.temp = "" Xtemp = '40'x /* Bit 30 means 'Load to CHIPMEM' */ Xflagtext.temp = " (CHIP)" Xbits. = '00'x X Xtype. = "Unknown" X X/* These are the hunk types we know about (so far) */ X XHunk_unit = '03E7'x; type.Hunk_unit = "Hunk_unit " XHunk_name = '03E8'x; type.Hunk_name = "Hunk_name " XHunk_code = '03E9'x; type.Hunk_code = "Hunk_code " XHunk_data = '03EA'x; type.Hunk_data = "Hunk_data " XHunk_bss = '03EB'x; type.Hunk_bss = "Hunk_bss " XHunk_reloc32 = '03EC'x; type.Hunk_reloc32 = "Hunk_reloc32 " XHunk_reloc16 = '03ED'x; type.Hunk_reloc16 = "Hunk_reloc16 " XHunk_reloc8 = '03EE'x; type.Hunk_reloc8 = "Hunk_reloc8 " XHunk_ext = '03EF'x; type.Hunk_ext = "Hunk_ext " XHunk_symbol = '03F0'x; type.Hunk_symbol = "Hunk_symbol " XHunk_debug = '03F1'x; type.Hunk_debug = "Hunk_debug " XHunk_end = '03F2'x; type.Hunk_end = "Hunk_end " XHunk_header = '03F3'x; type.Hunk_header = "Hunk_header " XHunk_overlay = '03F5'x; type.Hunk_overlay = "Hunk_overlay " XHunk_break = '03F6'x; type.Hunk_break = "Hunk_break " XHunk_drel32 = '03F7'x; type.Hunk_drel32 = "Hunk_drel32 " XHunk_drel16 = '03F8'x; type.Hunk_drel16 = "Hunk_drel16 " XHunk_drel8 = '03F9'x; type.Hunk_drel8 = "Hunk_drel8 " XHunk_libhunk = '03FA'x; type.Hunk_libhunk = "Hunk_libhunk " XHunk_libindx = '03FB'x; type.Hunk_libindx = "Hunk_libindx " X X/* These are subtypes in Hunk_ext */ X XHunk_def = '01'x; type.Hunk_def = "Hunk_def " XHunk_abs = '02'x; type.Hunk_abs = "Hunk_abs " XHunk_res = '03'x; type.Hunk_res = "Hunk_res " XHunk_ext32 = '81'x; type.Hunk_ext32 = "Hunk_ext32 " XHunk_ext16 = '83'x; type.Hunk_ext16 = "Hunk_ext16 " XHunk_ext8 = '84'x; type.Hunk_ext8 = "Hunk_ext8 " XHunk_dext32 = '85'x; type.Hunk_dext32 = "Hunk_dext32 " XHunk_dext16 = '86'x; type.Hunk_dext16 = "Hunk_dext16 " XHunk_dext8 = '87'x; type.Hunk_dext8 = "Hunk_dext8 " X Xif ~open(lf, file, 'R') then do /* Open load file */ X say "Can't open" file X exit 10 Xend X Xindex = 0 Xsize. = 0 X Xloop: X type = readch(lf, 4) /* Read hunk type */ X if type == "" then do /* End of file */ X signal done X end X bits.index = bitor(bits.index, left(type, 1)) /* Check flag bits */ X type = right(type, 2) /* Remove flag bits */ X if type.type = "Unknown" then do X say "Unknown hunk type ("c2x(type)")" X exit 10 X end X id = type.type "("c2x(type)")" X signal value trim(type.type) /* Jump to hunk display routine */ X XHunk_header: X say id X dummy = c2d(readch(lf, 4)) /* What's this? */ X count = c2d(readch(lf, 4)) X low = c2d(readch(lf, 4)) X high = c2d(readch(lf, 4)) X say " "count "hunk"pl.count "("low "to" high")" X do i=low to high X size = readch(lf, 4) X bits.i = left(size, 1) X size.i = c2d(right(size, 3))*4 X bits = bits.i X say " Size hunk" i":" size.i "bytes" flagtext.bits X end X index = low X signal loop X XHunk_end: X say " "id X signal loop X XHunk_code: X size = readch(lf, 4) X bits = bitor(bits.index, left(size, 1)) X size = c2d(right(size, 3))*4 X temp = right(index, 2) X temp = temp":" id X temp = temp "("size "bytes)"flagtext.bits X say temp X do while size>32768 X data = readch(lf, 32768) X size = size-32768 X end X data = readch(lf, size) X index = index+1 X signal loop X XHunk_reloc32: XHunk_reloc16: XHunk_reloc8: X say " "id X count = c2d(readch(lf, 4)) X do while count~=0 X ref = c2d(readch(lf, 4)) X say " "count "item"pl.count "for hunk" ref X refs = readch(lf, count*4) X count = c2d(readch(lf, 4)) X end X signal loop X XHunk_ext: X say " "id X sym_type = readch(lf, 1) X sym_length = c2d(readch(lf, 3))*4 X do until sym_type == "00"x X symbol = strip(readch(lf, sym_length), 'T', '00'x) X select X when sym_type == hunk_def |, X sym_type == hunk_abs |, X sym_type == hunk_res then do X offset = strip(c2x(readch(lf, 4)), 'T', '00'x) X temp = " " type.sym_type X temp = temp left(symbol, 32)":" "0x"offset X say temp X end X when sym_type == hunk_ext32 |, X sym_type == hunk_ext16 |, X sym_type == hunk_ext8 |, X sym_type == hunk_dext32 |, X sym_type == hunk_dext16 |, X sym_type == hunk_dext8 then do X count = c2d(readch(lf, 4)) X refs = readch(lf, count*4) X temp = " " type.sym_type X temp = temp left(symbol, 32)":" X temp = temp right(count, 2) "item"pl.count X say temp X end X otherwise do X say " Unknown definition" X end X end X sym_type = readch(lf, 1) X sym_length = c2d(readch(lf, 3))*4 X end X signal loop X XHunk_drel32: XHunk_drel16: XHunk_drel8: X say " "id X count = c2d(readch(lf, 4)) X do while count~=0 X ref = c2d(readch(lf, 4)) X say " "count "item"pl.count "for hunk" ref X refs = readch(lf, count*4) X count = c2d(readch(lf, 4)) X end X signal loop X XHunk_data: X size = readch(lf, 4) X bits = bitor(bits.index, left(size, 1)) X size = c2d(right(size, 3))*4 X temp = right(index, 2) X temp = temp":" id X temp = temp "("size "bytes" X if size.index-size>0 then do X temp = temp"," size.index-size "BSS" X end X temp = temp")"flagtext.bits X say temp X data = readch(lf, size) X index = index+1 X signal loop X XHunk_bss: X size = readch(lf, 4) X bits = bitor(bits.index, left(size, 1)) X size = c2d(right(size, 3))*4 X temp = right(index, 2) X temp = temp":" id X temp = temp "("size "bytes)"flagtext.bits X say temp X index = index+1 X signal loop X XHunk_unit: XHunk_name: X say right(index, 2)":"id X size = c2d(readch(lf, 4))*4 X data = readch(lf, size) X say " " type.type":" data X index = index+1 X signal loop X XHunk_symbol: X say right(index, 2)":"id X size = c2d(readch(lf, 4))*4 X do while size~=0 X data = strip(readch(lf, size), 'T', '00'x) X say " " left(data, 32)":" c2x(readch(lf, 4)) X size = c2d(readch(lf, 4))*4 X end X signal loop X XHunk_libhunk: X size = readch(lf, 4) X bits = bitor(bits.index, left(size, 1)) X size = c2d(right(size, 3))*4 X say " "id "("size "bytes)"flagtext.bits X signal loop X XHunk_libindx: X size = c2d(readch(lf, 4))*4 X say " "id "("size "bytes)" X count = c2d(readch(lf, 2)) X say " " count "bytes in string block" X string = readch(lf, count) X do forever X nameoffset = c2d(readch(lf, 2)) X if nameoffset=0 then leave X parse value substr(string, nameoffset+1) with name "00"x . X say " PUNIT '"name"'" X unitoffset = c2d(readch(lf, 2)) X say " offset" unitoffset "longword"pl.unitoffset X hunkcount = c2d(readch(lf, 2)) X say " " hunkcount "hunk"pl.hunkcount X do for hunkcount X nameoffset = c2d(readch(lf, 2)) X parse value substr(string, nameoffset+1) with name "00"x . X hunksize = c2d(readch(lf, 2)) X hunktype = readch(lf, 2) X say " " type.hunktype "'"name"' of" hunksize "longword"pl.hunksize X refcount = c2d(readch(lf, 2)) X say " " refcount "ref"pl.refcount":" X do for refcount X nameoffset = c2d(readch(lf, 2)) X if substr(string, nameoffset+1, 1)="00"x then do X nameoffset = nameoffset+1 X temp = "16" X end X else do X temp = "32" X end X parse value substr(string, nameoffset+1) with name "00"x . X say " " temp"-bit ref '"name"'" X end X defcount = c2d(readch(lf, 2)) X say " " defcount "def"pl.defcount":" X do for defcount X nameoffset = c2d(readch(lf, 2)) X parse value substr(string, nameoffset+1) with name "00"x . X defoffset = readch(lf, 2) X defdata = readch(lf, 2) X deftype = c2d(right(defdata, 2)) X defdata = left(defdata, 2) X select X when deftype=1 then do X say " Define def '"name"' at" c2d(defoffset) X end X when deftype=2 then do X defoffset = defdata || defoffset X say " Define abs '"name"' at" c2d(defoffset) X end X when deftype=3 then do X say " Define res '"name"' at" c2d(defoffset) X end X when deftype=66 then do X defoffset = "FF"x || defdata || defoffset X say " Define abs '"name"' at" c2d(defoffset) X end X otherwise do X say "Error in object file" X exit 10 X end X end X end X end X end X signal loop X XHunk_debug: X size = c2d(readch(lf, 4))*4 X say " "id "("size "bytes)" X say " Offset:" c2d(readch(lf, 4)) X say " Type: " readch(lf, 4) X data = readch(lf, size-8) X signal loop X XHunk_break: X size = c2d(readch(lf, 4))*4 X say " "id "("size "bytes)" X data = readch(lf, size) X index = index+1 X signal loop X XHunk_overlay: X size = c2d(readch(lf, 4))*4 X say " "id "("size "bytes) - Not supported" X data = readch(lf, size) X index = index+1 X signal loop X X Xbreak_c: Xdone: Xexit 0 END_OF_FILE if test 10360 -ne `wc -c <'dalf.rexx'`; then echo shar: \"'dalf.rexx'\" unpacked with wrong size! fi # end of 'dalf.rexx' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>. Mail comments to the moderator at <amiga-request@cs.odu.edu>. Post requests for sources, and general discussion to comp.sys.amiga.