finally I made #gcc plugin to collect struct/classes fields & virtual methods calls cross-references, part 1: redplait.blogspot.com/2023/0… plugin src: github.com/redplait/dwarfdum…
1
5
20
isn't -fdump-lang-class good enough to associate vtable offsets with methods?
1
no, it can show you vtables but not where are their methods called from
1
i see, for call sites i'd look at gimple instead, IMHO it's easier to find and analyze those GIMPLE_CALLs to vmethods (OBJ_TYPE_REF models the target of the call).
1
you cannot be sure that code at GIMPLE stage will be places in real native code. this is general compilers problem, llvm has it too - see for example blog.trailofbits.com/2023/07… from OBJ_TYPE_REF you can extract types of object and called method but not name of method
1
why does DCE matter? you can just discard the information you don't need? as for the method name, you can extract the base class info from the 'this' arg type then parsing TYPE_BINFO/BINFO_VIRTUALS/etc will get you method names.
1
the accuracy btw code can be omitted not only due to dce, but for example can be converted to ordinary non-virtual call - see ipa-devirt.cc in gcc src
1
Replying to @real_redp
i must be missing something here ;). if some virtual call does not end up in the final asm, surely that doesn't affect whatever you computed for those that do end up in there?

Jul 31, 2023 · 9:34 AM UTC

1
Replying to @paxteam
final goal of my work - to make from sources database of functions for methods they call and fields they use, so then you can find set of functions referring to some field/vmethod and investigate them with disasm