Undefined Symbols with Kernel Modules
807567Sep 21 2000 — edited Sep 21 2000I am trying to create a kernel module which will export one of
its functions globally, so that another kernel module which will
be loaded afterwords can access that function like normal.
Inside of the first module which exports this function, I have
declared it as a extern inside of a header which both kernel
modules include.
I would imagine this would work, in all the documentation that
I have read it describes the kernel as being a runtime linker which
when a new kernel module is loaded, will resolve the symbols and
add them to a global linkage map inside of the kernel for all modules
to use.
I can compile both kernel modules fine without errors, and I can
load the first module which will export the function for the second,
but when I go to try to load the second kernel module it will not load
due to an undefined symbol of the function that I wanted to use.
This is the output I get when I load the kernel modules:
void / # nm -g /dev/ksyms | fgrep mem_alloc
void / # modload ./core
void / # nm -g /dev/ksyms | fgrep mem_alloc
[13185] |1518157880| 132|FUNC |GLOB |0 |ABS |mem_alloc
void / # modload ./driver
./driver: undefined symbol mem_alloc
As you can see above, the kernel symbol table does have the
mem_alloc symbol , after I loaded the core kernel module, yet it says
it is undefined when the driver kernel module attempts to use it.
I have seen another time when this exact thing works, for example
when using kmem_alloc() which is a extern function that the
kernel exports, which all loadable kernel modules can call.
Can anyone tell me why this is happening, and how I would go about
fixing it?