summaryrefslogtreecommitdiffstats
path: root/src/util/symcheck.pl
diff options
context:
space:
mode:
authorMichael Brown2005-05-02 15:49:54 +0200
committerMichael Brown2005-05-02 15:49:54 +0200
commit88baf7a3830d014f1b79d5d10841990dc000a319 (patch)
tree3c0e5af66588eb451d967238187dbf5358826ff7 /src/util/symcheck.pl
parentAdd DOWNLOAD_PROTO_XXX options. (diff)
downloadipxe-88baf7a3830d014f1b79d5d10841990dc000a319.tar.gz
ipxe-88baf7a3830d014f1b79d5d10841990dc000a319.tar.xz
ipxe-88baf7a3830d014f1b79d5d10841990dc000a319.zip
Tweaked to read more information (including symbol size) from blib.a
Diffstat (limited to 'src/util/symcheck.pl')
-rwxr-xr-xsrc/util/symcheck.pl58
1 files changed, 45 insertions, 13 deletions
diff --git a/src/util/symcheck.pl b/src/util/symcheck.pl
index 5de101a0..38da5971 100755
--- a/src/util/symcheck.pl
+++ b/src/util/symcheck.pl
@@ -3,30 +3,62 @@
use strict;
use warnings;
-my $symbols = {};
+use constant WARNING_SIZE => 2048;
-# Scan output of "nm -o -g bin/blib.a" and build up symbol cross-ref table
+my $symtab = {};
+
+# Scan output of "nm -o -S bin/blib.a" and build up symbol table
#
while ( <> ) {
chomp;
- ( my $object, my $type, my $symbol ) = /^.*?:(.*?\.o):.*?\s(\S)\s(.*)$/;
- my $category = $type eq 'U' ? "requires" : "provides";
- $symbols->{$symbol}->{$category}->{$object} = 1;
+ ( my $object, undef, my $value, undef, my $size, my $type, my $symbol )
+ = /^.*?:(.*?\.o):((\S+)(\s+(\S+))?)?\s+(\S)\s+(\S+)$/;
+ $symtab->{$object}->{$symbol} = {
+ global => ( $type eq uc $type ),
+ type => ( $type ),
+ value => ( $value ? hex ( $value ) : 0 ),
+ size => ( $size ? hex ( $size ) : 0 ),
+ };
}
# Add symbols that we know will be generated or required by the linker
#
-while ( ( my $symbol, my $info ) = each %$symbols ) {
- $info->{requires}->{LINKER} = 1 if $symbol =~ /^obj_/;
+foreach my $object ( keys %$symtab ) {
+ my $obj_symbol = "obj_$object";
+ $obj_symbol =~ s/\.o$//;
+ $obj_symbol =~ s/\W/_/g;
+ $symtab->{LINKER}->{$obj_symbol} = {
+ global => 1,
+ type => 'U',
+ value => 0,
+ size => 0,
+ };
+}
+foreach my $link_sym qw ( _prefix _eprefix _decompress _edecompress _text
+ _etext _data _edata _bss _ebss _end ) {
+ $symtab->{LINKER}->{$link_sym} = {
+ global => 1,
+ type => 'A',
+ value => 0,
+ size => 0,
+ };
+}
+
+# Build up requires and provides 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" ) );
+ $globals->{$symbol}->{$category}->{$object} = 1;
+ }
+ }
}
-$symbols->{$_}->{provides}->{LINKER} = 1
- foreach qw ( _prefix _eprefix _decompress _edecompress _text
- _etext _data _edata _bss _ebss _end );
-# Check for multiply defined, never-defined and unused symbols
+# Check for multiply defined, never-defined and unused global symbols
#
my $problems = {};
-while ( ( my $symbol, my $info ) = each %$symbols ) {
+while ( ( my $symbol, my $info ) = each %$globals ) {
my @provides = keys %{$info->{provides}};
my @requires = keys %{$info->{requires}};
@@ -58,7 +90,7 @@ foreach my $object ( sort keys %$problems ) {
$errors += @nonexistent;
foreach my $symbol ( @multiples ) {
my @other_objects = sort grep { $_ ne $object }
- keys %{$symbols->{$symbol}->{provides}};
+ keys %{$globals->{$symbol}->{provides}};
print "ERR $object provides symbol $symbol"
." (also provided by @other_objects)\n";
}