1
votes

When I compile a C++ binary using gcc with option to keep symbol information and when I run the following command it lists the typeinfo for the classes

objdump -Ct ExecName | grep typeinfo

When I compile with the stripped option -s and run the following it says no symbols.

But I am worried the RTTI information is being held in some other place.

I would prefer all the class names to be not shown in the binary. I would like a confirmation whether stripping symbols actually ends up removing the RTTI information.

In this presentation at Blackhat they show how to use RTTI to learn about the binary. http://www.blackhat.com/presentations/bh-dc-07/Sabanal_Yason/Paper/bh-dc-07-Sabanal_Yason-WP.pdf

I know you could turn off RTTI by using -fno-rtti when compiling but I want this to be the last resort.

1
nope (padding padding padding) - sehe
You might check with the strings command line utility whether your binary contains your class names in plain text... - arne
@pt123 The document you referenced talks about MSVC. g++ is free to implement RTTI some different way. The MSVC description includes class names, the g++ method may not. You need to find out how g++ does RTTI. - brian beuning
Brian that's why I am asking here, I have searched the internet read many questions here on RTTI, the ones concerned with class names tend to be MSVC and not g++ - pt123
@Arne you are right the Strings contained the class names with a number in front, I had missed them earlier. - pt123

1 Answers

3
votes

But I am worried the RTTI information is being held in some other place.

It is.

When I ask the compiler to perform dynamic_cast, then it must honour the contract of dynamic_cast, and that requires RTTI. The only way to escape this is to have a compiler setting which would give an error or UB when you attempt to use dynamic_cast in this fashion. The compiler is obliged to provide RTTI by the language, unless you explicitly tell it otherwise.