Remove C ++ characters - STL / Boost debug (... or don't create them)

Linux / Gcc / LD - Toolchain.

I would like to remove STL / Boost debugging symbols from libraries and executables for two reasons:

  • Linking is becoming very slow for large programs.
  • Debugging goes into stl / boost code, which is annoying

For 1. incremental binding will be a big improvement, but AFAIK ld does not support incremental binding. In the 1999 dr.dobb magazine (not on the Internet) there is a workaround for โ€œpseudo-incremental linkingโ€, but in archive.org (the idea is to put everything in a dynamic library and all updated object files into the second one, which is loaded first), but this is not a general solution.

For 2. there is a script here , but a) it did not work for me (it did not delete characters), b) it is very slow, since it works at the end of the pipe, while it would be more efficient to delete characters earlier.

Obviously, other debugging symbols should remain in place.

+5
source share
6 answers

The GNU strip accepts regex arguments in --strip-symbols = STL and boost are denoted by names due to namespaces. I can't use gut binutils at the moment, but just look at the name mangling used for namespaces and create a regular expression for 'characters from the namespace X' and pass this to the -strip-symbols = character

+3

, , gcc. , , , .

, , .

, ( ) gcc, .

+2

, , - .

GDB DDD , Boost , . ( , !)

, .

script, , strip ( "man strip" ), .

+1

. strip --strip-unneeded --strip-debug libfoo.so

?

+1

, , MSalters STL.

STL . , , . GNU Binutils:

> nm --debug-syms <objectfile>

STL, resize. , :

> nm --debug-syms --demangle <objectfile>

, STL, , . , STL _ZNSt [0-9] + _ZSt [0-9] + ..

GNU Strip , :

> strip --wildcard              \
    --strip-symbol='_ZNKSt*'    \
    --strip-symbol='_ZNSt*'     \
    --strip-symbol='_ZSt*'      \
    --strip-symbol='_ZNSa*'     \
    <objectfile>

/ . , nm ( vimdiff). --wildcard . , [0-9] * 0 , 1 , ( ).

STL-, gdb skip file, .

,

+1

Which compiler are you using? For example, if I understood your question correctly, this is a trivial question in MS Visual Studio.

-1
source

All Articles