Biohazrd icon indicating copy to clipboard operation
Biohazrd copied to clipboard

Query Clang for the which vTable entry is the 0th entry

Open PathogenDavid opened this issue 3 years ago • 2 comments

Things like the RTTI pointer are stored in the vTable before the entry where the vTable pointer points. Right now we just assume the vTable pointer points to the first occurrence of a function pointer in the table. This is probably fine, but in the interest of correctness we should figure out where this information is hidden within Clang.

If I remember right, -fdump-vtable-layouts points it out for the Microsoft ABI but not Linux. I think I investigated how it was determining it but it was non-trivial and I decided to make an assumption for now instead.

Note that right now CSharpLibraryGenerator is what is handling this assumption. Ideally this should be encoded in TranslatedVTable instead.

PathogenDavid avatar Sep 13 '20 09:09 PathogenDavid

In the Itanium ABI, this entry is called the address point. The logic we use for determining the 0th entry lines up with the Itanium spec (0th entry is first function pointer.) (Reference)

PathogenDavid avatar Nov 10 '20 15:11 PathogenDavid

VTableLayout contains an AddressPoints map. This is probably what we need.

This issue is closely related to https://github.com/InfectedLibraries/Biohazrd/issues/112

PathogenDavid avatar Jun 21 '21 22:06 PathogenDavid