#!/usr/local/bin/perl foreach $f (@ARGV) { open(FILE, $f) || die("Cannot open $f"); seek(FILE, -36, 2); $path_size = do read_int(); $code_size = do read_int(); $prim_size = do read_int(); $data_size = do read_int(); $symbol_size = do read_int(); $debug_size = do read_int(); read(FILE, $magic, 12); if ($path_size > 0) { seek(FILE, -($path_size + $code_size + $prim_size + $data_size + $symbol_size + $debug_size + 36), 2); read(FILE, $path, $path_size); } else { $path = "(default runtime)\n"; } print $f, ":\n" if ($#ARGV > 0); printf ("\tcode: %d data: %d symbols: %d debug: %d\n", $code_size, $data_size, $symbol_size, $debug_size); printf ("\tmagic number: %s runtime system: %s", $magic, $path); close(FILE); } sub read_int { read(FILE, $buff, 4) == 4 || die("Truncated bytecode file $f"); @int = unpack("C4", $buff); return ($int[0] << 24) + ($int[1] << 16) + ($int[2] << 8) + $int[3]; }