diff options
author | Michael Brown <mcb30@etherboot.org> | 2005-05-02 15:21:12 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2005-05-02 15:21:12 +0000 |
commit | 35ab3bf808343f44a2603901fc1f38f9952faa5c (patch) | |
tree | bc9f6bfec0da02b2a245aad9ce1b4d489fa46b31 /src/util | |
parent | 734d2e9f2db97cbda205ef81d167193faba68c0d (diff) | |
download | ipxe-35ab3bf808343f44a2603901fc1f38f9952faa5c.zip ipxe-35ab3bf808343f44a2603901fc1f38f9952faa5c.tar.gz ipxe-35ab3bf808343f44a2603901fc1f38f9952faa5c.tar.bz2 |
Report on misuses of shared symbols, and excessively large static symbols.
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/symcheck.pl | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/src/util/symcheck.pl b/src/util/symcheck.pl index 38da597..d5dce82 100755 --- a/src/util/symcheck.pl +++ b/src/util/symcheck.pl @@ -44,12 +44,15 @@ foreach my $link_sym qw ( _prefix _eprefix _decompress _edecompress _text }; } -# Build up requires and provides tables for global symbols +# Build up requires, provides and shares symbol tables for global +# symbols +# my $globals = {}; while ( ( my $object, my $symbols ) = each %$symtab ) { while ( ( my $symbol, my $info ) = each %$symbols ) { if ( $info->{global} ) { - my $category = ( ( $info->{type} eq 'U' ? "requires" : "provides" ) ); + my $category = ( ( $info->{type} eq 'U' ? "requires" : + ( $info->{type} eq 'C' ? "shares" : "provides" ) ) ); $globals->{$symbol}->{$category}->{$object} = 1; } } @@ -61,18 +64,56 @@ my $problems = {}; while ( ( my $symbol, my $info ) = each %$globals ) { my @provides = keys %{$info->{provides}}; my @requires = keys %{$info->{requires}}; + my @shares = keys %{$info->{shares}}; + + if ( ( @provides == 0 ) && ( @shares == 1 ) ) { + # A symbol "shared" by just a single file is actually being + # provided by that file; it just doesn't have an initialiser. + @provides = @shares; + @shares = (); + } - if ( @provides == 0 ) { - # No object provides this symbol + if ( ( @requires > 0 ) && ( @provides == 0 ) ) { + # No object provides this symbol, but some objects require it. $problems->{$_}->{nonexistent}->{$symbol} = 1 foreach @requires; - } elsif ( @provides > 1 ) { - # Symbol defined in multiple objects - $problems->{$_}->{multiples}->{$symbol} = 1 foreach @provides; } - if ( @requires == 0 ) { - # Symbol not required + + if ( ( @requires == 0 ) && ( @provides > 0 ) ) { + # No object requires this symbol, but some objects provide it. $problems->{$_}->{unused}->{$symbol} = 1 foreach @provides; } + + if ( ( @shares > 0 ) && ( @requires > 0 ) ) { + # A shared symbol is being referenced from another object + $problems->{$_}->{shared}->{$symbol} = 1 foreach @requires; + } + + if ( ( @shares > 0 ) && ( @provides > 0 ) ) { + # A shared symbol is being initialised by an object + $problems->{$_}->{shared}->{$symbol} = 1 foreach @provides; + } + + if ( ( @shares > 0 ) && ! ( $symbol =~ /^_shared_/ ) ) { + # A shared symbol is not declared via __shared + $problems->{$_}->{shared}->{$symbol} = 1 foreach @shares; + } + + if ( @provides > 1 ) { + # A non-shared symbol is defined in multiple objects + $problems->{$_}->{multiples}->{$symbol} = 1 foreach @provides; + } +} + +# Check for excessively large local symbols +# +while ( ( my $object, my $symbols ) = each %$symtab ) { + while ( ( my $symbol, my $info ) = each %$symbols ) { + if ( ( ! $info->{global} ) && + ( $info->{type} ne 't' ) && + ( $info->{size} >= WARNING_SIZE ) ) { + $problems->{$object}->{large}->{$symbol} = 1; + } + } } # Print out error messages @@ -83,9 +124,13 @@ foreach my $object ( sort keys %$problems ) { my @nonexistent = sort keys %{$problems->{$object}->{nonexistent}}; my @multiples = sort keys %{$problems->{$object}->{multiples}}; my @unused = sort keys %{$problems->{$object}->{unused}}; + my @shared = sort keys %{$problems->{$object}->{shared}}; + my @large = sort keys %{$problems->{$object}->{large}}; print "WARN $object provides unused symbol $_\n" foreach @unused; $warnings += @unused; + print "WARN $object has large static symbol $_\n" foreach @large; + $warnings += @large; print "ERR $object requires non-existent symbol $_\n" foreach @nonexistent; $errors += @nonexistent; foreach my $symbol ( @multiples ) { @@ -95,6 +140,7 @@ foreach my $object ( sort keys %$problems ) { ." (also provided by @other_objects)\n"; } $errors += @multiples; + print "ERR $object misuses shared symbol $_\n" foreach @shared; } print "$errors error(s), $warnings warning(s)\n"; |