head     1.1;
branch   1.1.1;
access   ;
symbols  start:1.1.1.1 webdox:1.1.1;
locks    ; strict;
comment  @# @;


1.1
date     2003.03.15.00.57.44;  author redpain;  state Exp;
branches 1.1.1.1;
next     ;

1.1.1.1
date     2003.03.15.00.57.44;  author redpain;  state Exp;
branches ;
next     ;


desc
@@



1.1
log
@Initial revision
@
text
@#! /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 <kernfile>\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);
}
@


1.1.1.1
log
@Project Start
@
text
@@
