lkml.org 
[lkml]   [2000]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: how interesting are data->bss patches?
Date
On Sun, 24 Sep 2000 14:28:07 -0500 (CDT), 
Peter Samuelson <peter@cadcamlab.org> wrote:
>[Tigran Aivazian <tigran@veritas.com>]
>> The question you ask can be answered trivially - yes, it is
>> definitely a good idea, please make such a patch.
>
>My expression doesn't catch *all* offenders, by any means. For
>example, things like
>
> char *foo[MAX_BLURFL] = { NULL, };
>
>would be much harder to pick up.

Got bored, wrote some Perl. On a 2.4.0-test8 system with a fairly
minimal config, most stuff in modules, it found 14,420 bytes of vmlinux
.data where the entire variable was initialized to 0. Obviously this
depends on your config and will only catch data for options that have
been selected. Anybody want to try this on a kernel with the lot?

Biggest offenders

0xc02ce7e0(64) empty_iops.505
0xc02ce820(64) empty_fops.506
0xc02c8c40(128) last_irq_sums.664
0xc02c8cc0(128) alert_counter.665
0xc02c9120(128) vm86_irqs
0xc02ca340(128) apic_timer_irqs
0xc02dc0c0(128) inet_protos
0xc02dc240(128) tcp_listening_hash
0xc02dff20(128) inet6_protos
0xc02c9920(256) command_line
0xc02ca080(256) tsc_values
0xc02cee60(512) proc_alloc_map
0xc02c9680(672) e820
0xc02d0c60(1024) floppy_blocksizes
0xc02d4f80(1024) raw_device_bindings
0xc02d5380(1024) raw_device_inuse
0xc02d5780(1024) raw_device_sector_size
0xc02d5b80(1024) raw_device_sector_bits
0xc02cd160(2048) chrdevs
0xc02cdc40(2048) blkdevs

--- cut here

#!/usr/bin/perl -w
# List symbols in .data section which are initialized to zero.
# Needs readelf command from recent binutils.

use strict;
die($0 . " takes exactly one argument, vmlinux or a module to be explored\n") if($#ARGV);

my ($data, $section, $start, $size, $addr, $len, $i, $total);
my @f;
my @symdata;
my @keys;
my %symbol;

$data = `readelf -S $ARGV[0] | fgrep ' .data '`;
chomp($data);
die("$0 could not find .data section in $ARGV[0]\n") if($data eq "");
print("Data section ", $data, "\n");
$data =~ s/[][]//g;
(@f) = split(' ', $data);
$section = $f[0];
$start = hex("0x" . $f[3]);
$size = hex("0x" . $f[5]);
$symbol{$start} = ".data__start";
$symbol{$start+$size} = ".data__end";

$data = "";
@symdata = `readelf -s -x $section $ARGV[0]`;
foreach (@symdata) {
chomp();
if (/^ *[0-9]+:/) {
(@f) = split();
$symbol{hex("0x" . $f[1])} = $f[7] if ($f[6] eq "$section");
}
elsif (/^ *0x/) {
s/^ +//;
$addr = hex(substr($_, 0, 10));
($_ = substr($_, 11, 35)) =~ s/ //g;
$data .= scalar reverse($_); # assumes little endian
}
}

@keys = sort(keys(%symbol));
$total = 0;
for ($i = 0; $i < $#keys-1; ++$i) {
$addr = $keys[$i];
$len = $keys[$i+1] - $addr;
if (substr($data, ($addr-$start)*2, $len*2) =~ /^0+$/) {
printf("0x%x(%d)\t%s\n", $addr, $len, $symbol{$addr});
$total += $len;
}
}

printf("Total %d (0x%x)\n", $total, $total);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.094 / U:2.292 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site