pts
pts

Reputation: 87291

How to remove unused code from Linux .so files?

I have binaries X, Y, Z, and they use libA.so, libB.so and libD.so (as printed by ldd). Is there a tool which makes the libA.so, libB.so and libD.so files smaller by removing all symbols (and the associated code and data) which is not used by any of X, Y and Z? I don't have access to the source code of the programs or the .so files.

I think I've seen such an .so stripping tool a few years ago, but I forgot the details.

Upvotes: 2

Views: 2172

Answers (1)

pts
pts

Reputation: 87291

I've just found Library Optimizer, but it needs the original .o object files from which libA.so etc. was built.

I've also found mklibs. It also needs .o files, e.g. /lib/libc_pic.a. But it's very convenient to use, and installation is also easy: sudo apt-get install mklibs. Please note that most shared libraries don't have a precompiled *_pic.a, so there will be no size savings.

Upvotes: 2

Related Questions