Yes, this should be possible, provided your library archive doesnít depend on any external symbols (e.g., no C-library dependence). There are two things meant by your question, and both are possible. The first is: can you have multiple source files linked to form one single loadable kernel module, much as they can form an archive or executable in userspace? The second is: suppose you have a precompiled (for the target arch) library archive making use of no external symbols. Can you use that object code in a kernel module without the source code? The answer to both is yes, as I will show in this example.
Suppose I want to make a module which will eventually be called foo.ko
. The logic is complicated enough to be separated into two separate source files: bar.c
(this addresses the first question). Additionally, there is a precompiled library filled with symbols referenced by bar.c
. This is named qux.a
(this addresses the second question). Then there is a Makefile to tie it all together (this is the file I will show you). All four of these files live in the same directory (for simplicity), which happens to be somewhere outside the kernel source tree (also for simplicity).
The Makefile might go something like this:
KERNELDIR := /lib/modules/$(shell uname -r)/build
obj-m := foo.o
foo-objs := bar.o baz.o qux.a
$(MAKE) -C $(KERNELDIR) M=$(PWD)
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
This way you can execute make
from the directory containing the sources. A module with prefix foo
(full name foo.ko
) will be built. The objects from which it is built are bar.o
. Since bar.c
are newer than bar.o
(which donít yet exist), they will be compiled into their respective objects. Since qux.a
exists (and since there is no requisite), it will be incorporated as-is.
P.S., you can read more about using Makefiles with the kbuild system here