4 open(FILE, $f) || die("Cannot open $f");
6 $num_sections = do read_int();
7 read(FILE, $magic, 12);
8 seek(FILE, -16 - 8 * $num_sections, 2);
12 for ($i = 0; $i < $num_sections; $i++) {
15 $seclength[$i] = do read_int();
16 $length{$sec} = $seclength[$i];
18 print $f, ":\n" if ($#ARGV > 0);
21 do read_section('RNTM') :
22 "(default runtime)\n";
23 printf ("\tcode: %-7d data: %-7d symbols: %-7d debug: %-7d\n",
24 $length{'CODE'}, $length{'DATA'},
25 $length{'SYMB'}, $length{'DBUG'});
26 printf ("\tmagic number: %s runtime system: %s",
32 read(FILE, $buff, 4) == 4 || die("Truncated bytecode file $f");
33 @int = unpack("C4", $buff);
34 return ($int[0] << 24) + ($int[1] << 16) + ($int[2] << 8) + $int[3];
39 local ($i, $ofs, $data);
40 for ($i = $num_sections - 1; $i >= 0; $i--) {
41 $ofs += $seclength[$i];
42 if ($secname[$i] eq $sec) {
43 seek(FILE, -16 - 8 * $num_sections - $ofs, 2);
44 read(FILE, $data, $seclength[$i]);