Example #1
0
int
in_dso2 (void)
{
  int *foop;
  int result = 0;
  static int n;
  int *np;

  puts ("foo");			/* Make sure PLT is used before macros.  */
  asm ("" ::: "memory");

  foop = TLS_GD (foo);
  np = TLS_GD (comm_n);

  if (n != *np)
    {
      printf ("n = %d != comm_n = %d\n", n, *np);
      result = 1;
    }

  result |= in_dso (*foop = 42 + n++, foop);

  *foop = 16;

  return result;
}
Example #2
0
static int
do_test (void)
{
  int result = 0;
  int *ap, *bp, *cp;


  /* Set the variable using the local exec model.  */
  puts ("set baz to 3 (LE)");
  ap = TLS_LE (baz);
  *ap = 3;


  /* Get variables using initial exec model.  */
  puts ("set variables foo and bar (IE)");
  ap = TLS_IE (foo);
  *ap = 1;
  bp = TLS_IE (bar);
  *bp = 2;


  /* Get variables using local dynamic model.  */
  fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
  ap = TLS_GD (foo);
  bp = TLS_GD (bar);
  cp = TLS_LD (baz);
  printf (" = %d\n", *ap + *bp + *cp);
  result |= *ap + *bp + *cp != 6;
  if (*ap != 1)
    {
      printf ("foo = %d\n", *ap);
      result = 1;
    }
  if (*bp != 2)
    {
      printf ("bar = %d\n", *bp);
      result = 1;
    }
  if (*cp != 3)
    {
      printf ("baz = %d\n", *cp);
      result = 1;
    }


  result |= in_dso ();

  return result;
}
Example #3
0
int
in_dso (int n, int *caller_foop)
{
  int *foop;
  int result = 0;

  puts ("foo");			/* Make sure PLT is used before macros.  */
  asm ("" ::: "memory");

  foop = TLS_GD (foo);

  if (caller_foop != NULL && foop != caller_foop)
    {
      printf ("callers address of foo differs: %p vs %p\n", caller_foop, foop);
      result = 1;
    }
  else if (*foop != n)
    {
      printf ("foo != %d\n", n);
      result = 1;
    }

  *foop = 16;

  return result;
}
Example #4
0
static int
do_test (void)
{
  int result = 0;
  int *ap, *bp;


  /* Set the variable using the local exec model.  */
  puts ("set bar to 1 (LE)");
  ap = TLS_LE (bar);
  *ap = 1;


  /* Get variables using initial exec model.  */
  fputs ("get sum of foo and bar (IE)", stdout);
  ap = TLS_IE (foo);
  bp = TLS_IE (bar);
  printf (" = %d\n", *ap + *bp);
  result |= *ap + *bp != 1;
  if (*ap != 0)
    {
      printf ("foo = %d\n", *ap);
      result = 1;
    }
  if (*bp != 1)
    {
      printf ("bar = %d\n", *bp);
      result = 1;
    }


  /* Get variables using local dynamic model.  */
  fputs ("get sum of foo and bar (LD)", stdout);
  ap = TLS_LD (foo);
  bp = TLS_LD (bar);
  printf (" = %d\n", *ap + *bp);
  result |= *ap + *bp != 1;
  if (*ap != 0)
    {
      printf ("foo = %d\n", *ap);
      result = 1;
    }
  if (*bp != 1)
    {
      printf ("bar = %d\n", *bp);
      result = 1;
    }


  /* Get variables using generic dynamic model.  */
  fputs ("get sum of foo and bar (GD)", stdout);
  ap = TLS_GD (foo);
  bp = TLS_GD (bar);
  printf (" = %d\n", *ap + *bp);
  result |= *ap + *bp != 1;
  if (*ap != 0)
    {
      printf ("foo = %d\n", *ap);
      result = 1;
    }
  if (*bp != 1)
    {
      printf ("bar = %d\n", *bp);
      result = 1;
    }

  return result;
}