LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   kernel module problem (https://www.linuxquestions.org/questions/programming-9/kernel-module-problem-509603/)

tgo 12-12-2006 12:32 AM

kernel module problem
 
after trying to compile a pretty stanard lkm I wrote I got this error ( among many others from included files )

Code:

In file included from /lib/modules/2.6.17.2/build/include/linux/rwsem.h:27,
                from /lib/modules/2.6.17.2/build/include/asm/semaphore.h:42,
                from /lib/modules/2.6.17.2/build/include/linux/sched.h:20,
                from /lib/modules/2.6.17.2/build/include/linux/module.h:10,
                from ftpsniff.c:3:
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__down_read':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:105: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__down_write':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:157: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__up_read':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:194: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:188: warning: unused variable 'tmp'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__up_write':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:220: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__downgrade_write':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:245: error: expected ':' or ')' before 'KBUILD_BASENAME'

I googled the first line about __down_read and it seems many other projects had this problem in their bug reports and other people asking about it but no one had a solution. It seems to only hapeen in 2.6.15 > kernels and I am running 2.6.17.2.

Has anyone seen this error or is there some config option i missed that would cause this?

thanks

Simon Bridge 12-12-2006 05:34 PM

/lib/modules/2.6.17.2/build/include/asm/rwsem.h
... have you tried looking in that header, lines 105, 157, etc, and seeing if there is a missing ":" or ")" that should be there?

You'll find googling "rwsem.h:105: error: expected ':' or ')'" more productive... lots of folk with your kernel are experiencing difficulty with this header.

pcastone 12-23-2006 03:05 PM

Here is a fix
 
The root cause of this problem is somewhere around 2.6.15 the inline function LOCK_SECTION_NAME was defined as
#define LOCK_SECTION_NAME ".text.lock." __stringify(KBUILD_BASENAME)
In latter release of the the 2.6.xx kernel it's define as
#define LOCK_SECTION_NAME".text.lock."KBUILD_BASENAME
without the __stringify macro.

The fix is to use KBASE_STR macro at then Makefile level.

add these lines to your Makefile or Makefile.am

KMOD = <Module Name> # Name of module
KBASE= <Module Base> # Name of Base

CFLAGS+= -D"KBUILD_STR(s)=\#s"
CFLAGS+= -D"KBUILD_BASENAME=KBUILD_STR(${KBASE})"
CFLAGS+= -D"KBUILD_MODNAME=KBUILD_STR(${MOD})"

Last thing make sure that you build str uses ${CFLAGS}
IE: cc ${CFLAGS} <...>

tgo 12-23-2006 04:13 PM

yes sorry for not replying to this post after getting it figured. Changing my makefile similar to how you mentioned it fixed it. thanks.


All times are GMT -5. The time now is 07:39 PM.