ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There is a module A which is compiled with the kernel.
I wrote an external module B which exported a symbol using EXPORT_SYMBOL.
The module A now needs to talk with that exported symbol (function call). For that i modified A so that it includes the function call from B. However i now get unidentified symbol errors during 'make' operation as symbols of B are not present during kernel compile and A now kind of depends on B.
One solution is that make B part of the kernel as well. However, it would mean that whenever now i try to compile a kernel with a different source, i have to modify the config files and everything to accommodate B.
Hence i am seeking a solution which does not include modifying the kernel.
There is a module A which is compiled with the kernel.
I assume that you mean a real kernel module that will be dynamically loaded in the Linux kernel by using modprobe/insmod. Right?
Quote:
Originally Posted by bizoo
The module A now needs to talk with that exported symbol (function call). For that i modified A so that it includes the function call from B. However i now get unidentified symbol errors during 'make' operation as symbols of B are not present during kernel compile and A now kind of depends on B.
Well, the first question is, how do you build the two modules? In the context of the currently running kernel sources or did you create an own make file? Secondly, did you include the function prototype of B in A?
If you search for 'Linux 2.6 kernel modules' using your favorite WEB search engine, you'll get the following two tutorials:
As a hint: always compile your kernel modules with the kernel makefiles as described in the tutorials. Furthermore, it is important to use the sources of the kernel which is currently running on your system, otherwise you might get unwanted side-effects
More generally, you shouldn't get undefined symbols at module link time (if you use the correct make file), because the 'kernel' linker will resolve those symbols at load-time when insmod()ed into your kernel.
For example, take any of the existing modules of your kernel and do a 'nm' on the module file und you'll see some 'undefined symbols' like e.g. kfree.
Quote:
Originally Posted by bizoo
One solution is that make B part of the kernel as well. However, it would mean that whenever now i try to compile a kernel with a different source, i have to modify the config files and everything to accommodate B.
Hence i am seeking a solution which does not include modifying the kernel.
You only need the kernel makefile, but you could keep your module source code independent of the kernel source code (except the kernel header files).
If anythink is unclear or you have further questions, just post them :-)
I assume that you mean a real kernel module that will be dynamically loaded in the Linux kernel by using modprobe/insmod. Right?
Yes
Quote:
Well, the first question is, how do you build the two modules? In the context of the currently running kernel sources or did you create an own make file? Secondly, did you include the function prototype of B in A?
Well module A is compiled with the kernel source and its makefile is embedded in the kernel and it also has its own Kconfig file. Thus whenever i make changes inside A, i just go to my linux kernel source and type 'make'. Always does the job for me. Then i simply load my my module through insmod or modprobe. And yes, the module A have the prototype of function from B.
Module B is not built in the kernel and has its own makefile in which i seek the kernel Makefile to compile my module.
Quote:
As a hint: always compile your kernel modules with the kernel makefiles as described in the tutorials. Furthermore, it is important to use the sources of the kernel which is currently running on your system, otherwise you might get unwanted side-effects
I do it this way, i can even copy the makefile of module B. I am pretty sure that i am doing it the right way.
In my understanding, as module B has a symbol which is needed inside A for its compilation, Module A now depends upon module B. This means that now i have to change the Kconfig file of A and add this new dependency in. Also i have to make module B before A and as A comes from the kernel source, B should also be there in the kernel source tree and thats what i want to avoid.
Hope i have presented my situation a bit more clearly and thanking in anticipation for more pointers and ideas!
Well module A is compiled with the kernel source and its makefile is embedded in the kernel and it also has its own Kconfig file. Thus whenever i make changes inside A, i just go to my linux kernel source and type 'make'. Always does the job for me. Then i simply load my my module through insmod or modprobe. And yes, the module A have the prototype of function from B.
Module B is not built in the kernel and has its own makefile in which i seek the kernel Makefile to compile my module.
Right, both sounds okay to me ...
Quote:
Originally Posted by bizoo
In my understanding, as module B has a symbol which is needed inside A for its compilation, Module A now depends upon module B. This means that now i have to change the Kconfig file of A and add this new dependency in. Also i have to make module B before A and as A comes from the kernel source, B should also be there in the kernel source tree and thats what i want to avoid.
Right, module A depends on module B which means that module B must be loaded into the kernel BEFORE module A gets loaded. Though, either you guarantee this dependency by using a shell script which insmod() the modules in the correct order or you use the dependency model of depmod.
I don't think you need module B to be available in the kernel source tree. If you would use the depmod utility, it just checks for the available kernel objects (ko) and doesn't care about where a specific module was built.
Anyway, this is just the secondary step, but you're already getting problems during compilation.
Could you possibly make your code available in the net? I mean just the sources which aren't available in the vanilla tree (maybe a diff?).
- Andi -
Hope i have presented my situation a bit more clearly and thanking in anticipation for more pointers and ideas!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.