1 Star 0 Fork 275

Adttil/kernel_src

forked from src-openEuler/kernel 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
check-kabi 3.58 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/python3
#
# check-kabi - Red Hat kABI reference checking tool
#
# We use this script to check against reference Module.kabi files.
#
# Author: Jon Masters <jcm@redhat.com>
# Copyright (C) 2007-2009 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# General Public License (GPL).
# Changelog:
#
# 2009/08/15 - Updated for use in RHEL6.
# 2007/06/13 - Initial rewrite in python by Jon Masters.
__author__ = "Jon Masters <jcm@redhat.com>"
__version__ = "2.0"
__date__ = "2009/08/15"
__copyright__ = "Copyright (C) 2007-2009 Red Hat, Inc"
__license__ = "GPL"
import getopt
import os
import re
import string
import sys
true = 1
false = 0
def load_symvers(symvers,filename):
"""Load a Module.symvers file."""
symvers_file = open(filename,"r")
while true:
in_line = symvers_file.readline()
if in_line == "":
break
if in_line == "\n":
continue
checksum,symbol,directory,type,namespace = in_line.split('\t')
symvers[symbol] = in_line[0:-1]
def load_kabi(kabi,filename):
"""Load a Module.kabi file."""
kabi_file = open(filename,"r")
while true:
in_line = kabi_file.readline()
if in_line == "":
break
if in_line == "\n":
continue
checksum,symbol,directory,type,namespace = in_line.split('\t')
kabi[symbol] = in_line[0:-1]
def check_kabi(symvers,kabi):
"""Check Module.kabi and Module.symvers files."""
fail=0
warn=0
lost=0
changed_symbols=[]
moved_symbols=[]
losted_symbols=[]
for symbol in kabi:
abi_hash,abi_sym,abi_dir,abi_type,abi_namespace = kabi[symbol].split('\t')
if symbol in symvers:
sym_hash,sym_sym,sym_dir,sym_type,sym_namespace = symvers[symbol].split('\t')
if abi_hash != sym_hash:
fail=1
changed_symbols.append(symbol)
if abi_dir != sym_dir:
warn=1
moved_symbols.append(symbol)
else:
lost=1
losted_symbols.append(symbol)
if fail:
print ("*** ERROR - ABI BREAKAGE WAS DETECTED ***")
print ("")
print ("The following symbols have been changed (this will cause an ABI breakage):")
print ("new kabi:")
for symbol in changed_symbols:
print (symvers[symbol])
print ("old kabi:")
for symbol in changed_symbols:
print (kabi[symbol])
print ("")
if lost:
print ("*** ERROR - ABI BREAKAGE WAS DETECTED ***")
print ("")
print ("The following symbols have been losted (this will cause an ABI breakage):")
print ("old kabi:")
for symbol in losted_symbols:
print (kabi[symbol])
print ("")
if warn:
print ("*** WARNING - ABI SYMBOLS MOVED ***")
print ("")
print ("The following symbols moved (typically caused by moving a symbol from being")
print ("provided by the kernel vmlinux out to a loadable module):")
print ("new kabi:")
for symbol in moved_symbols:
print (symvers[symbol])
print ("old kabi")
for symbol in moved_symbols:
print (kabi[symbol])
print ("")
"""Halt the build, if we got errors and/or warnings. In either case,
double-checkig is required to avoid introducing / concealing
KABI inconsistencies."""
if fail or warn or lost:
sys.exit(1)
sys.exit(0)
def usage():
print ("""
check-kabi: check Module.kabi and Module.symvers files.
check-kabi [ -k Module.kabi ] [ -s Module.symvers ]
""")
if __name__ == "__main__":
symvers_file = ""
kabi_file = ""
opts, args = getopt.getopt(sys.argv[1:], 'hk:s:')
for o, v in opts:
if o == "-s":
symvers_file = v
if o == "-h":
usage()
sys.exit(0)
if o == "-k":
kabi_file = v
if (symvers_file == "") or (kabi_file == ""):
usage()
sys.exit(1)
symvers={}
kabi={}
load_symvers(symvers,symvers_file)
load_kabi(kabi,kabi_file)
check_kabi(symvers,kabi)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/adttil/kernel_src.git
git@gitee.com:adttil/kernel_src.git
adttil
kernel_src
kernel_src
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385