Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Library and tools for manipulating text and binary file ("KEYED STREAM file: / textfi...
[palacios.releases.git] / geekos / scripts / kerninfo
1 #! /usr/bin/perl
2
3 # A script to analyze the output of "objdump -h" on the
4 # kernel executable file.
5
6 use strict qw(vars refs);
7 use FileHandle;
8
9 my $kernfile = shift @ARGV;
10 (defined $kernfile) || die "usage: kernsize <kernfile>\n";
11
12 my $kern_fh = new FileHandle("<$kernfile");
13 (defined $kern_fh) || die "can't open $kernfile: $!\n";
14
15 my $objdump_fh = new FileHandle("objdump -h $kernfile|");
16 while ( <$objdump_fh> ) {
17     chop;
18     s/^\s+//;
19     my @fields = split(/\s+/, $_);
20     if ( $fields[0] =~ /^[0-9]$/ ) {
21 #       print "text start is ", $fields[5], "\n" if $fields[0] eq '0';
22         my $size = hex($fields[2]);
23         my $offset = hex($fields[5]);
24
25         print $fields[0], " (", $fields[1], "): size=$size, offset=$offset\n";
26
27         printf("Word at beginning of section is %08x\n", ReadWord($kern_fh,$offset) );
28     }
29 }
30 $objdump_fh->close();
31
32 sub ReadWord {
33     my ($fh, $offset) = @_;
34     seek $fh, $offset, SEEK_SET;
35     my $buf = 'X' x 4;
36     read $fh, $buf, 4;
37     return unpack('V',$buf);
38 }