3 # check-kabi - Red Hat kABI reference checking tool
5 # We use this script to check against reference Module.kabi files.
7 # Author: Jon Masters <jcm@redhat.com>
8 # Copyright (C) 2007-2009 Red Hat, Inc.
10 # This software may be freely redistributed under the terms of the GNU
11 # General Public License (GPL).
15 # 2009/08/15 - Updated for use in RHEL6.
16 # 2007/06/13 - Initial rewrite in python by Jon Masters.
18 __author__ = "Jon Masters <jcm@redhat.com>"
20 __date__ = "2009/08/15"
21 __copyright__ = "Copyright (C) 2007-2009 Red Hat, Inc"
33 def load_symvers(symvers,filename):
34 """Load a Module.symvers file."""
36 symvers_file = open(filename,"r")
39 in_line = symvers_file.readline()
44 checksum,symbol,directory,type = string.split(in_line)
46 symvers[symbol] = in_line[0:-1]
48 def load_kabi(kabi,filename):
49 """Load a Module.kabi file."""
51 kabi_file = open(filename,"r")
54 in_line = kabi_file.readline()
59 checksum,symbol,directory,type = string.split(in_line)
61 kabi[symbol] = in_line[0:-1]
63 def check_kabi(symvers,kabi):
64 """Check Module.kabi and Module.symvers files."""
72 abi_hash,abi_sym,abi_dir,abi_type = string.split(kabi[symbol])
73 if symvers.has_key(symbol):
74 sym_hash,sym_sym,sym_dir,sym_type = string.split(symvers[symbol])
75 if abi_hash != sym_hash:
77 changed_symbols.append(symbol)
79 if abi_dir != sym_dir:
81 moved_symbols.append(symbol)
84 changed_symbols.append(symbol)
87 print "*** ERROR - ABI BREAKAGE WAS DETECTED ***"
89 print "The following symbols have been changed (this will cause an ABI breakage):"
91 for symbol in changed_symbols:
96 print "*** WARNING - ABI SYMBOLS MOVED ***"
98 print "The following symbols moved (typically caused by moving a symbol from being"
99 print "provided by the kernel vmlinux out to a loadable module):"
101 for symbol in moved_symbols:
105 """Halt the build, if we got errors and/or warnings. In either case,
106 double-checkig is required to avoid introducing / concealing
107 KABI inconsistencies."""
114 check-kabi: check Module.kabi and Module.symvers files.
116 check-kabi [ -k Module.kabi ] [ -s Module.symvers ]
120 if __name__ == "__main__":
125 opts, args = getopt.getopt(sys.argv[1:], 'hk:s:')
136 if (symvers_file == "") or (kabi_file == ""):
143 load_symvers(symvers,symvers_file)
144 load_kabi(kabi,kabi_file)
145 check_kabi(symvers,kabi)