How to strip Linux kernel modules?


We have a kernel module file named gpdrv.ko which is a custom driver and we don’t have the source codes.

It’s file size about 120 KB, after stripping, module size decreases as low as 10 KB.

But when we try to insert stripped module, it gives following error:

module has no symbols (stripped?)
insmod: can't insert 'gpdrv.ko': invalid module format

Is it possible to strip kernel module object? If so, how?


Stripping linux kernel module objects is possible but you need to take attention that you can’t use the default parameters. You can only strip debugging symbols from kernel objects with --strip-debug parameter:

strip --strip-debug module.ko

If you don’t give any parameter at all, it will also removes the names of the symbols that the module calls.