Skip to contentSkip to conversation

Linux 2.6 kernel module compilation without using KBUILD

DISCUSSION murtuja bharmal 3 participants 6 messages Nov 28, 2007

lore
Share & tools
lore
#0 lore raw

Hello All,

I want to compile external linux kernel module without using KBUILD.
I tried to find out whole process of kernel module compilation using KBUILD after enabling flag KBUILD_VERBOSE=1.

If we look at 2.6 kernel module building process.

1. gcc is making ".hello.o.d" and ".tmp_hello.o" from "hello.c" file.
2. Creating "hello.o" file using ".hello.o.d" and ".tmp_hello.o".
3. Running Script "scripts/mod/modpost" to create "hello.mod.c" using “hello.o”.
4. gcc is making "hello.mod.o" after compiling "hello-mod.c" file.
5. finally "ld" is linking "hello.o"
and "hello.mod.o" and making "hello.ko".

Step 2 of above process is not very much cleared, how it is making hello-2.o from ".hello.o.d" and ".tmp_hello.o".

What is ".tmp_hello.o”.

Do we have any document which describe how to make kernel module without using KBUILD.

Any pointer of information is very helpful for me.

Thanks
Murtuja Bharmal

      ____________________________________________________________________________________

Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

#1 lore raw
Quoted 4 lines · murtuja bharmal

Hello All,

I want to compile external linux kernel module without using KBUILD.

...

Quoted 2 lines

Do we have any document which describe how to make kernel module without using KBUILD.

No.
Becasue building kernel modules without using kbuild is highly discouraged and vulnerable for all sort of config related issues. As a simple example the module may become unuseable if just one change is made to the configuration because this changes the parameters passed to gcc which again affects the code being built.

Can you try to enlighting why you want to avoid kbuild. If you have a specific problem then maybe kbuild already can do what you need.

Sam

#2 lore raw
Quoted 30 lines · --- Sam Ravnborg
Quoted 3 lines · murtuja bharmal

Hello All,

I want to compile external linux kernel module

without

Quoted 1 line

using KBUILD.

...

Quoted 2 lines

Do we have any document which describe how to make kernel module without using KBUILD.

No.
Becasue building kernel modules without using kbuild is highly
discouraged and vulnerable for all sort of config related issues.
As a simple example the module may become unuseable if just one
change is made to the configuration because this changes
the parameters passed to gcc which again affects the code
being built.

Can you try to enlighting why you want to avoid
kbuild.
If you have a specific problem then maybe kbuild
already can
do what you need.

Quoted 9 lines

Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Hello Sam,

My intention is to just understand whole process of making kernel module.
Actually I am working on one project in which I have to port lots of 2.4 kernel module in 2.6 kernel. So I thought lets first try to understand, what is going behind KBUILD.
I also gone through linux/Documentation/kbuild/ but didn't get very much information.
Even after running it on Verbose Mode, I am not very much clear.

Thanks
Murtuja Bharmal

      ____________________________________________________________________________________

Get easy, one-click access to your favorites. Make Yahoo! your homepage.
http://www.yahoo.com/r/hs

#3 lore raw
Quoted 11 lines · murtuja bharmal

Hello Sam,

My intention is to just understand whole process of making kernel module. Actually I am working on one project in which I have to port lots of 2.4 kernel module in 2.6 kernel. So I thought lets first try to understand, what is going behind KBUILD. I also gone through linux/Documentation/kbuild/ but didn't get very much information. Even after running it on Verbose Mode, I am not very much clear.

Thanks
Murtuja Bharmal

you'd probably be better off asking this on the kernel newbies list rather than the main kernel list. and, as an intro to porting 2.4 to 2.6 modules, you might want to start here:

http://lwn.net/Articles/driver-porting/

and, as others have suggested, you're probably better off just figuring out the 2.6 kbuild structure. trying to do this manually without kbuild is just making this way more difficult than it has to be.

rday

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

#4 lore raw
Quoted 36 lines · --- "Robert P. J. Day
Quoted 3 lines · murtuja bharmal

Hello Sam,

My intention is to just understand whole process

of making kernel

Quoted 1 line

module. Actually I am working on one project in

which I have to port

Quoted 1 line

lots of 2.4 kernel module in 2.6 kernel. So I

thought lets first try

Quoted 1 line

to understand, what is going behind KBUILD. I also

gone through

Quoted 1 line

linux/Documentation/kbuild/ but didn't get very

much information.

Quoted 1 line

Even after running it on Verbose Mode, I am not

very much clear.

Quoted 3 lines

Thanks
Murtuja Bharmal

you'd probably be better off asking this on the kernel newbies list
rather than the main kernel list. and, as an intro to porting 2.4 to
2.6 modules, you might want to start here:

http://lwn.net/Articles/driver-porting/

and, as others have suggested, you're probably better off just
figuring out the 2.6 kbuild structure. trying to do this manually
without kbuild is just making this way more difficult than it has to
be.

Quoted 3 lines

rday

========================================================================

Quoted 7 lines

Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca

========================================================================

Quoted 1 line

Hello Robert,

I think I am not very much clear. Let me try to clarify more.
My intention is not build or port kernel driver without using KBUILD.
I know about driver porting and Writing makefile using KBUILD.
I don't have any issue about that.

I just want understand the whole process for clearity thats it.
unfortunately I didn't get any answer from linux-doc and linux-admin about this issue.
Let me try to understand KBUILD internal architecture more by self.

Any Way.
Thanks for your view.
Murtuja Bharmal

      ____________________________________________________________________________________

Be a better pen pal.
Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/

#5 lore raw
In reply to murtuja bharmal
Quoted 3 lines

My intention is to just understand whole
process of making kernel module.

The short story....
kbuild knows that .o files listed with obj-m are modules. So if you have:
obj-m := foo.o

the kbuild will know that it has to build a module named foo.o. If foo.o consist of composite objects then kbuild
is told so using:
foo-y := bar.o baz.o

So in this case kbuild will build bar.o and baz.o and use these for the resulting module named foo.

When building baz.o kbuild uses make to search for the source file. First it look for baz.c - if it fails it look for baz.s
Does both fail kbuild give up (there are some corner cases but ignore that).

When foo.o is ready is uses some linker magic to link in version information and the end result is foo.ko.

foo.ko has a number of unresolved symbols that are:
1) during build time checked if kernel or other modules define them
2) during load time they are resolved

The above is general stuff - if you need more details please be specific.

Sam