Scientific Linux Forum.org



  Reply to this topicStart new topicStart Poll

> Own Kernel Module: Invalid Format
raddirad
 Posted: Feb 3 2015, 01:41 PM
Quote Post


SLF Newbie


Group: Members
Posts: 4
Member No.: 3357
Joined: 3-February 15









Hi,
I am currently developting Software on a machine with Scientific Linux.

My current task involves writing my software as a Kernel Module.
For the beginning I decided to write a simple Hello World

CODE

#include <linux/module.h>       /* Needed by all modules */
#include <linux/kernel.h>       /* Needed for KERN_INFO */
#include <linux/init.h>         /* Needed for the macros */
static int __init hello_start(void)
{
       printk(KERN_INFO "Loading hello module...\n");
       printk(KERN_INFO "Hello world\n");
       return 0;
}
static void __exit hello_end(void)
{
       printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("M. Radtke");


uname -r says
CODE
2.6.32-358.23.2.el6.x86_64


My Makefile
CODE

obj-m += hello.o

all:
       make VERBOSE=1 -C /lib/modules/`uname -r`/build M=`pwd` modules

clean:
       make -C /lib/modules/`uname -r`/build M=`pwd` clean


it compiles fine but when i try to load the module with insmod I get the following error
CODE

insmod: error inserting './hello.ko': -1 Invalid module format


dmesg | tail
CODE

hello: no symbol version for module_layout


I am not aware why the module does not want to load.
I am using the build directory of the currently used kernel.

Any help on how to make the module work?

Thanks in advance
PM
^
toracat
 Posted: Feb 3 2015, 06:33 PM
Quote Post


SLF Geek
****

Group: Members
Posts: 303
Member No.: 11
Joined: 10-April 11









Could you show us the output returned by :

CODE
rpm -qa kernel\* | sort

--------------------
ELRepo: repository specializing in hardware support for EL
PMUsers Website
^
raddirad
 Posted: Feb 4 2015, 02:10 PM
Quote Post


SLF Newbie


Group: Members
Posts: 4
Member No.: 3357
Joined: 3-February 15









Hi
here's the output

CODE

kernel-2.6.32-279.14.1.el6.x86_64
kernel-2.6.32-358.23.2.el6.x86_64
kernel-2.6.32-358.6.2.el6.x86_64
kernel-devel-2.6.32-358.23.2.el6.x86_64
kernel-devel-2.6.32-358.6.2.el6.x86_64
kernel-devel-2.6.32-431.23.3.el6.x86_64
kernel-firmware-2.6.32-358.23.2.el6.noarch
kernel-headers-2.6.32-431.23.3.el6.x86_64
PM
^
toracat
 Posted: Feb 4 2015, 05:02 PM
Quote Post


SLF Geek
****

Group: Members
Posts: 303
Member No.: 11
Joined: 10-April 11









kernel-header has a new version than the running kernel. Whether this could cause the issue remains to be seen.

Could you try building the kmod-hellop package available from ELRepo?

http://elrepo.org/linux/testing/el6/SRPMS/hellop-kmod-0.5-6.el6.elrepo.src.rpm

I encourage you to look at the source code (written by Alan Bartlett).

--------------------
ELRepo: repository specializing in hardware support for EL
PMUsers Website
^
burakkucat
 Posted: Feb 4 2015, 05:12 PM
Quote Post


SLF Administrator
****

Group: Admins
Posts: 208
Member No.: 14
Joined: 10-April 11









QUOTE (toracat @ Feb 4 2015, 05:02 PM)
Could you try building the kmod-hellop package available from ELRepo?

http://elrepo.org/linux/testing/el6/SRPMS/hellop-kmod-0.5-6.el6.elrepo.src.rpm

I encourage you to look at the source code (written by Alan Bartlett).

To be utterly honest, the code was adapted and modified by me. Its genesis is way back in the mists of time of the Linux kernel . . .

--------------------
user posted image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.
PMUsers Website
^
toracat
 Posted: Feb 4 2015, 05:15 PM
Quote Post


SLF Geek
****

Group: Members
Posts: 303
Member No.: 11
Joined: 10-April 11









In case people do not recognize ... burakkucat == Alan Bartlett. ohmy.gif

--------------------
ELRepo: repository specializing in hardware support for EL
PMUsers Website
^
burakkucat
 Posted: Feb 4 2015, 05:59 PM
Quote Post


SLF Administrator
****

Group: Admins
Posts: 208
Member No.: 14
Joined: 10-April 11









And in the same spirit, I post --

In case people do not recognize ... toracat == Akemi Yagi biggrin.gif

--------------------
user posted image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.
PMUsers Website
^
raddirad
 Posted: Feb 5 2015, 02:24 PM
Quote Post


SLF Newbie


Group: Members
Posts: 4
Member No.: 3357
Joined: 3-February 15









ok problem is solved

i used a newer version of gcc to compile my module. this caused the module to not load.

didnt knew that a newer gcc for the module and older gcc which compiled the kernel can cause this much trouble

thanks for your help guys
PM
^
toracat
 Posted: Feb 5 2015, 04:57 PM
Quote Post


SLF Geek
****

Group: Members
Posts: 303
Member No.: 11
Joined: 10-April 11









QUOTE (raddirad @ Feb 5 2015, 06:24 AM)
ok problem is solved

i used a newer version of gcc to compile my module. this caused the module to not load.

didnt knew that a newer gcc for the module and older gcc which compiled the kernel can cause this much trouble

That is curious. Would you mind letting us know which version of gcc caused the issue?

--------------------
ELRepo: repository specializing in hardware support for EL
PMUsers Website
^
helikaon
 Posted: Feb 6 2015, 07:41 AM
Quote Post


SLF Administrator
*******

Group: Admins
Posts: 836
Member No.: 4
Joined: 8-April 11









QUOTE (toracat @ Feb 4 2015, 05:15 PM)
In case people do not recognize ... burakkucat == Alan Bartlett.  ohmy.gif


QUOTE (burakkucat @ Feb 4 2015, 05:59 PM)
And in the same spirit, I post --

In case people do not recognize ... toracat == Akemi Yagi  biggrin.gif


.... and i thought that multilayered inet personality == troll (jk) biggrin.gif
Glad we have you guys around!

(and sorry for hijacking the thread, couldn't help myself, too tempting ... biggrin.gif )

--------------------
PMEmail Poster
^
raddirad
 Posted: Feb 6 2015, 11:36 AM
Quote Post


SLF Newbie


Group: Members
Posts: 4
Member No.: 3357
Joined: 3-February 15









QUOTE (toracat @ Feb 5 2015, 04:57 PM)
QUOTE (raddirad @ Feb 5 2015, 06:24 AM)
ok problem is solved

i used a newer version of gcc to compile my module. this caused the module to not load.

didnt knew that a newer gcc for the module and older gcc which compiled the kernel can cause this much trouble

That is curious. Would you mind letting us know which version of gcc caused the issue?


Version for compiling the Kernel 4.4.7
Version for compiling Module 4.8.2

luckily i didnt replace the older gcc with the new one, had to source it instead
PM
^
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll