I imported my exe file in OllyDB and when I searched for the names(labels) present, I was able to see all the function declarations, class names etc. I didn't have my PDB in the EXE path. Why does this occur? Should I enable some obfuscation settings during my build?
dynamic_cast requires a runtime check that the cast is valid at execution time and the usual implementation uses RTTI (Run-time type information) attached to all classes participating in the casts. However, since it's not easy to narrow down the classes that may be possibly casted, in practice the compiler emits RTTI for all polymorphic classes (i.e. those that have virtual methods). While the RTTI details are not specified by the C++ standard, the Visual C++ implementation retains full class names. You can find more details in my article on the topic.