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?

2 Answers 2

16

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?

2

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

1
  • 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, 2017 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .