Re: 'insmod error Invalid module format' upon an improper kernel source tree hierarchy?



On Sep 27, 8:16 am, dan.odega...@xxxxxxxxx wrote:
On Sep 26, 8:58 pm, "lovecreatesbea...@xxxxxxxxx"

<lovecreatesbea...@xxxxxxxxx> wrote:

I fail again at catching the concept of Linux 'kernel source tree' and
compiling a 'hello world' module successfully. Can you please help me
again? Thank you for your time.

I'm running a debian-40r1 (kernel 2.6.18) and got a copy of kernel
source linux-2.6.22.6.tar.bz2 from kernel.org. The version numbers of
the running kernel and the kernel source aren't exact the same, and
I'm aware of the minor difference. Will this be a problem if I don't
boot with the newly compiled kernel of 2.6.22.6.

After built the kernel source and a `hello world' module, I really
encountered a problem of `error inserting 'hellomod.ko': -1 Invalid
module format' when executed insmod.

The followings are main steps of kernel source building:

1. untar kernel source linux-2.6.22.6.tar.bz2 in my home directory.
And nothing added at /usr/src/linux. Will this be a problem?

2. su root -c 'make defconfig'

3. su root -c 'make'

4. su root -c 'make modules_install install'

Now the object files of the kernel source are all generated, those
object files are what customized kernel module programming needed, so
I just stopped here.

Do the above steps build a kernel source tree hierarchy properly,
since I didn't do the following steps '5*'.

[
5* I didn't do 'make bzImage' and didn't add corresponding entries
for the newly built kernel in GRUB or LILO.
]

if you build your kernel module using kernel sources 2.6.22.x, you
should to compile this kernel and boot using it.

Thank you.

I still don't understand the relation between the running kernel and
the kernel used for kernel module programming.

Does the following sentence extracted from the book mean that the
running kernel and the kernel used for module programming can be
different?

<quote>
LINUX DEVICE DRIVERS, 3rd by JONATHAN, ALESSANDRO and GREG, oreilly
press:
....if you are actually running the target kernel when you build your
modules, though this is not required.
</quote>

but i don't really understand why did you get kernel sources from
kernel.org if debian contains linux-source-2.6.x package that has just
the same version as your debian kernel image. so if you compile your
module using kernel sources from debian package it will work properly.

I find a kernel source package with aptitude search. The kernel source
isn't a executable, can I use aptitude install to deal with kernel
source package? I installed manpages-dev with aptitude install before,
can the kernel source case be the same...I'll have a try. Thank you
for point this out.

$ su root -c 'aptitude search linux-source-2.6'
Password:
v linux-source-2.6 -
p linux-source-2.6.18 - Linux kernel source for version
2.6.18 wit
$ uname -a
Linux jhl-debian 2.6.18-5-486 #1 Thu Aug 30 01:46:45 UTC 2007 i686 GNU/
Linux
$

.



Relevant Pages

  • Re: Distributions
    ... | general there are a lot of packages for people to use. ... kernel, have to run on a multitude of different systems, they tend to be ... and slower than if you compile those packages, ... can have that stability with virtually any distro. ...
    (Debian-User)
  • Re: Distributions
    ... Ubuntu is based on Debian, ... | general there are a lot of packages for people to use. ... kernel, have to run on a multitude of different systems, they tend to be larger ... and slower than if you compile those packages, ...
    (Debian-User)
  • Problems with custom kernel fbsd 6.2
    ... My kernel for freebsd 6.2 is not compiling but only with my custom config. ... I was able to compile it with the GENERIC kernel included, but my modified one will not compile. ... # Power management support ...
    (freebsd-questions)
  • Re: [PATCH] 2.6 workaround for Athlon/Opteron prefetch errata
    ... >optimisations independently of each other', is fairly simple, (in ... >concept), and elegant, (as it lets you compile the most finely tuned ... >Up to now, selecting a CPU to compile for basically means, "Use ... it's silly to include them all in a kernel for a 386. ...
    (Linux-Kernel)
  • Re: C++ pushback
    ... There are all sorts of macros that use member initialization of that form. ... This does not break the code at run time, this breaks the code at compile time, and should be less painful. ... The kernel relies really _really_ heavily on such structure initializers, and breaking them would effectively break the world as far as the kernel is concerned. ... If they were not, one could simply make a base class having members outlined, and which class does not enforce type safety and is for inheritance only. ...
    (Linux-Kernel)