X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=geekos%2Fscripts%2Fkerninfo;fp=geekos%2Fscripts%2Fkerninfo;h=9241e3a0cad2335f31ea8c72ce6fdce9f33a47ea;hp=0000000000000000000000000000000000000000;hb=ddc16b0737cf58f7aa90a69c6652cdf4090aec51;hpb=626595465a2c6987606a6bc697df65130ad8c2d3 diff --git a/geekos/scripts/kerninfo b/geekos/scripts/kerninfo new file mode 100755 index 0000000..9241e3a --- /dev/null +++ b/geekos/scripts/kerninfo @@ -0,0 +1,38 @@ +#! /usr/bin/perl + +# A script to analyze the output of "objdump -h" on the +# kernel executable file. + +use strict qw(vars refs); +use FileHandle; + +my $kernfile = shift @ARGV; +(defined $kernfile) || die "usage: kernsize \n"; + +my $kern_fh = new FileHandle("<$kernfile"); +(defined $kern_fh) || die "can't open $kernfile: $!\n"; + +my $objdump_fh = new FileHandle("objdump -h $kernfile|"); +while ( <$objdump_fh> ) { + chop; + s/^\s+//; + my @fields = split(/\s+/, $_); + if ( $fields[0] =~ /^[0-9]$/ ) { +# print "text start is ", $fields[5], "\n" if $fields[0] eq '0'; + my $size = hex($fields[2]); + my $offset = hex($fields[5]); + + print $fields[0], " (", $fields[1], "): size=$size, offset=$offset\n"; + + printf("Word at beginning of section is %08x\n", ReadWord($kern_fh,$offset) ); + } +} +$objdump_fh->close(); + +sub ReadWord { + my ($fh, $offset) = @_; + seek $fh, $offset, SEEK_SET; + my $buf = 'X' x 4; + read $fh, $buf, 4; + return unpack('V',$buf); +}