I see that the virtual method table (VMT, a.k.a. VFT) contains some odd values, e.g.:
obj:0x123c1a8 [704] vmt:0x611f77f8
data: 0123c1a8 f8 77 1f 61 00 96 23 01 00 00 00 00 c4 e0 b4 5c 00 00 00 00 00 00 00 00 00 00 00 00 30 f2 76 5e 78 a2 23 01 78 e0 b4 5c 00 00 00 00 14 b1 75 5e 00 00 00 00 f8 7c 1f 61 f0 a2 23 01 00 00 00 00 `w`a``#````````\````````````0`v^x`#`x``\``````u^`````|`a``#`````
vmt: 611f77f8 09 63 98 60 25 63 98 60 95 67 98 60 e5 67 98 60 9d 68 98 60 e1 2f 9f 5c 51 07 9f 5c 45 07 9f 5c 49 07 9f 5c 4d 07 9f 5c 99 a3 69 5e a1 a3 69 5e 31 dd 68 5e a1 dd 68 5e d1 dd 68 5e c1 dd 68 5e `c``%c```g```g```h```/`\Q``\E``\I``\M``\``i^``i^1`h^``h^``h^``h^
(You see these odd 0x60986309 and 60986325 in the beginning of the virtual function table.)
What is stored in the virtual function table?
The compiler is GCC, more precisely, G++ (GNU C++) for ARM from the Android NDK.
EDIT: I see that the VMT contains entries that are not pointers to functions.
Here's the disassembled code for the Qt class QSystemLocale
, you see pairs of lines, these are the IDA output lines followed by the same lines processed by c++filt
:
_ZTV13QSystemLocale DCD 0, _ZTI13QSystemLocale, _ZN13QSystemLocaleD2Ev+1, _ZN13QSystemLocaleD0Ev+1
vtable for QSystemLocale DCD 0, typeinfo for QSystemLocale, QSystemLocale::~QSystemLocale()+1, QSystemLocale::~QSystemLocale()+1
DCD _ZNK13QSystemLocale5queryENS_9QueryTypeE8QVariant+1
DCD QSystemLocale::query(QSystemLocale::QueryType, QVariant) const+1
DCD _ZNK13QSystemLocale14fallbackLocaleEv+1
DCD QSystemLocale::fallbackLocale() const+1
Here we see that:
there is a suspicious 0 in the very beginning of VMT. It is reasonable to suggest that sometimes it may be not 0, as it happened in the dump above, but what is it then? See here.
there is typeinfo. What does it allow to do? See here.
there are two destructors,
_ZN13QSystemLocaleD2Ev
and_ZN13QSystemLocaleD0Ev
. See why.and, finally:
can I be sure that VMT is not initialized/modified at run-time? If it is written to, what gets written?
The typeinfo
is:
EXPORT _ZTI13QSystemLocale
EXPORT typeinfo for QSystemLocale
_ZTI13QSystemLocale DCD _ZTVN10__cxxabiv117__class_type_infoE+8, _ZTS13QSystemLocale
typeinfo for QSystemLocale DCD vtable for __cxxabiv1::__class_type_info+8, typeinfo name for QSystemLocale