I need to remove unused functions from a big C++ project. After reading a while I used this link: How can I know which parts in the code are never used?
I compile on RedHat using makefiles. I added to compiler the flags:
-Wall -Wconversion -ffunction-sections -fdata-sections
and to the linker the flags:
-Wl,-rpath,--demangle,--gc-sections,--print-gc-sections
For some annoying reason I receive the output after mangling even after using --demangle option. For example:
/usr/bin/ld: Removing unused section '.text._ZN8TRACABLED0Ev' in file 'CMakeFiles/oded.dir/oded.cpp.o'
/usr/bin/ld: Removing unused section '.text._ZN8TRACABLED1Ev' in file 'CMakeFiles/oded.dir/oded.cpp.o'
So I have 6000 function names I need to unmangle and I cannot use extern C
.
I can write a script to parse it and use c++filt, but Im looking for a solution that will make the linker unmangle the function by itself!
Anyone knows if such a solution exist?