Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
vtable_layout_x86.cpp File Reference
#include <stdio.h>

Go to the source code of this file.

Classes

class  test

Functions

void die (char *x)
int main ()
 main()

Function Documentation

void die ( char *  x)

Definition at line 24 of file vtable_layout_x86.cpp.

                  {
      fprintf(stderr, "%s\n", x);
      exit(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void  )

main()

Definition at line 30 of file vtable_layout_x86.cpp.

{
      int             i;
      test           *t = new test();
      int            *tp = (int *) t;
      int             off1 = -1;
      int             off2 = -1;
      int             factor;
      int             factorshift;

      if (*tp++ != 0x12121212)
              die("Integer element test::x not found!");
      tp = (int *) *tp;
      for (i = 0; i < 10; i++) {
              if (tp[i] == (int) t->t1)
                      off1 = i;
              if (tp[i] == (int) t->t2)
                      off2 = i;
      }
      if (off1 == -1 || off2 == -1)
              die("Could not determine offset into vtable!");
      factor = (off2 - off1) * 4;
      factorshift = -1;
      while (factor) {
              factorshift++;
              factor >>= 1;
      }
      printf("/* Automatically generated by vtable_layout_x86.cpp */\n");
      printf("#define GCC_VTABLE_START\t0x%x\n", off1 * 4);
      printf("#define GCC_VTABLE_FACTOR\t0x%x\n", (off2 - off1) * 4);
      printf("#define GCC_VTABLE_SHIFT\t0x%x\n", factorshift);
      exit(0);
}

Here is the call graph for this function: