binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

GCC/Clang RTTI analysis

Open cvscade opened this issue 3 years ago • 1 comments

GCC/Clang RTTI analysis RTTI support for the Itanium ABI

Is your feature request related to a problem? No

Are any alternative solutions acceptable? There is a plugin (Itanium C++ ABI by whitequark) but it's buggy and the version in the plugin manager hasn't been updated since 2020. The plugin's repository is pretty much dead.

cvscade avatar Feb 02 '23 10:02 cvscade

I'm not 100%, so correct me if i'm wrong, but I believe this may be related to automatically creating the structs for vtable_for_* and typeinfo_for_* and similar?

If so, I was wondering why this didn't seem to currently be a thing, I first found myself at this issue (due to the empty structs not being visible in the types):

  • https://github.com/Vector35/binaryninja-api/issues/4551

And then found the following blog series, which helped me understand the in-memory layout of the vtables/etc in clang binaries a lot better:

  • https://shaharmike.com/cpp/vtable-part1/
    • C++ vtables - Part 1 - Basics

  • https://shaharmike.com/cpp/vtable-part2/
    • C++ vtables - Part 2 - Multiple Inheritance

  • https://shaharmike.com/cpp/vtable-part3/
    • C++ vtables - Part 3 - Virtual Inheritance

  • https://shaharmike.com/cpp/vtable-part4/
    • C++ vtables - Part 4 - Compiler-Generated Code

Or for something way more low-level:

  • https://clang.llvm.org/doxygen/VTableBuilder_8cpp_source.html

This may also be of interest:

  • https://blog.trailofbits.com/2017/02/13/devirtualizing-c-with-binary-ninja/

As well as the existing vtable docs:

  • https://docs.binary.ninja/guide/cpp.html#virtual-function-tables

It would be awesome if Binary Ninja core was able to handle this automagically!


Also, since they don't seem to be cross-linked currently, here is the issue for MSVC for easier findability:

  • https://github.com/Vector35/binaryninja-api/issues/3930

0xdevalias avatar Apr 11 '24 08:04 0xdevalias