문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top