MacOs 10.6, if I have a file \"unwanted.c\" which contains:
class secret_thing {
public:
secret_thing() {}
void revealing_method_name() {}
};
main()
{
s
Given the example code you’ve posted, adding the ‘-O’ optimisation flag results in those symbols not being shown by nm
after compilation.
It sounds like what you really want isn't to strip the executable, but to obfuscate its symbol table. I'm not sure, but perhaps something like this would be helpful. At least, "C++ symbol table obfuscator" is probably a better Google search string..
Using the following compile line I successfully strip the symbols from the executable:
$ g++ -Xlinker -unexported_symbol -Xlinker "*" -o executable file.cpp
$ strip executable
Given the latest sample file, this results in:
$ nm executable
U __ZTVN10__cxxabiv117__class_type_infoE
U __ZTVN10__cxxabiv120__si_class_type_infoE
U __ZdlPv
U __Znwm
U ___cxa_pure_virtual
U ___gxx_personality_v0
0000000100000000 A __mh_execute_header
U _exit
U dyld_stub_binder
This seems to work as desired...:
$ strip unwanted
$ nm unwanted | grep secret | cut -f 3 -d ' ' > /tmp/remove
$ strip -R /tmp/remove unwanted