开发者

Is there a way to get Splint or a similar static checker to work with Linux Kernel modules?

I compiled ( no warnings ) the hello-5.c example from "The Linux Kernel Module Programming Guide" and when I tried to insmod it, I received the following error:

insmod: error inserting 'hello-5.ko': -1 Unknown symbol in module

I thought I would try splint to see if it came up with any obvious errors, but when I ran it I got a slew of warnings from the kernel headers until it barfed trying to parse asm/types.h

anon@anon:~/ker开发者_如何学Cnel-source/lkmpg$ splint -I/lib/modules/$(uname -r)/build/include hello-5.c
Splint 3.1.1 --- 03 Nov 2006

( ... lots of warnings ... )

/lib/modules/2.6.24-24-insp8600/build/include/asm/types.h:13:24: Parse Error:
    Suspect missing struct or union keyword: __signed__ :
    unsigned short int. (For help on parse errors, see splint -help
    parseerrors.)
*** Cannot continue.

So really there are two questions:

  1. How do I fix the insmod error?
  2. How do I get splint to play nice with the kernel headers?


Funny. Currently I'm sitting in the office and trying to run a static checker on Linux Kernel drivers :)

Static checkers have a hard time processing linux kernel, because C dialect used in kernel code is broader than the one commonly understood as "C language". It sometimes happens that C front-end of a checker just can't parse ever-changing constructs used in the code.

As I could understand, you simply use an outdated version of the checker (03 Nov 2006), but your kernel version is outdated too, and I don't know which is older. What may help is updating the checker to its current version, or using up-to-date C front-end, if the checker supports switching it.

Moreover, if a checker can process Linux kernel, the fact outright becomes being bragged about on the checker's homepage. So, pick one that claims it and do your checks.


I'm not sure but this might be what I'm looking for:

splint-discuss Using Splint on Linux kernel modules

It provides a custom make file to help splint get through the gcc specific extensions used in the Kernel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜