[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unresolved Symbol in Module
On Thu, 8 Mar 2001, Narayana, Venkat A. wrote:
> I am learning to write kernel modules, and while experimenting
> with a simple module, i got
> " hello.o: unresolved symbol printk_Rsmp_1b7d4074" error
> while loading this module via insmod hello.o command.
>
> I noticed that /proc/ksyms contains printk symbol.
If you have "printk" in /proc/ksyms then your kernel was compiled without
version info. To compile a kernel without version info you turn off the
CONFIG_MODVERSIONS flag in the configuration. If your kernel were
compiled with version info then /proc/ksyms would have had an entry for
printk_Rsmp_1b7d4074 instead of just printk.
To see the symbols in your module you can run "nm" on it. Your original
module (built with CONFIG_MODVERSIONS) would have had an entry of:
U printk_Rsmp_1b7d4074
but now that you've recompiled without CONFIG_MODVERSIONS it will have an
entry of:
U printk
The first symbol isn't in your /proc/ksyms, and the second one is, which
is why recompiling without CONFIG_MODVERSIONS allows the module to be
inserted.
However, if you are writing kernel modules, you should have versioning
info in your kernel. This allows your modules to call functions in the
kernel which haven't changed between versions. But as soon as a kernel
function changes it will get a new symbol and your module won't be
insertable anymore. This is a good thing, since it prevents your module
from assuming that a function is the same as it always was, even when it
isn't.
Someone commented that there isn't a lot of documentation. It's not
centralized (IMHO), and it doesn't really explain the "why" of it very
well, but it's there. From Documentation/modules.txt:
"You also have a possibility to create modules that are less dependent on
the kernel version. This option can be selected during "make config", by
enabling CONFIG_MODVERSIONS, and is most useful on "stable" kernel
versions, such as the kernels from the 1.2 and 2.0 series. If you have
modules that are based on sources that are not included in the official
kernel sources, you will certainly like this option..."
Also relevant is the help text for CONFIG_MODVERSIONS in the file
Documentation/Configure.help:
"CONFIG_MODVERSIONS
Usually, modules have to be recompiled whenever you switch to a new
kernel. Saying Y here makes it possible, and safe, to use the
same modules even after compiling a new kernel; this requires the
program modprobe. All the software needed for module support is in
the modutils package (check the file Documentation/Changes for
location and latest version). NOTE: if you say Y here but don't
have the program genksyms (which is also contained in the above
mentioned modutils package), then the building of your kernel will
fail. If you are going to use modules that are generated from
non-kernel sources, you would benefit from this option. Otherwise
it's not that important. So, N ought to be a safe bet."
Regards,
Paul Gearon
pag@PISoftware.com
Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml