]>
Commit | Line | Data |
---|---|---|
2f2c2430 FG |
1 | #!/usr/bin/perl -w |
2 | ||
9bdcd713 FG |
3 | my $abinew = shift; |
4 | my $abiold = shift; | |
2f2c2430 FG |
5 | my $skipabi = shift; |
6 | ||
9bdcd713 FG |
7 | $abinew =~ /abi-(.*)/; |
8 | my $abinum = $1; | |
9 | ||
2f2c2430 FG |
10 | my $fail_exit = 1; |
11 | my $EE = "EE:"; | |
12 | my $errors = 0; | |
13 | my $abiskip = 0; | |
14 | ||
15 | my $count; | |
16 | ||
9bdcd713 | 17 | print "II: Checking ABI...\n"; |
2f2c2430 | 18 | |
9bdcd713 | 19 | if ($skipabi) { |
2f2c2430 FG |
20 | print "WW: Explicitly asked to ignore ABI, running in no-fail mode\n"; |
21 | $fail_exit = 0; | |
22 | $abiskip = 1; | |
23 | $EE = "WW:"; | |
24 | } | |
25 | ||
9bdcd713 FG |
26 | #if ($prev_abinum != $abinum) { |
27 | # print "II: Different ABI's, running in no-fail mode\n"; | |
28 | # $fail_exit = 0; | |
29 | # $EE = "WW:"; | |
30 | #} | |
31 | # | |
32 | if (not -f "$abinew" or not -f "$abiold") { | |
2f2c2430 | 33 | print "EE: Previous or current ABI file missing!\n"; |
9bdcd713 FG |
34 | print " $abinew\n" if not -f "$abinew"; |
35 | print " $abiold\n" if not -f "$abiold"; | |
2f2c2430 FG |
36 | |
37 | # Exit if the ABI files are missing, but return status based on whether | |
38 | # skip ABI was indicated. | |
39 | if ("$abiskip" eq "1") { | |
40 | exit(0); | |
41 | } else { | |
42 | exit(1); | |
43 | } | |
44 | } | |
45 | ||
46 | my %symbols; | |
47 | my %symbols_ignore; | |
48 | my %modules_ignore; | |
49 | my %module_syms; | |
50 | ||
51 | # See if we have any ignores | |
52 | my $ignore = 0; | |
53 | print " Reading symbols/modules to ignore..."; | |
54 | ||
9bdcd713 | 55 | for $file ("abi-blacklist") { |
2f2c2430 FG |
56 | if (-f $file) { |
57 | open(IGNORE, "< $file") or | |
58 | die "Could not open $file"; | |
59 | while (<IGNORE>) { | |
60 | chomp; | |
61 | if ($_ =~ m/M: (.*)/) { | |
62 | $modules_ignore{$1} = 1; | |
63 | } else { | |
64 | $symbols_ignore{$_} = 1; | |
65 | } | |
66 | $ignore++; | |
67 | } | |
68 | close(IGNORE); | |
69 | } | |
70 | } | |
71 | print "read $ignore symbols/modules.\n"; | |
72 | ||
73 | sub is_ignored($$) { | |
74 | my ($mod, $sym) = @_; | |
75 | ||
76 | die "Missing module name in is_ignored()" if not defined($mod); | |
77 | die "Missing symbol name in is_ignored()" if not defined($sym); | |
78 | ||
79 | if (defined($symbols_ignore{$sym}) or defined($modules_ignore{$mod})) { | |
80 | return 1; | |
81 | } | |
82 | return 0; | |
83 | } | |
84 | ||
85 | # Read new syms first | |
86 | print " Reading new symbols ($abinum)..."; | |
87 | $count = 0; | |
9bdcd713 FG |
88 | open(NEW, "< $abinew") or |
89 | die "Could not open $abinew"; | |
2f2c2430 FG |
90 | while (<NEW>) { |
91 | chomp; | |
92 | m/^(\S+)\s(.+)\s(0x[0-9a-f]+)\s(.+)$/; | |
93 | $symbols{$4}{'type'} = $1; | |
94 | $symbols{$4}{'loc'} = $2; | |
95 | $symbols{$4}{'hash'} = $3; | |
96 | $module_syms{$2} = 0; | |
97 | $count++; | |
98 | } | |
99 | close(NEW); | |
100 | print "read $count symbols.\n"; | |
101 | ||
102 | # Now the old symbols, checking for missing ones | |
9bdcd713 | 103 | print " Reading old symbols..."; |
2f2c2430 | 104 | $count = 0; |
9bdcd713 FG |
105 | open(OLD, "< $abiold") or |
106 | die "Could not open $abiold"; | |
2f2c2430 FG |
107 | while (<OLD>) { |
108 | chomp; | |
109 | m/^(\S+)\s(.+)\s(0x[0-9a-f]+)\s(.+)$/; | |
110 | $symbols{$4}{'old_type'} = $1; | |
111 | $symbols{$4}{'old_loc'} = $2; | |
112 | $symbols{$4}{'old_hash'} = $3; | |
113 | $count++; | |
114 | } | |
115 | close(OLD); | |
116 | ||
117 | print "read $count symbols.\n"; | |
118 | ||
119 | print "II: Checking for missing symbols in new ABI..."; | |
120 | $count = 0; | |
121 | foreach $sym (keys(%symbols)) { | |
122 | if (!defined($symbols{$sym}{'type'})) { | |
123 | print "\n" if not $count; | |
124 | printf(" MISS : %s%s\n", $sym, | |
125 | is_ignored($symbols{$sym}{'old_loc'}, $sym) ? " (ignored)" : ""); | |
126 | $count++ if !is_ignored($symbols{$sym}{'old_loc'}, $sym); | |
127 | } | |
128 | } | |
129 | print " " if $count; | |
130 | print "found $count missing symbols\n"; | |
131 | if ($count) { | |
132 | print "$EE Symbols gone missing (what did you do!?!)\n"; | |
133 | $errors++; | |
134 | } | |
135 | ||
136 | ||
137 | print "II: Checking for new symbols in new ABI..."; | |
138 | $count = 0; | |
139 | foreach $sym (keys(%symbols)) { | |
140 | if (!defined($symbols{$sym}{'old_type'})) { | |
141 | print "\n" if not $count; | |
142 | print " NEW : $sym\n"; | |
143 | $count++; | |
144 | } | |
145 | } | |
146 | print " " if $count; | |
147 | print "found $count new symbols\n"; | |
9bdcd713 FG |
148 | if ($count) { |
149 | print "WW: Found new symbols. Not recommended unless ABI was bumped\n"; | |
2f2c2430 FG |
150 | } |
151 | ||
152 | print "II: Checking for changes to ABI...\n"; | |
153 | $count = 0; | |
154 | my $moved = 0; | |
155 | my $changed_type = 0; | |
156 | my $changed_hash = 0; | |
157 | foreach $sym (keys(%symbols)) { | |
158 | if (!defined($symbols{$sym}{'old_type'}) or | |
159 | !defined($symbols{$sym}{'type'})) { | |
160 | next; | |
161 | } | |
162 | ||
163 | # Changes in location don't hurt us, but log it anyway | |
164 | if ($symbols{$sym}{'loc'} ne $symbols{$sym}{'old_loc'}) { | |
165 | printf(" MOVE : %-40s : %s => %s\n", $sym, $symbols{$sym}{'old_loc'}, | |
166 | $symbols{$sym}{'loc'}); | |
167 | $moved++; | |
168 | } | |
169 | ||
170 | # Changes to export type are only bad if new type isn't | |
171 | # EXPORT_SYMBOL. Changing things to GPL are bad. | |
172 | if ($symbols{$sym}{'type'} ne $symbols{$sym}{'old_type'}) { | |
173 | printf(" TYPE : %-40s : %s => %s%s\n", $sym, $symbols{$sym}{'old_type'}. | |
174 | $symbols{$sym}{'type'}, is_ignored($symbols{$sym}{'loc'}, $sym) | |
175 | ? " (ignored)" : ""); | |
176 | $changed_type++ if $symbols{$sym}{'type'} ne "EXPORT_SYMBOL" | |
177 | and !is_ignored($symbols{$sym}{'loc'}, $sym); | |
178 | } | |
179 | ||
180 | # Changes to the hash are always bad | |
181 | if ($symbols{$sym}{'hash'} ne $symbols{$sym}{'old_hash'}) { | |
182 | printf(" HASH : %-40s : %s => %s%s\n", $sym, $symbols{$sym}{'old_hash'}, | |
183 | $symbols{$sym}{'hash'}, is_ignored($symbols{$sym}{'loc'}, $sym) | |
184 | ? " (ignored)" : ""); | |
185 | $changed_hash++ if !is_ignored($symbols{$sym}{'loc'}, $sym); | |
186 | $module_syms{$symbols{$sym}{'loc'}}++; | |
187 | } | |
188 | } | |
189 | ||
190 | print "WW: $moved symbols changed location\n" if $moved; | |
191 | print "$EE $changed_type symbols changed export type and weren't ignored\n" if $changed_type; | |
192 | print "$EE $changed_hash symbols changed hash and weren't ignored\n" if $changed_hash; | |
193 | ||
194 | $errors++ if $changed_hash or $changed_type; | |
195 | if ($changed_hash) { | |
196 | print "II: Module hash change summary...\n"; | |
197 | foreach $mod (sort { $module_syms{$b} <=> $module_syms{$a} } keys %module_syms) { | |
198 | next if ! $module_syms{$mod}; | |
199 | printf(" %-40s: %d\n", $mod, $module_syms{$mod}); | |
200 | } | |
201 | } | |
202 | ||
203 | print "II: Done\n"; | |
204 | ||
205 | if ($errors) { | |
206 | exit($fail_exit); | |
207 | } else { | |
208 | exit(0); | |
209 | } |