My first encounter with kernel modules was when my systems running Fedora Core 5 started crashing after the kernel update to 2.6.18. Long story short, it was due to a bug in the cifs kernel module which was fixed after more than 100 e-mail exchanges with samba developers. The problem was solved, but there was something I never understood; the patched cifs module I built was much larger than the distro’s. This is always true. A custom-built version can be more than 10-times larger than its counter part in the distro kernel.
I never pursued this issue until the other day when wolfy and Ned started a conversation on IRC about this size difference. It is not due to stripping because the distro version is “not stripped” and, in fact, if you strip it the module no longer loads.
Then later, Alan asked in his clever voice, “have you checked the options to strip? It might be that a total strip is verboten but a selective strip works?”
That was it! 🙂
I tried a strip --strip-unneeded
command and that reduced the size of my module file to something close to the distro’s AND the file remained “not stripped“. Soon after, Ned found the --strip-debug
option does the trick, too. This is probably what is used when the kernel is built and modules compiled.
Mystery solved.
I’m not sure why kmod modules don’t get stripped by default – maybe one should add a ‘strip –strip-debug’ to the %install section of the SPEC file.
Alan has added this strip stanza to the kmod spec example file[1]:
# Strip the module(s).
find ${INSTALL_MOD_PATH} -type f -name \*.ko -exec strip --strip-debug \{\} \;
[1] http://wiki.centos.org/HowTos/BuildingKernelModules