当前位置: 首页 > 资讯 >

Linux内核代码的静态检查_环球速讯

来源:面包芯语   时间:2023-05-22 12:31:49


【资料图】

ubuntu16@ubuntu16:~$gitclonegit://git.kernel.org/pub/scm/devel/sparse/sparse.gitCloninginto"sparse"...remote:Enumeratingobjects:17,done.remote:Countingobjects:100%(17/17),done.remote:Compressingobjects:100%(17/17),done.remote:Total20026(delta6),reused0(delta0),pack-reused20009Receivingobjects:100%(20026/20026),4.29MiB|924.00KiB/s,done.Resolvingdeltas:100%(14035/14035),done.Checkingconnectivity...done.
ubuntu16@ubuntu16:~$cdsparse/ubuntu16@ubuntu16:sparse$makeMakefile:152:Yoursystemdoesnothavelibxml,disablingc2xmlMakefile:170:Yoursystemdoesnothavesqlite3,disablingsemindMakefile:192:Yoursystemdoesnothavegtk3/gtk2,disablingtest-inspectMakefile:226:Yoursystemdoesnothavellvm,disablingsparse-llvm
ubuntu16@ubuntu16:sparse$makeinstallMakefile:152:Yoursystemdoesnothavelibxml,disablingc2xmlMakefile:170:Yoursystemdoesnothavesqlite3,disablingsemindMakefile:192:Yoursystemdoesnothavegtk3/gtk2,disablingtest-inspectMakefile:226:Yoursystemdoesnothavellvm,disablingsparse-llvmINSTALL/home/ubuntu16/bin/sparseINSTALL/home/ubuntu16/bin/cgccINSTALL/home/ubuntu16/share/man/man1/sparse.1INSTALL/home/ubuntu16/share/man/man1/cgcc.1ubuntu16@ubuntu16:sparse$

3、执行Sparse静态检查

从kernel顶层Makefile中可以看出,当编译kernel时通过指定C=1C=2,可以调用到Sparse进行代码静态检查。

192#Callasourcecodechecker(bydefault,"sparse")aspartofthe193#Ccompilation.194#195#Use"makeC=1"toenablecheckingofonlyre-compiledfiles.196#Use"makeC=2"toenablecheckingof*all*sourcefiles,regardless197#ofwhethertheyarere-compiledornot.198#199#Seethefile"Documentation/dev-tools/sparse.rst"formoredetails,200#includingwheretogetthe"sparse"utility.

执行结果:

ubuntu16@ubuntu16:linux$makeARCH=armCROSS_COMPILE=arm-linux-gnueabi--j4C=2CHECKscripts/mod/empty.cCALLscripts/atomic/check-atomics.shCALLscripts/checksyscalls.shCHECKarch/arm/vfp/vfpmodule.cCHECKinit/main.carch/arm/vfp/vfpmodule.c:38:17:warning:symbol"vfp_vector"wasnotdeclared.Shoulditbestatic?arch/arm/vfp/vfpmodule.c:56:17:warning:symbol"vfp_current_hw_state"wasnotdeclared.Shoulditbestatic?arch/arm/vfp/vfpmodule.c:323:6:warning:symbol"VFP_bounce"wasnotdeclared.Shoulditbestatic?arch/arm/vfp/vfpmodule.c:714:6:warning:symbol"kernel_neon_begin"wasnotdeclared.Shoulditbestatic?arch/arm/vfp/vfpmodule.c:745:6:warning:symbol"kernel_neon_end"wasnotdeclared.Shoulditbestatic?...

X 关闭

推荐内容

信息

Copyright ©  2015-2022 太平洋母婴网版权所有  备案号:豫ICP备2022016495号-17   联系邮箱:93 96 74 66 9@qq.com