1
/* this code contributed by Bert Driehuis <bert_driehuis@nl.compuware.com> */
5
// Try to determine the vtable layout generated by G++
6
// Produces the offset at which the first vtable entry can be
7
// found, and the factor to apply for subsequent entries on stdout.
9
// #define GCC_VTABLE_START 0xc
10
// #define GCC_VTABLE_FACTOR 0x8
19
test::test() { this->x = 0x12121212; };
21
int test::t1(void) { return 1; }
22
int test::t2(void) { return 2; }
25
fprintf(stderr, "%s\n", x);
40
if (*tp++ != 0x12121212)
41
die("Integer element test::x not found!");
43
for (i = 0; i < 10; i++) {
44
if (tp[i] == (int) t->t1)
46
if (tp[i] == (int) t->t2)
49
if (off1 == -1 || off2 == -1)
50
die("Could not determine offset into vtable!");
51
factor = (off2 - off1) * 4;
57
printf("/* Automatically generated by vtable_layout_x86.cpp */\n");
58
printf("#define GCC_VTABLE_START\t0x%x\n", off1 * 4);
59
printf("#define GCC_VTABLE_FACTOR\t0x%x\n", (off2 - off1) * 4);
60
printf("#define GCC_VTABLE_SHIFT\t0x%x\n", factorshift);