]> git.proxmox.com Git - pve-kernel.git/blame - abi-check
bump version to 4.13-38
[pve-kernel.git] / abi-check
CommitLineData
2f2c2430
FG
1#!/usr/bin/perl -w
2
9bdcd713
FG
3my $abinew = shift;
4my $abiold = shift;
2f2c2430
FG
5my $skipabi = shift;
6
9bdcd713
FG
7$abinew =~ /abi-(.*)/;
8my $abinum = $1;
9
2f2c2430
FG
10my $fail_exit = 1;
11my $EE = "EE:";
12my $errors = 0;
13my $abiskip = 0;
14
15my $count;
16
9bdcd713 17print "II: Checking ABI...\n";
2f2c2430 18
9bdcd713 19if ($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#
32if (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
46my %symbols;
47my %symbols_ignore;
48my %modules_ignore;
49my %module_syms;
50
51# See if we have any ignores
52my $ignore = 0;
53print " Reading symbols/modules to ignore...";
54
9bdcd713 55for $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}
71print "read $ignore symbols/modules.\n";
72
73sub 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
86print " Reading new symbols ($abinum)...";
87$count = 0;
9bdcd713
FG
88open(NEW, "< $abinew") or
89 die "Could not open $abinew";
2f2c2430
FG
90while (<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}
99close(NEW);
100print "read $count symbols.\n";
101
102# Now the old symbols, checking for missing ones
9bdcd713 103print " Reading old symbols...";
2f2c2430 104$count = 0;
9bdcd713
FG
105open(OLD, "< $abiold") or
106 die "Could not open $abiold";
2f2c2430
FG
107while (<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}
115close(OLD);
116
117print "read $count symbols.\n";
118
119print "II: Checking for missing symbols in new ABI...";
120$count = 0;
121foreach $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}
129print " " if $count;
130print "found $count missing symbols\n";
131if ($count) {
132 print "$EE Symbols gone missing (what did you do!?!)\n";
133 $errors++;
134}
135
136
137print "II: Checking for new symbols in new ABI...";
138$count = 0;
139foreach $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}
146print " " if $count;
147print "found $count new symbols\n";
9bdcd713
FG
148if ($count) {
149 print "WW: Found new symbols. Not recommended unless ABI was bumped\n";
2f2c2430
FG
150}
151
152print "II: Checking for changes to ABI...\n";
153$count = 0;
154my $moved = 0;
155my $changed_type = 0;
156my $changed_hash = 0;
157foreach $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
190print "WW: $moved symbols changed location\n" if $moved;
191print "$EE $changed_type symbols changed export type and weren't ignored\n" if $changed_type;
192print "$EE $changed_hash symbols changed hash and weren't ignored\n" if $changed_hash;
193
194$errors++ if $changed_hash or $changed_type;
195if ($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
203print "II: Done\n";
204
205if ($errors) {
206 exit($fail_exit);
207} else {
208 exit(0);
209}