9

I regularly create packages for Slackware Linux and part of the process is stripping binaries so that they take up less space. I find that if I strip --strip-all (or strip with no options) kernel modules, they often fail to insert:

FATAL: Error inserting cloop (/lib/modules/2.6.38.7-smp/kernel/fs/cloop/cloop.ko): Invalid module format

What level of stripping is recommended for kernel modules? If I use --strip-debug, will I remove debugging symbols that will negatively affect system performance and/or error logging?

amphetamachine
  • 5,388
  • 2
  • 34
  • 41

2 Answers2

15

Stripping all symbols removes the names of the symbols that the module calls. It's not going to work.

Stripping debugging symbols with strip --strip-debug *.ko (= strip -g *.ko) is safe. The kernel makefile does it for you if you run make INSTALL_MOD_STRIP=1 modules_install.

You can prevent debugging symbols being inserted in the first place by configuring your kernel with CONFIG_DEBUG_INFO not defined.

See also How do I strip local symbols from linux kernel module without breaking it?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
2

I believe the safest approach is strip --strip-unneeded.

David Schwartz
  • 5,294
  • 22
  • 27
  • 1
    I see that `--strip-unneeded` also strips `.modinfo` section, including the 'module depends' and the 'vermagic' things. Unsure what would be the consequences. – PypeBros Nov 29 '17 at 13:22