3 # A script to analyze the output of "objdump -h" on the
4 # kernel executable file.
6 use strict qw(vars refs);
9 my $kernfile = shift @ARGV;
10 (defined $kernfile) || die "usage: kernsize <kernfile>\n";
12 my $kern_fh = new FileHandle("<$kernfile");
13 (defined $kern_fh) || die "can't open $kernfile: $!\n";
15 my $objdump_fh = new FileHandle("objdump -h $kernfile|");
16 while ( <$objdump_fh> ) {
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]);
25 print $fields[0], " (", $fields[1], "): size=$size, offset=$offset\n";
27 printf("Word at beginning of section is %08x\n", ReadWord($kern_fh,$offset) );
33 my ($fh, $offset) = @_;
34 seek $fh, $offset, SEEK_SET;
37 return unpack('V',$buf);