|
@@ -44,12 +44,15 @@ foreach my $link_sym qw ( _prefix _eprefix _decompress _edecompress _text
|
44
|
44
|
};
|
45
|
45
|
}
|
46
|
46
|
|
47
|
|
-# Build up requires and provides tables for global symbols
|
|
47
|
+# Build up requires, provides and shares symbol tables for global
|
|
48
|
+# symbols
|
|
49
|
+#
|
48
|
50
|
my $globals = {};
|
49
|
51
|
while ( ( my $object, my $symbols ) = each %$symtab ) {
|
50
|
52
|
while ( ( my $symbol, my $info ) = each %$symbols ) {
|
51
|
53
|
if ( $info->{global} ) {
|
52
|
|
- my $category = ( ( $info->{type} eq 'U' ? "requires" : "provides" ) );
|
|
54
|
+ my $category = ( ( $info->{type} eq 'U' ? "requires" :
|
|
55
|
+ ( $info->{type} eq 'C' ? "shares" : "provides" ) ) );
|
53
|
56
|
$globals->{$symbol}->{$category}->{$object} = 1;
|
54
|
57
|
}
|
55
|
58
|
}
|
|
@@ -61,18 +64,56 @@ my $problems = {};
|
61
|
64
|
while ( ( my $symbol, my $info ) = each %$globals ) {
|
62
|
65
|
my @provides = keys %{$info->{provides}};
|
63
|
66
|
my @requires = keys %{$info->{requires}};
|
|
67
|
+ my @shares = keys %{$info->{shares}};
|
|
68
|
+
|
|
69
|
+ if ( ( @provides == 0 ) && ( @shares == 1 ) ) {
|
|
70
|
+ # A symbol "shared" by just a single file is actually being
|
|
71
|
+ # provided by that file; it just doesn't have an initialiser.
|
|
72
|
+ @provides = @shares;
|
|
73
|
+ @shares = ();
|
|
74
|
+ }
|
64
|
75
|
|
65
|
|
- if ( @provides == 0 ) {
|
66
|
|
- # No object provides this symbol
|
|
76
|
+ if ( ( @requires > 0 ) && ( @provides == 0 ) ) {
|
|
77
|
+ # No object provides this symbol, but some objects require it.
|
67
|
78
|
$problems->{$_}->{nonexistent}->{$symbol} = 1 foreach @requires;
|
68
|
|
- } elsif ( @provides > 1 ) {
|
69
|
|
- # Symbol defined in multiple objects
|
70
|
|
- $problems->{$_}->{multiples}->{$symbol} = 1 foreach @provides;
|
71
|
79
|
}
|
72
|
|
- if ( @requires == 0 ) {
|
73
|
|
- # Symbol not required
|
|
80
|
+
|
|
81
|
+ if ( ( @requires == 0 ) && ( @provides > 0 ) ) {
|
|
82
|
+ # No object requires this symbol, but some objects provide it.
|
74
|
83
|
$problems->{$_}->{unused}->{$symbol} = 1 foreach @provides;
|
75
|
84
|
}
|
|
85
|
+
|
|
86
|
+ if ( ( @shares > 0 ) && ( @requires > 0 ) ) {
|
|
87
|
+ # A shared symbol is being referenced from another object
|
|
88
|
+ $problems->{$_}->{shared}->{$symbol} = 1 foreach @requires;
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ if ( ( @shares > 0 ) && ( @provides > 0 ) ) {
|
|
92
|
+ # A shared symbol is being initialised by an object
|
|
93
|
+ $problems->{$_}->{shared}->{$symbol} = 1 foreach @provides;
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ if ( ( @shares > 0 ) && ! ( $symbol =~ /^_shared_/ ) ) {
|
|
97
|
+ # A shared symbol is not declared via __shared
|
|
98
|
+ $problems->{$_}->{shared}->{$symbol} = 1 foreach @shares;
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ if ( @provides > 1 ) {
|
|
102
|
+ # A non-shared symbol is defined in multiple objects
|
|
103
|
+ $problems->{$_}->{multiples}->{$symbol} = 1 foreach @provides;
|
|
104
|
+ }
|
|
105
|
+}
|
|
106
|
+
|
|
107
|
+# Check for excessively large local symbols
|
|
108
|
+#
|
|
109
|
+while ( ( my $object, my $symbols ) = each %$symtab ) {
|
|
110
|
+ while ( ( my $symbol, my $info ) = each %$symbols ) {
|
|
111
|
+ if ( ( ! $info->{global} ) &&
|
|
112
|
+ ( $info->{type} ne 't' ) &&
|
|
113
|
+ ( $info->{size} >= WARNING_SIZE ) ) {
|
|
114
|
+ $problems->{$object}->{large}->{$symbol} = 1;
|
|
115
|
+ }
|
|
116
|
+ }
|
76
|
117
|
}
|
77
|
118
|
|
78
|
119
|
# Print out error messages
|
|
@@ -83,9 +124,13 @@ foreach my $object ( sort keys %$problems ) {
|
83
|
124
|
my @nonexistent = sort keys %{$problems->{$object}->{nonexistent}};
|
84
|
125
|
my @multiples = sort keys %{$problems->{$object}->{multiples}};
|
85
|
126
|
my @unused = sort keys %{$problems->{$object}->{unused}};
|
|
127
|
+ my @shared = sort keys %{$problems->{$object}->{shared}};
|
|
128
|
+ my @large = sort keys %{$problems->{$object}->{large}};
|
86
|
129
|
|
87
|
130
|
print "WARN $object provides unused symbol $_\n" foreach @unused;
|
88
|
131
|
$warnings += @unused;
|
|
132
|
+ print "WARN $object has large static symbol $_\n" foreach @large;
|
|
133
|
+ $warnings += @large;
|
89
|
134
|
print "ERR $object requires non-existent symbol $_\n" foreach @nonexistent;
|
90
|
135
|
$errors += @nonexistent;
|
91
|
136
|
foreach my $symbol ( @multiples ) {
|
|
@@ -95,6 +140,7 @@ foreach my $object ( sort keys %$problems ) {
|
95
|
140
|
." (also provided by @other_objects)\n";
|
96
|
141
|
}
|
97
|
142
|
$errors += @multiples;
|
|
143
|
+ print "ERR $object misuses shared symbol $_\n" foreach @shared;
|
98
|
144
|
}
|
99
|
145
|
|
100
|
146
|
print "$errors error(s), $warnings warning(s)\n";
|